diff options
| author | LMBishop <13875753+LMBishop@users.noreply.github.com> | 2021-12-22 20:35:16 +0000 |
|---|---|---|
| committer | LMBishop <13875753+LMBishop@users.noreply.github.com> | 2021-12-22 20:35:16 +0000 |
| commit | 951984fb55d552d9c816a30069e2321f3602d305 (patch) | |
| tree | 3763441916dffff9ca96dd0286c72104ba2954c0 /app/logger.ts | |
| parent | 4ddf6fc9ed90a704869da683561e5032b6c48d79 (diff) | |
Add circular dependency detection and logging library
Diffstat (limited to 'app/logger.ts')
| -rw-r--r-- | app/logger.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/logger.ts b/app/logger.ts new file mode 100644 index 0000000..4ce0150 --- /dev/null +++ b/app/logger.ts @@ -0,0 +1,23 @@ +import winston from 'winston'; + +const enumerateErrorFormat = winston.format((info) => { + if (info instanceof Error) { + Object.assign(info, { message: info.stack }); + } + return info; + }); + +export const logger = winston.createLogger({ + level: process.env.LOGGING_LEVEL === 'development' ? 'debug' : 'info', + format: winston.format.combine( + enumerateErrorFormat(), + winston.format.colorize(), + winston.format.splat(), + winston.format.printf(({ level, message }) => `${level}: ${message}`) + ), + transports: [ + new winston.transports.Console({ + stderrLevels: ['error'], + }), + ], +}); |
