`log.log("warning", "message")` works, but `log.warning("message") doesn't
See original GitHub issuePlease tell us about your environment:
winston
version?-
winston@2
-
winston@3
-
- _
node -v
outputs: v10.16.0 - _Operating System? macOS & Linux
- _Language? TypeScript 3.3, JavaScript
What is the problem?
A call to log.log("warning", "message")
works, but a call to log.warning("message")
doesn’t. This is with a Console logger and syslog levels.
Online example of problem: https://repl.it/repls/LongtermCloudyCircles
const winston = require("winston");
winston.loggers.add("default");
const log = winston.loggers.get("default");
log.levels = winston.config.syslog.levels;
log.add(new winston.transports.Console());
log.log("warning", "named warning message");
log.warning("warning message");
Running that code will produce the following:
{"level":"warning","message":"named warning message"}
./scratch.js:8
log.warning("warning message");
^
TypeError: log.warning is not a function
at Object.<anonymous> (/Users/cjbarth/meps/wol-castle/scratch.js:8:5)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
What do you expect to happen instead?
{“level”:“warning”,“message”:“named warning message”} {“level”:“warning”,“message”:“warning message”}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Log.LogMessage does not display in Visual Studio console
I have a Build Task, I'm trying to write message to the Visual Studio output console using Log.LogMessage but to no avail.
Read more >log info doesn't show up on console but warn and error do
It prints warning and critical messages properly, but it does not print info and debug . getEffectiveLevel() shows the correct level. import ...
Read more >7.5 - Types of Log Messages | STAT 480
In this section, we investigate three different kinds of messages —errors, warnings, and notes — that SAS displays in the log window.
Read more >Logging HOWTO — Python 3.11.1 documentation
Logging is a means of tracking events that happen when some software runs. ... The INFO message doesn't appear because the default level...
Read more >psychopy.logging - control what gets logged
Provides functions for logging error and other messages to one or more files ... Some warning messages and error messages are generated by...
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
For those looking for a quick fix, try doing a project-wide find (in your own project) for
log.warning(
and replace it withlog.warn(
. I agree it would be a good idea to handle .warning more elegantly though.Somewhat new to winston internals, but I believe this is due to how the example is setting levels. If not set during logger configuration, winston will not setup the logger prototype with the per-level convenience functions (
log.warning
)However, if passed as configuration,
log.warning
is available:Thoughts? I’m thinking this is a non-issue, and setting levels via
log.levels =
is not intended to be supported.