Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@neoskop/nestjs-logger

Package Overview
Dependencies
Maintainers
4
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neoskop/nestjs-logger - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

1

dist/logger.service.d.ts

@@ -5,2 +5,3 @@ import { LoggerModuleOptions } from './logger-module-options.interface';

constructor(options: LoggerModuleOptions);
private static readonly format;
private static readonly logger;

@@ -7,0 +8,0 @@ error(message: any, trace?: any): void;

12

dist/logger.service.js

@@ -39,6 +39,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

};
LoggerService.format = winston.format.combine(winston.format.colorize({ level: true }), winston.format.timestamp({
format: 'HH:mm:ss',
}), winston.format.printf((info) => {
return `${info.timestamp} ${info.level.padStart(25, ' ')} ${info.message}`;
}));
LoggerService.logger = winston.createLogger({
format: winston.format.combine(winston.format.colorize({ all: true }), winston.format.timestamp({
format: 'YYYY-MM-DD HH:mm:ss',
}), winston.format.printf((info) => `[${info.timestamp}] ${info.level.toUpperCase()}: ${info.message}`)),
transports: [

@@ -48,2 +50,6 @@ new winston.transports.Console({

consoleWarnLevels: ['warn', 'error'],
format: winston.format.combine(winston.format((info) => {
info.level = info.level.toUpperCase();
return info;
})(), winston.format.colorize(), LoggerService_1.format),
}),

@@ -50,0 +56,0 @@ ],

@@ -5,3 +5,3 @@ {

"ignore": ["src/**/*.spec.ts"],
"exec": "yarn build"
"exec": "npm run build"
}
{
"name": "@neoskop/nestjs-logger",
"version": "0.2.0",
"version": "0.2.1",
"type": "module",

@@ -21,3 +21,4 @@ "keywords": [

"watch": "nodemon",
"build": "tsc -p tsconfig.json"
"build": "tsc -p tsconfig.json",
"test": "jest"
},

@@ -39,2 +40,3 @@ "peerDependencies": {

"rxjs": "7.5.5",
"ts-jest": "28.0.5",
"typescript": "4.7.4"

@@ -47,3 +49,17 @@ },

"winston": "3.8.1"
},
"jest": {
"extensionsToTreatAsEsm": [
".ts"
],
"globals": {
"ts-jest": {
"useESM": true
}
},
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.js$": "$1"
},
"preset": "ts-jest"
}
}

@@ -1,2 +0,1 @@

import { Test, TestingModule } from '@nestjs/testing';
import { LoggerService } from './logger.service';

@@ -7,8 +6,9 @@

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [LoggerService],
}).compile();
beforeEach(() => {
service = new LoggerService({ logLevel: 'debug' });
jest.spyOn((console as any)._stdout, 'write');
});
service = module.get<LoggerService>(LoggerService);
afterEach(() => {
jest.clearAllMocks();
});

@@ -21,6 +21,14 @@

it('should write to stdout', () => {
jest.spyOn((console as any)._stdout, 'write');
service.info('foo');
expect((console as any)._stdout).toHaveBeenCalledWith('foo');
expect((console as any)._stdout.write).toHaveBeenCalledWith(
expect.stringMatching(/foo/),
);
});
it('should write loglevel to stdout', () => {
service.debug('foo');
expect((console as any)._stdout.write).toHaveBeenCalledWith(
expect.stringMatching(/debug/i),
);
});
});

@@ -9,13 +9,15 @@ import { Injectable } from '@nestjs/common';

private static readonly format = winston.format.combine(
winston.format.colorize({ level: true }),
winston.format.timestamp({
format: 'HH:mm:ss',
}),
winston.format.printf((info) => {
return `${info.timestamp} ${info.level.padStart(25, ' ')} ${
info.message
}`;
}),
);
private static readonly logger: winston.Logger = winston.createLogger({
format: winston.format.combine(
winston.format.colorize({ all: true }),
winston.format.timestamp({
format: 'YYYY-MM-DD HH:mm:ss',
}),
winston.format.printf(
(info) =>
`[${info.timestamp}] ${info.level.toUpperCase()}: ${info.message}`,
),
),
transports: [

@@ -25,2 +27,10 @@ new winston.transports.Console({

consoleWarnLevels: ['warn', 'error'],
format: winston.format.combine(
winston.format((info) => {
info.level = info.level.toUpperCase();
return info;
})(),
winston.format.colorize(),
LoggerService.format,
),
}),

@@ -27,0 +37,0 @@ ],

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc