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.1.0 to 0.2.0

1

dist/logger.service.d.ts

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

private static readonly logger;
private static customFormat;
error(message: any, trace?: any): void;

@@ -9,0 +8,0 @@ warn(message: any, context?: any): void;

@@ -12,3 +12,2 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

import { Injectable } from '@nestjs/common';
import chalk from 'chalk';
import * as winston from 'winston';

@@ -19,25 +18,2 @@ let LoggerService = LoggerService_1 = class LoggerService {

}
static customFormat(info) {
let level = info.level.toUpperCase();
let padding = 0;
switch (info.level) {
case 'debug':
level = chalk.blueBright(level);
break;
case 'info':
level = chalk.whiteBright(level);
padding = 1;
break;
case 'warn':
level = chalk.yellowBright(level);
padding = 1;
break;
case 'error':
level = chalk.redBright(level);
break;
}
const formattedLevel = `[${chalk.bold(level)}]${' '.repeat(padding)}`;
info.message = `${chalk.gray(info.timestamp)} ${formattedLevel} ${info.message}`;
return info;
}
error(message, trace) {

@@ -66,5 +42,5 @@ LoggerService_1.logger.error(`${message} ${trace ? trace : ''}`);

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

@@ -71,0 +47,0 @@ new winston.transports.Console({

{
"name": "@neoskop/nestjs-logger",
"version": "0.1.0",
"version": "0.2.0",
"type": "module",

@@ -26,3 +26,2 @@ "keywords": [

"@nestjs/core": "8.4.7",
"chalk": "5.0.1",
"reflect-metadata": "0.1.13"

@@ -36,3 +35,2 @@ },

"@types/node": "18.0.3",
"@types/triple-beam": "1.3.2",
"jest": "28.1.2",

@@ -48,7 +46,4 @@ "nodemon": "2.0.19",

"dependencies": {
"chalk": "5.0.1",
"logform": "2.4.2",
"triple-beam": "1.3.0",
"winston": "3.8.1"
}
}

6

src/logger.service.spec.ts

@@ -18,2 +18,8 @@ import { Test, TestingModule } from '@nestjs/testing';

});
it('should write to stdout', () => {
jest.spyOn((console as any)._stdout, 'write');
service.info('foo');
expect((console as any)._stdout).toHaveBeenCalledWith('foo');
});
});
import { Injectable } from '@nestjs/common';
import chalk from 'chalk';
import { TransformableInfo } from 'logform';
import * as winston from 'winston';

@@ -13,6 +11,10 @@ import { LoggerModuleOptions } from './logger-module-options.interface';

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

@@ -27,31 +29,2 @@ transports: [

private static customFormat(info: TransformableInfo) {
let level = info.level.toUpperCase();
let padding = 0;
switch (info.level) {
case 'debug':
level = chalk.blueBright(level);
break;
case 'info':
level = chalk.whiteBright(level);
padding = 1;
break;
case 'warn':
level = chalk.yellowBright(level);
padding = 1;
break;
case 'error':
level = chalk.redBright(level);
break;
}
const formattedLevel = `[${chalk.bold(level)}]${' '.repeat(padding)}`;
info.message = `${chalk.gray(info.timestamp)} ${formattedLevel} ${
info.message
}`;
return info;
}
public error(message: any, trace?: any) {

@@ -58,0 +31,0 @@ LoggerService.logger.error(`${message} ${trace ? trace : ''}`);

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