Skip to content

Commit

Permalink
Merge pull request #40 from LN-Zap/tests
Browse files Browse the repository at this point in the history
Modularise code
  • Loading branch information
mrfelton authored Feb 14, 2024
2 parents 2bb27c1 + c829cae commit fbae945
Show file tree
Hide file tree
Showing 3 changed files with 420 additions and 435 deletions.
27 changes: 27 additions & 0 deletions src/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pino, { type Logger } from 'pino'

export function logger (loglevel: string) : Logger {
let log : Logger;
const pinoOptions = {
level: loglevel,
messageKey: 'message',
formatters: {
level: (label: string) => {
return { level: label };
}
},
redact: ['bitcoind.password'],
}
if (process.env.NODE_ENV === 'production') {
log = pino(pinoOptions);
}
else {
try {
const pretty = require('pino-pretty');
log = pino(pinoOptions, pretty());
} catch (error) {
log = pino(pinoOptions);
}
}
return log;
}
Loading

0 comments on commit fbae945

Please sign in to comment.