npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

babel-plugin-shotgun-logs

v0.0.5

Published

## Getting Started `npm install babel-plugin-shotgun-logs`

Downloads

4,275

Readme

babel-plugin-shotgun-logs

Getting Started

npm install babel-plugin-shotgun-logs

And then configure your project to run with babel plugins (docs)

Example .babelrc:

[
  [
    "babel-plugin-shotgun-logs",
    {
      "functionNameBlacklist": [ "unimportantFunction" ],
      "functionNameBlackoutList": [ "functionName" ],
      "isTerminal": true,
      "entryLogShowFullArgs": false,
      "entryLogArgOutputInline": true,
      "entryLogMultilineJSONargs": false,
      "exitLogReturnOutputInline": true,
      "exitLogStubObjects": true,
      "timeProfiling": false,
      "storeJSONexternally": {
        "sizeThreshold": 10000,
        "location": "s3",
        "bucket": "deleteme-shotgun-log-json-test"
      }
    }
  ]
]

Plugin options:

General Options

- functionNameBlacklist (Default: [])

A list of functions not to include in the shotgun log output

- functionNameBlackoutList (Default: [])

A list of functions to log but NOT log any functions that get called by this function

🟢  main() {"arg1":{"key1":1,"key2":2},"arg2":5}
--🟢  a() {"arg1":{"key1":1,"key2":2},"arg2":5}
----🟢  y() {"arg1":{"key1":1,"key2":2},"arg2":5}
----🔴  y() ⇒ {"a":1,"b":2}
----🟢  z() {"arg1":{"key1":1,"key2":2},"arg2":5}
----🔴  z() ⇒ {"a":1,"b":2}
--🔴  a() ⇒ {"a":1,"b":2}
🔴  main() ⇒ {"a":1,"b":2}

When set to [ "a" ]:

🟢  main() {"arg1":{"key1":1,"key2":2},"arg2":5}
--🟢  a() {"arg1":{"key1":1,"key2":2},"arg2":5}
--🔴  a() ⇒ {"a":1,"b":2}
🔴  main() ⇒ {"a":1,"b":2}

- isTerminal (default: true)

Boolean flag if you are viewing the shotgun log output on the terminal. This option changes the way that emojis are displayed to have the correct spacing in the terminal

- fileSizeLimitMb (default: 500)

When the log file reaches this size, a new log file will be created and the previous log file will be deleted. NOTE: Log file format is log/shotgun.log.<unix_timestamp>

storeJSONexternally (Default: false)

Examples:

{
  sizeThreshold: 10000,
  location: 'local',
}
{
  sizeThreshold: 10000,
  location: 's3',
  bucket: 'bucket_name'
}

sizeThreshold (Default: 10000)

The size in bytes that JSON needs to exceed to be written externally rather than in the .log file

location (Default: 'local')

Options: ['local', 's3'] If local: files are written to log/json/ If s3: files are written to an S3 bucket. The bucket name needs to be specified in the object and the credentials need to be specified by the env variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY with permission to access the bucket specified

TODO: add other options for specifying S3 credentials

bucket

The bucket to upload JSON files to if they are larger than the threshold. Only used if location is set to s3.

Options For Modifying Entry Logs

Example default function entry log:
🟢 main( arg1: { ... }, arg2: 5 ) {"arg1":{"key1":1,"key2":2},"arg2":5}


- entryLogShowFullArgs (Default: true)

Logs all of the arguments & values to the function as JSON after the signature

When true:
🟢 main( arg1: { ... }, arg2: 5 ) {"arg1":{"key1":1,"key2":2},"arg2":5}

When false:
🟢 main( arg1: { ... }, arg2: 5 )

- entryLogMultilineJSONargs (Default: false)

Logs the arguments output as multiline JSON

When true:

🟢  main( arg1: { ... }, arg2: 5 ) {
  "arg1": {
    "key1":1,
    "key2":2
  },
  "arg2":5
}

When false:
🟢 main( arg1: { ... }, arg2: 5 ) {arg1:{"key1":1,"key2":2},"arg2":5}

- entryLogArgOutputInline (Default: true)

Displays the argument object on the same line as the signature

When true:
🟢 main( arg1: { ... }, arg2: 5 ) {"arg1":{"key1":1,"key2":2},"arg2":5}

When false:

🟢  main( arg1: { ... }, arg2: 5 )
{"arg1":{"key1":1,"key2":2},"arg2":5}

- entryLogSymbol (Default: 🟢 )

The symbol to use at the start of an entry log

Default:
🟢 main( arg1: { ... }, arg2: 5 ) {"arg1":{"key1":1,"key2":2},"arg2":5}

entryLogSymbol = $
$ main( arg1: { ... }, arg2: 5 ) {"arg1":{"key1":1,"key2":2},"arg2":5}

Options For Modifying Exit Logs

Example default function exit logs:

🔴  main() ⇒ {"a":1,"b":2}
🔴  main() ⇒ 10.5

- exitLogStubObjects (Default: false)

Stubs the return value output when it is an object (leaves the value the same when the return value is a different primitive)

When true:

🔴  main() ⇒ { ... }
🔴  main() ⇒ 10.5

When false:

🔴  main() ⇒ {"a":1,"b":2}
🔴  main() ⇒ 10.5

- exitLogReturnOutputInline (Default: true)

Outputs the return value in the same line as the function name

When true:

🔴  main() ⇒ {"a":1,"b":2}
🔴  main() ⇒ 10.5

When false:

🔴  main() ⇒ 
{"a":1,"b":2}
🔴  main() ⇒
10.5

- exitLogSymbol (Default: 🔴 )

The symbol to use at the start of an entry log

Default:
🔴 main() ⇒ {"a":1,"b":2}

exitLogSymbol = $
$ main() ⇒ {"a":1,"b":2}

- timeProfiling (Default: false)

Displays how long the function took to run

When true:
🔴 main() ⏱️ 1005.789 ms ⇒ {"a":1,"b":2}