From 93635eca9cd63c03d3b0dd2c340f94e828c867b0 Mon Sep 17 00:00:00 2001 From: Alexey Yarmosh Date: Wed, 27 Mar 2024 12:52:04 +0100 Subject: [PATCH] feat: use src logger --- test/e2e/docker.ts | 2 +- test/e2e/logger.ts | 35 ----------------------------------- test/e2e/utils.ts | 2 +- 3 files changed, 2 insertions(+), 37 deletions(-) delete mode 100644 test/e2e/logger.ts diff --git a/test/e2e/docker.ts b/test/e2e/docker.ts index dbdc32e2..2b92b264 100644 --- a/test/e2e/docker.ts +++ b/test/e2e/docker.ts @@ -1,7 +1,7 @@ import Docker from 'dockerode'; import config from 'config'; -import { scopedLogger } from './logger.js'; +import { scopedLogger } from '../../src/lib/logger.js'; const logger = scopedLogger('docker-manager'); diff --git a/test/e2e/logger.ts b/test/e2e/logger.ts deleted file mode 100644 index 444267cb..00000000 --- a/test/e2e/logger.ts +++ /dev/null @@ -1,35 +0,0 @@ -import process from 'node:process'; -import { inspect } from 'node:util'; -import * as winston from 'winston'; - -const objectFormatter = (object: Record) => { - const objectWithoutSymbols = Object.fromEntries(Object.entries(object)); - return inspect(objectWithoutSymbols); -}; - -const logger = winston.createLogger({ - level: process.env['LOG_LEVEL'] ?? 'debug', - format: winston.format.combine( - winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), - winston.format.prettyPrint(), - winston.format.printf((info: winston.Logform.TransformableInfo) => { - const { timestamp, level, scope, message, stack, label, ...otherFields } = info; // eslint-disable-line @typescript-eslint/no-unsafe-assignment - let result = `[${timestamp as string}] [${level.toUpperCase()}] [${process.pid}] [${scope as string}] ${label ? `[${label}] ` : ''}${message as string}`; - - if (Object.keys(otherFields).length > 0) { - result += `\n${objectFormatter(otherFields)}`; - } - - if (stack) { - result += `\n${info['stack'] as string}`; - } - - return result; - }), - ), - transports: [ - new winston.transports.Console(), - ], -}); - -export const scopedLogger = (scope: string, label?: string): winston.Logger => logger.child({ scope, label }); diff --git a/test/e2e/utils.ts b/test/e2e/utils.ts index 5776b6f3..d1ee4f25 100644 --- a/test/e2e/utils.ts +++ b/test/e2e/utils.ts @@ -1,6 +1,6 @@ import got, { type RequestError } from 'got'; import { setTimeout } from 'timers/promises'; -import { scopedLogger } from './logger.js'; +import { scopedLogger } from '../../src/lib/logger.js'; const logger = scopedLogger('e2e-utils');