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

Hook to uppercase the 'level' #21

Open
raboof opened this issue Nov 18, 2015 · 1 comment
Open

Hook to uppercase the 'level' #21

raboof opened this issue Nov 18, 2015 · 1 comment

Comments

@raboof
Copy link

raboof commented Nov 18, 2015

I like how bunyan-logstash-tcp converts the integer loglevel to a string.

I'd like to have uppercase loglevels in logstash, though. Is there a way to do this, perhaps by pre-processing the log object somehow? I've briefly looked at serializers but that doesn't seem to be helpful here.

If not, could we somehow make the translation of the 'level' field configurable in bunyan-logstash-tcp?

@raboof
Copy link
Author

raboof commented Nov 18, 2015

I've monkey-patched around it like this for now:


var levels = {
  10: 'TRACE',
  20: 'DEBUG',
  30: 'INFO',
  40: 'WARN',
  50: 'ERROR',
  60: 'FATAL'
};

logstashStream.originalWrite = logstashStream.write
logstashStream.write = function patchedLogstashWrite(entry) {
  if (levels.hasOwnProperty(entry.level)) {
    entry.level = levels[entry.level];
  }
  this.originalWrite(entry);
}

.. but I'm not proud of it :)

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

1 participant