Skip to content

Commit a73ccb5

Browse files
committed
Logging app version.
1 parent 77d56df commit a73ccb5

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/logger.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ import pretty from 'pino-pretty';
33
import { LOGS_FILEPATH } from './config/file';
44
import { Environment } from './types';
55
import { POLL } from './config/bot';
6+
import { version } from '../package.json';
7+
8+
const getBindings = (bindings: pino.Bindings) => {
9+
return {
10+
pid: bindings.pid,
11+
hostname: bindings.hostname,
12+
version,
13+
};
14+
}
615

716
const getLoggerByEnvironment = (env: Environment) => {
817
switch (env) {
@@ -12,6 +21,9 @@ const getLoggerByEnvironment = (env: Environment) => {
1221
case Environment.Production:
1322
return pino({
1423
level: 'debug',
24+
formatters: {
25+
bindings: getBindings,
26+
},
1527
transport: {
1628
target: 'pino-pretty',
1729
},
@@ -24,6 +36,9 @@ const getLoggerByUseCase = () => {
2436
if (POLL) {
2537
return pino({
2638
level: 'trace',
39+
formatters: {
40+
bindings: getBindings,
41+
},
2742
}, pino.transport({
2843
targets: [{
2944
level: 'info',
@@ -41,6 +56,9 @@ const getLoggerByUseCase = () => {
4156
// Otherwise, only terminal is sufficient
4257
return pino({
4358
level: 'debug',
59+
formatters: {
60+
bindings: getBindings,
61+
},
4462
transport: {
4563
target: 'pino-pretty',
4664
},

0 commit comments

Comments
 (0)