Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using pino instead of winston for logging #709

Closed
0x2b3bfa0 opened this issue Sep 9, 2021 · 5 comments
Closed

Consider using pino instead of winston for logging #709

0x2b3bfa0 opened this issue Sep 9, 2021 · 5 comments
Labels
discussion Waiting for team decision enhancement New feature or request technical-debt Refactoring, linting & tidying ui/ux User interface/experience

Comments

@0x2b3bfa0
Copy link
Member

0x2b3bfa0 commented Sep 9, 2021

It could be a better option, not only because of asthetics, but also because of functionality and apparent project health. Configured logger objects can be passed as suggested on pinojs/pino#1108 (comment).

See also

@0x2b3bfa0
Copy link
Member Author

0x2b3bfa0 commented Sep 10, 2021

Try–it–yourself comparison

const pino = require('pino');
const winston = require('winston');

const pinoLogger = pino(
  {
    prettyPrint: {
      ignore: 'pid,hostname',
      translateTime: true,
      colorize: true
    },
    level: 'debug'
  },
  process.stderr
);

const winstonLogger = winston.createLogger({
  level: 'debug',
  format: winston.format.combine(
    winston.format.colorize(),
    winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss.SSS ZZ' }),
    winston.format.simple()
  ),
  transports: [
    new winston.transports.Console({
      stderrLevels: Object.keys(winston.config.npm.levels)
    })
  ]
});

for (logger of [pinoLogger, winstonLogger]) {
  logger.error(new Error('runners are exhausted because of cloud altitude'));
  logger.warn('the personal access token has been written backwards');
  logger.info('no bot dared to comment on your last commit');
  logger.debug('this repository contains files');
}

Pino

Captura de pantalla 2021-09-10 a las 3 45 41 copia

Winston

Sin título-1 copia

@0x2b3bfa0 0x2b3bfa0 added enhancement New feature or request ui/ux User interface/experience discussion Waiting for team decision labels Sep 10, 2021
@DavidGOrtega
Copy link
Contributor

I do not understand what do you want to showcase with this example. Whats the main difference?

@0x2b3bfa0
Copy link
Member Author

  1. Full and readable stack traces for errors
  2. Object formatting

@dacbd
Copy link
Contributor

dacbd commented Oct 31, 2022

p3-cool-if-someone-is-really-bored-on-a-weekend or p4-graveyard?

@0x2b3bfa0
Copy link
Member Author

p5-low-priority-enough-to-postpone-choosing-a-priority

@0x2b3bfa0 0x2b3bfa0 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 31, 2022
@casperdcl casperdcl added the technical-debt Refactoring, linting & tidying label Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Waiting for team decision enhancement New feature or request technical-debt Refactoring, linting & tidying ui/ux User interface/experience
Projects
None yet
Development

No branches or pull requests

4 participants