Winston 3 breaking on syslog levels.
See original GitHub issueSomewhat a follow-on to #87, which was closed.
Setting the syslog log levels with the param on createLogger, as is appropriate for Winston 3 doesn’t seem to be working quite as expected. I made a little test program:
const { createLogger, format, transports, config, } = require('winston');
require('winston-syslog').Syslog;
const logger = createLogger({
levels: config.syslog,
format: format.simple(),
transports: [
new transports.Console(),
new transports.Syslog({
type: '5424',
protocol: 'unix',
path: '/var/run/syslog',
})
]
});
logger.notice(`Current Testing Time is: ${new Date()}`)
logger.error("Here is a test error message")
When I run that with Node 8, Winston 3.0.0-rc1, I get this error:
TypeError: logger.notice is not a function
Which implies that it’s not getting the right levels, which seems odd, since winston.config.syslog
logs out as:
{ levels:
{ emerg: 0,
alert: 1,
crit: 2,
error: 3,
warning: 4,
notice: 5,
info: 6,
debug: 7 },
colors:
{ emerg: 'red',
alert: 'yellow',
crit: 'red',
error: 'red',
warning: 'red',
notice: 'yellow',
info: 'green',
debug: 'blue' } }
Now, if I swap the Logger constructor to:
levels: config.syslog.levels,
We get further, but now I get this error:
notice: Current Testing Time is: Tue Nov 07 2017 08:59:07 GMT-0600 (CST) {}
/Users/perry.shuman/Code/temp/log_test/node_modules/winston-syslog/lib/winston-syslog.js:126
return callback(new Error('Cannot log unknown syslog level: ' + level));
^
TypeError: callback is not a function
at exports.Syslog.Syslog.log (/Users/perry.shuman/Code/temp/log_test/node_modules/winston-syslog/lib/winston-syslog.js:126:12)
at exports.Syslog.TransportStream._write (/Users/perry.shuman/Code/temp/log_test/node_modules/winston-transport/index.js:88:17)
at doWrite (_stream_writable.js:387:12)
at writeOrBuffer (_stream_writable.js:373:5)
at exports.Syslog.Writable.write (_stream_writable.js:290:11)
at DerivedLogger.ondata (_stream_readable.js:639:20)
at emitOne (events.js:121:20)
at DerivedLogger.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
Which looks like winston-syslog isn’t reading the level that’s passed in as a valid level, since you shouldn’t be able to get to line 126 without failing this conditional:
if (!~levels.indexOf(level)) {
return callback(new Error('Cannot log unknown syslog level: ' + level));
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:9 (2 by maintainers)
Top Results From Across the Web
contrast/winston-syslog - npm package
tldr;? : To break the winston codebase into small modules that work together. The winston codebase has been growing significantly with ...
Read more >UPGRADE-3.0.md - winstonjs/winston - Sourcegraph
This document represents a living guide on upgrading to winston@3 . Much attention has gone into the ... Breaking changes. Top-level winston.* API....
Read more >Complete Winston Logger Guide With Hands-on Examples
1. Centralized control over how and when to log · 2. Control where your logs are sent · 3. Custom logging formats ·...
Read more >express-winston
winstonInstance : <WinstonLogger>, // a winston logger instance. If this is provided the transports and formats options are ignored. level: ...
Read more >Winston Logger Ultimate Tutorial: Best Practices ...
Streams: Winston uses Node. · Transports: Logs need to go somewhere. · Formatting: Your regular console. · Levels: Winston adds another interesting ...
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
Had the same issue as above
I was able to reproduce this problem without
winston-syslog
, so this appears to be awinston
issue. I’ve opened this issue there: https://github.com/winstonjs/winston/issues/1711