Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ if (cmd.h || cmd.help) {

let opts = minimist(process.argv, {
alias: {
// defaults to true (sonic-boom options default)
append: 'append',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. They are not needed. However, I would prefer those for code quality reasons. I understand the call to minimist as a registration of possible program params. It's weird to me to have some params not being mentioned at all. The list would look incomplete to me here.
Your call, tho.

colorize: 'c',
crlf: 'f',
destination: 'd',
errorProps: 'e',
levelFirst: 'l',
minimumLevel: 'L',
Expand All @@ -52,6 +55,7 @@ if (cmd.h || cmd.help) {
useOnlyCustomProps: 'U',
errorLikeObjectKeys: 'k',
messageKey: 'm',
mkdir: 'r',
levelKey: CONSTANTS.LEVEL_KEY,
levelLabel: 'b',
messageFormat: 'o',
Expand All @@ -60,7 +64,8 @@ if (cmd.h || cmd.help) {
ignore: 'i',
include: 'I',
hideObject: 'H',
singleLine: 'S'
singleLine: 'S',
sync: 'sync'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed

},
default: {
messageKey: DEFAULT_VALUE,
Expand Down
12 changes: 11 additions & 1 deletion help/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
version Display version

Options:
--append For file destination, append instead of overwrite (defaults to append; use `--no-append` to overwrite instead)
-c, --colorize Force adding color sequences to the output
-C, --config specify a path to a json file containing the pino-pretty options
-C, --config Specify a path to a json file containing the pino-pretty options
-f, --crlf Append CRLF instead of LF to formatted lines
-X, --customColors Override default colors using names from https://www.npmjs.com/package/colorette (`-X err:red,info:blue`)
-x, --customLevels Override default levels (`-x err:99,info:1`)
-d, --destination [path] Write to a file instead of stdout
-k, --errorLikeObjectKeys Define which keys contain error objects (`-k err,error`) (defaults to `err,error`)
-e, --errorProps Comma separated list of properties on error objects to show (`*` for all properties) (defaults to ``)
-h, --help Output usage information
Expand All @@ -22,7 +24,9 @@
-o, --messageFormat Format output of message
-m, --messageKey [value] Highlight the message under the specified key (defaults to "msg")
-L, --minimumLevel Hide messages below the specified log level
-r, --mkdir For file destination, create file directory (recursively) if it does not exist
-S, --singleLine Print all non-error objects on a single line
--sync Write messages synchronously
-a, --timestampKey [value] Display the timestamp from the specified key (defaults to "time")
-t, --translateTime Display epoch timestamps as UTC ISO format or according to an optional format string (default ISO 8601)
-U, --useOnlyCustomProps Only use custom levels and colors (if provided); don't fallback to default levels and colors (-U false)
Expand All @@ -32,6 +36,12 @@
- To prettify logs, simply pipe a log file through
$ cat log | pino-pretty

- To ensure correct line order for mixed logs of pino objects and arbitrary log lines
$ cat log | pino-pretty --sync

- To write to a file
$ cat log | pino-pretty -d some/file/path/my.log --mkdir --no-append

- To highlight a string at a key other than 'msg'
$ cat log | pino-pretty -m fooMessage

Expand Down
24 changes: 14 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ const pretty = require('./lib/pretty')
* and colors will be used if they have been provided.
*/

/**
* @typedef {object} BuildStreamOpts
* @property {object|number|string} [destination] A destination stream, file
* descriptor, or target path to a file.
* @property {boolean} [append]
* @property {boolean} [mkdir]
* @property {boolean} [sync=false]
*/

/**
* @typedef {PinoPrettyOptions & BuildStreamOpts} CombinedOptions
*/

/**
* The default options that will be used when prettifying log lines.
*
Expand Down Expand Up @@ -159,20 +172,11 @@ function prettyFactory (options) {
return pretty.bind({ ...context, context })
}

/**
* @typedef {PinoPrettyOptions} BuildStreamOpts
* @property {object|number|string} [destination] A destination stream, file
* descriptor, or target path to a file.
* @property {boolean} [append]
* @property {boolean} [mkdir]
* @property {boolean} [sync=false]
*/

/**
* Constructs a {@link LogPrettifierFunc} and a stream to which the produced
* prettified log data will be written.
*
* @param {BuildStreamOpts} opts
* @param {CombinedOptions} opts
* @returns {Transform | (Transform & OnUnknown)}
*/
function build (opts = {}) {
Expand Down
Loading