question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

logger prints/output only first argument in v 3.2.0

See original GitHub issue

Environment

  • winston version?
    • winston@3.2.0
  • node -v outputs:
    • v10.13.0
  • Operating System? (macOS)

Problem

logger.info('First', 'Second') is printing only First in the console and in File. With 3.0, this is printing both arguments, First & Second. (Second in the new line)

What do you expect to happen instead?

Expecting output as First Second

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:8
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
robertsLandocommented, Apr 10, 2019

I think this is such a breaking change…

The partial solution is:

const wrapper = ( original ) => {
    return (...args) => {
      for (let index = 0; index < args.length; index++) {
        if(args[index] instanceof Error){
          args[index] = args[index].stack
        }
      }
      original(args.join(" "))
    }
};

logger.error = wrapper(logger.error);
logger.warn = wrapper(logger.warn);
logger.info = wrapper(logger.info);
logger.verbose = wrapper(logger.verbose);
logger.debug = wrapper(logger.debug);
logger.silly = wrapper(logger.silly);
1reaction
oakfirecommented, May 16, 2019

You could log like logger.info(['First', 'Second']) if you need that kind of call. Generally winston isn’t really designed for that call style; for the leveled log methods, the first param is a string message, and all other params are treated as splats/metas.

That being said, I think winstonjs/logform#85 with the metadataArray might help achieve what you want. I can leave this issue open till that gets merged.

But util.format('First', 'Second') will output First Second, the same as console.log and winston@2. Why winston@3 with format splat break this behavior?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Log Full Stack Trace with Winston 3?
For winston version 3.2.0+ , following will add stacktrace to log output: import { createLogger, format, transports } from 'winston'; ...
Read more >
Logging - Zephyr Project Documentation
The logging API provides a common interface to process messages issued by developers. Messages are passed through a frontend and are then ...
Read more >
Documentation / Core MI Functions - 3.2 - openSIPS
Prints the version string of a runningOpenSIPS. Arguments: none. Output: one item (named "Server") containing the version string. Examples of usage: # opensips- ......
Read more >
Troubleshoot Azure Monitor Application Insights for Java
This log file is the first place to check for hints about any issues you might ... check to make sure that your...
Read more >
cypress-terminal-report - npm
Better terminal and file output for cypress test logs. ... this amount of logs will be printed only around failing commands.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found