Skip to content

Commit

Permalink
feat: add support for json log formats
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelsaabna committed Dec 11, 2024
1 parent 208d018 commit 4b17491
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/cli/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@ const level =
.filter(isNonEmptyStringAndNotWhitespace)
.shift() ?? 'info';

const format =
[env.CONTAINERBASE_LOG_FORMAT, env.LOG_FORMAT]
.filter(isNonEmptyStringAndNotWhitespace)
.shift()
?.toLowerCase() ?? 'pretty';

const stdoutTransportTarget = format === 'json' ? 'pino/file' : 'pino-pretty';

let fileLevel = 'silent';

const targets: TransportTargetOptions[] = [
{ target: 'pino-pretty', level, options: {} },
{ target: stdoutTransportTarget, level, options: {} },
];

if (isNonEmptyStringAndNotWhitespace(env.CONTAINERBASE_LOG_FILE)) {
Expand Down

0 comments on commit 4b17491

Please sign in to comment.