Skip to content

Commit

Permalink
feat: introduce pino as a logger for the CLI
Browse files Browse the repository at this point in the history
In its current configuration, the logger outputs lines of structured JSON to
a file called `checkly.debug.log` in the current directory. This will change
later.

By default, logs are silenced. Only when you set CHECKLY_LOG_LEVEL, does the
log file actually receive any content.
  • Loading branch information
sorccu committed Nov 11, 2024
1 parent bb421ba commit 1da6dc7
Show file tree
Hide file tree
Showing 3 changed files with 224 additions and 0 deletions.
199 changes: 199 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"mqtt": "5.10.1",
"open": "8.4.0",
"p-queue": "6.6.2",
"pino": "9.5.0",
"prompts": "2.4.2",
"proxy-from-env": "1.1.0",
"recast": "0.23.4",
Expand Down
24 changes: 24 additions & 0 deletions packages/cli/src/services/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pino from 'pino'

export const rootLogger = pino(
{
level: process.env.CHECKLY_LOG_LEVEL || 'silent',
formatters: {
bindings: (bindings) => {
return { pid: bindings.pid }
},
level: (label) => {
return { level: label.toUpperCase() }
},
},
timestamp: pino.stdTimeFunctions.isoTime,
redact: {
paths: [
'password',
],
},
},
pino.destination('checkly.debug.log'),
)

export type Logger = pino.Logger

0 comments on commit 1da6dc7

Please sign in to comment.