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.

Ability to pass in multiple arguments to logging calls?

See original GitHub issue

@pigmej ran into an issue today in the IRC

 var winston = require('winston');
 winston.log('info', 'Hello distributed log files!', {"foo":"bar"}, ['123', '456']);


  node.js:134
          throw e; // process.nextTick error, or 'error' event on first tick
          ^
  TypeError: object is not a function
      at Array.CALL_NON_FUNCTION (native)
      at /usr/local/lib/node/.npm/winston/0.2.7/package/lib/winston/logger.js:107:42
      at [object Object].log (/usr/local/lib/node/.npm/winston/0.2.7/package/lib/winston/transports/console.js:46:3)
      at [object Object].log (/usr/local/lib/node/.npm/winston/0.2.7/package/lib/winston/logger.js:102:17)
      at Object.log (/usr/local/lib/node/.npm/winston/0.2.7/package/lib/winston.js:53:34)
      at Object.<anonymous> (/Users/maraksquires/dev/winston/test.js:3:9)
      at Module._compile (module.js:404:26)
      at Object..js (module.js:410:10)
      at Module.load (module.js:336:31)
      at Function._load (module.js:297:12)

I’m assuming this is a simple fix. What do you think indexzero?

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Reactions:4
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

14reactions
schontzcommented, Oct 3, 2018

I would suggest using ES2015 template literals. For example:

logger.info(`The value is ${value}`);

Notice I used back ticks ` instead of quotes ' to wrap my string.

8reactions
Marakcommented, May 23, 2011

@indexzero - The issue is that there is a disconnect between winston’s logging method and the standard console.log which many developers are use to using.

It’s pretty standard in JS land to do something like:

 console.log("this is foo", foo, " and this is bar", bar); 

I think it’s pretty reasonable to emulate this API. There is already code out there for doing the arguments parsing. I would think all we have to do is determine if the last method is a FN or not, if it is, then thats the callback.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing multiple arguments to console.log - Stack Overflow
If you want to be able to pass an arbitrary number of arguments into console.log , I would suggest using the arguments variable....
Read more >
logging — Logging facility for Python — Python 3.11.1 ...
Multiple calls to getLogger() with the same name will always return a reference to the ... The fourth keyword argument is extra which...
Read more >
Python Logging Basics - The Ultimate Guide To Logging
Python Logging Basics. This article covers the basics of using the standard logging module that ships with all Python distributions.
Read more >
Python Logging: A Stroll Through the Source Code
The Logger takes the LogRecord and passes it off to the Handler , but only if the effective level of the LogRecord is...
Read more >
Java static code analysis - SonarSource Rules
Similarly, passing concatenated strings into a logging method can also incur a needless performance hit because the concatenation will be performed every time ......
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