defaultMeta ignored when using logger.log function but not in logger[level] functions
See original GitHub issuePlease tell us about your environment:
winston
version?-
winston@2
-
winston@3
3.2.1
-
node -v
outputs: v13.5.0- Operating System? (Windows, macOS, or Linux) macOS
- Language? (all | TypeScript X.X | ES6/7 | ES5 | Dart) ES6/7
What is the problem?
When calling the function logger.log('debug', 'message')
it seems to completely ignore defaultMeta
, but calling functions like logger.debug
does not
My createLogger
const logger = winston.createLogger({
level: "debug",
defaultMeta: { id: 'APP' },
format: winston.format.combine(
winston.format.colorize(),
winston.format.timestamp({
format: "YYYY-MM-DD h:mm:ss:SSS"
}),
winston.format.printf(
info => `${info.timestamp} ${info.level}: [${info.id}] ${info.message}`
)
),
transports: [new winston.transports.Console()]
});
What do you expect to happen instead?
Given my createLogger setup above I expect both
logger.info("This is my info")
AND
logger.log("info", "This is my info")
to both print out this to the console:
2020-02-04 11:30:34:313 info: [APP] This is my info
However the latter (logger.log
) prints this
2020-02-04 11:30:34:307 info: [undefined] Initializing web sockets
Other information
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Node.js: Winston: Can I add default meta data to all log ...
js for logging. I know I can add metadata individually to each log message but is there a way to specify a default...
Read more >Log4j2 Example Tutorial - Configuration, Levels, Appenders
Notice that the propagation of log events up in the logger hierarchy is beyond this computation and it ignores the levels. But what...
Read more >A Complete Guide to Winston Logging in Node.js - Better Stack
In this tutorial, we will explain how to install, set up, and use the Winston logger in a Node.js application. We'll go through...
Read more >logging — Logging facility for Python — Python 3.11.1 ...
The basic classes defined by the module, together with their functions, are listed below. Loggers expose the interface that application code directly uses....
Read more >How to use the winston.transports.Console function in ... - Snyk
Use Snyk Code to scan source code in minutes - no build needed - and fix ... Instantiate a new Winston Logger with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Still the same on 3.3.3
Same happening with profiling, the
logger.profile()
method ignoresdefaultMeta
.So is this actually an issue or the expected behavior?