Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept alternative syslog level names #33

Open
dbmikus opened this issue Feb 9, 2015 · 3 comments
Open

Accept alternative syslog level names #33

dbmikus opened this issue Feb 9, 2015 · 3 comments

Comments

@dbmikus
Copy link
Contributor

dbmikus commented Feb 9, 2015

Syslog has the following log level names:

  • "emerg" (also "panic")
  • "alert"
  • "crit"
  • "err" (also "error")
  • "warning" (also "warn")
  • "notice"
  • "info"
  • "debug"

Currently, this transport will not recognize using the names "warn", "err", and "panic". I know it is trying to just have parity with the log levels defined in the winston.config.syslog.levels object, but I already think that is kind of messed up because that object picks and chooses which log level names to use. For example, it uses "error" instead of "err" but uses the default level names for the rest of the levels.

I think it would be nice for the syslog transport module to allow all of the names above. Of course, the decision is up to the repository maintainers. It doesn't look like we actually use the numerical values corresponding to log level keywords, so the extra keywords could probably just be added in.

Like:

var levels = Object.keys({
  debug: 0,
  info: 1,
  notice: 2,
  warning: 3,
  warn: 3,
  err: 4,
  error: 4,
  crit: 5,
  alert: 6,
  emerg: 7,
  panic: 7
});
@dbmikus
Copy link
Contributor Author

dbmikus commented Feb 9, 2015

Or stuff could be changed to rely on the log level numerical value. This conflicts with an issue with winston.config.syslog.levels where the levels are reversed in Winston, which is actually the opposite of the levels in syslog. That is, "emerg" is considered 0 by syslog but should be 7 in winston.config.syslog.levels, however winston.config.syslog.levels currently has it as 0. See: winstonjs/winston#307

I'm not sure if using the number would mess with the message sent to syslog over the socket, though.

@ktarplee
Copy link

ktarplee commented Apr 3, 2015

To have correct log level control from winston I had to reverse the numbers so that debug is 0 such as

//winston.setLevels(winston.config.syslog.levels); //this has the wrong sense
winston.setLevels({
emerg: 7,
alert: 6,
crit: 5,
error: 4,
warning: 3,
notice: 2,
info: 1,
debug: 0
});

@markstos
Copy link

winston-rsyslog2 has support for mapping winston level names to syslog levels. You are welcome to port the code over. It's possible winston-rsyslog2 may work directly with syslog, but this hasn't been tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants