diff --git a/Dockerfile b/Dockerfile index 79fa7b9..d0183be 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ WORKDIR /app COPY package.json ./ RUN yarn config set cache-folder /app/.yarn_cache && \ - yarn install --ignore-optional + yarn install --immutable --immutable-cache --check-cache ENV PATH $PATH:/app/node_modules/.bin diff --git a/config.env b/config.env index 013ad2c..d874b1f 100644 --- a/config.env +++ b/config.env @@ -1 +1,2 @@ -LOG_LEVEL=info \ No newline at end of file +LOG_LEVEL=info +LOG_FILE_PATH=./logs.log \ No newline at end of file diff --git a/package.json b/package.json index bcfaffa..17b6774 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "@nestjs/testing": "^10.3.0" }, "scripts": { - "build": "tsc", + "build": "echo 'Building...'", "check": "tsc --noEmit src/*.ts", "test": "jest" }, @@ -22,7 +22,6 @@ "dotenv": "^16.3.1", "pino": "^8.17.1", "pino-pretty": "^10.3.0", - "reflect-metadata": "0.1.14", - "rxjs": "^7.8.1" + "reflect-metadata": "0.1.14" } } diff --git a/src/logger.ts b/src/logger.ts index 3399349..7728d16 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -1,5 +1,6 @@ import pino from 'pino'; import { Configuracion } from './configuracion'; +import * as fs from 'fs'; export class Logger { private logger: pino.Logger; @@ -10,16 +11,23 @@ export class Logger { */ constructor(configuracion: Configuracion) { const logLevel = configuracion.get('LOG_LEVEL'); + const logFilePath = configuracion.get('LOG_FILE_PATH'); - if (!logLevel) { - throw new Error('Nivel de registro no configurado correctamente.'); + if (!logLevel || !logFilePath) { + throw new Error('Nivel de registro o ruta del archivo de registro no configurados correctamente.'); } + const streams = [ + { level: logLevel, stream: process.stdout }, + { level: logLevel, stream: fs.createWriteStream(logFilePath, { flags: 'a' }) }, + ]; + this.logger = pino({ level: logLevel, - }); + }, pino.multistream(streams)); } + /** * Registrar un mensaje de debug. * @param message Mensaje a registrar. @@ -58,6 +66,6 @@ export class Logger { } export const LoggerConfig = { - logger: new Logger(new Configuracion()), - config: new Configuracion(), -}; + logger: new Logger(new Configuracion()), + config: new Configuracion(), +}; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 1e8411c..9361dac 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,9 +6,7 @@ "module": "commonjs", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, - "strict": true, - "skipLibCheck": true, - "noEmit": true + "strict": true }, "include": [ "src/**/*.ts"