0.0.5 ā€¢ Published 11 months ago

babel-plugin-shotgun-logs v0.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

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}

0.0.5

11 months ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

2 years ago

0.0.1

2 years ago

1.0.0

2 years ago