Comments (2)
Yes. Pass the levels in when you create your logger. See: Using custom logging levels in the winston@3
docs.
const syslogLevelLogger = winston.createLogger({
levels: winston.config.syslog
});
from winston-syslog.
@indexzero That 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));
}
from winston-syslog.
Related Issues (20)
- Winston-syslog doesn't handle connection loss? HOT 5
- Support critical as loglevel
- mTLS connection is not working
- Syslog logs not flushed until app exits, and multiples are concatenated? HOT 6
- Logging via UNIX domains sockets is not quite conformant
- App doesn't stop when I use this library HOT 4
- Timestamp is incorrect when milliseconds < 100
- Usage: please correct "type" options HOT 1
- InFlight counter going negative
- Error healthCheck(dgram)
- Occasional ECONNRESET and EPIPE errors HOT 1
- No logs when running in docker container HOT 1
- Unable to change Destination via Syslog Configuration HOT 1
- cloudflare workers support HOT 7
- winston-syslog hardcodes log level to 'info' HOT 1
- Unable to change appName without reinstantiation HOT 1
- Error Handling on Creating TCP Socket HOT 1
- Winston containers problem with winston-syslog and solution HOT 2
- Implementing in nuxt 3
- Dependency glossy is unmaintained HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from winston-syslog.