feat(cli): support configuration via PINO_PRETTY_* environment variables#651
Closed
mahmoodhamdi wants to merge 1 commit intopinojs:masterfrom
Closed
feat(cli): support configuration via PINO_PRETTY_* environment variables#651mahmoodhamdi wants to merge 1 commit intopinojs:masterfrom
mahmoodhamdi wants to merge 1 commit intopinojs:masterfrom
Conversation
All CLI options are now configurable through environment variables using the PINO_PRETTY_ prefix and SCREAMING_SNAKE_CASE naming. Priority is maintained as: CLI flags > config file > env vars. Example mappings: --levelFirst → PINO_PRETTY_LEVEL_FIRST=true --singleLine → PINO_PRETTY_SINGLE_LINE=true --ignore → PINO_PRETTY_IGNORE=pid,hostname --translateTime → PINO_PRETTY_TRANSLATE_TIME=SYS:yyyy-mm-dd HH:MM:ss Boolean options accept true/1 and false/0 (case-insensitive). Invalid boolean values are silently ignored. String options are passed through as-is. Closes pinojs#554
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #554.
Adds environment variable support to the pino-pretty CLI. All options are configurable with a
PINO_PRETTY_prefix and SCREAMING_SNAKE_CASE naming.Priority: CLI flags > config file > env vars (env vars are lowest priority, acting as a global fallback).
Env var → CLI flag mapping
PINO_PRETTY_COLORIZE--colorizePINO_PRETTY_CRLF--crlfPINO_PRETTY_ERROR_PROPS--errorPropsPINO_PRETTY_LEVEL_FIRST--levelFirstPINO_PRETTY_MINIMUM_LEVEL--minimumLevelPINO_PRETTY_CUSTOM_LEVELS--customLevelsPINO_PRETTY_CUSTOM_COLORS--customColorsPINO_PRETTY_USE_ONLY_CUSTOM_PROPS--useOnlyCustomPropsPINO_PRETTY_ERROR_LIKE_OBJECT_KEYS--errorLikeObjectKeysPINO_PRETTY_MESSAGE_KEY--messageKeyPINO_PRETTY_LEVEL_KEY--levelKeyPINO_PRETTY_LEVEL_LABEL--levelLabelPINO_PRETTY_MESSAGE_FORMAT--messageFormatPINO_PRETTY_TIMESTAMP_KEY--timestampKeyPINO_PRETTY_TRANSLATE_TIME--translateTimePINO_PRETTY_IGNORE--ignorePINO_PRETTY_INCLUDE--includePINO_PRETTY_HIDE_OBJECT--hideObjectPINO_PRETTY_SINGLE_LINE--singleLineBoolean options accept
true/1andfalse/0(case-insensitive). Invalid values are silently ignored.Usage example
Test plan
test/cli-env.test.jscovering boolean options (true/1), string options, CLI-over-env priority, and invalid boolean value handlingnpm test)