-
Notifications
You must be signed in to change notification settings - Fork 14
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
Map Winston levels to LogDNA levels #31
Comments
While debugging this I came across a few potential issues. Most notably, this library only supports the NPM log levels; however, WinstonJS provides several log level configurations (docs)! Furthermore, this library does not support custom log levels, as the mapping between WinstonJS and LogDNA levels is hardcoded (file)! This is quite frustrating for developers working with custom log levels, as it means there is no way to pass some log levels through to LogDNA (or map them). Is there a way that this level mapping could be customizable? |
As a workaround, I created a patch file with Please note these are intended as temporary workarounds only :) diff --git a/node_modules/logdna-winston/index.js b/node_modules/logdna-winston/index.js
index e17031a..81abcf9 100644
--- a/node_modules/logdna-winston/index.js
+++ b/node_modules/logdna-winston/index.js
@@ -6,7 +6,8 @@ const pkg = require('./package.json')
// Convert between Winston levels and @logdna/logger levels
const levelTranslate = new Map([
- ['error', 'error']
+ ['critical', 'critical']
+, ['error', 'error']
, ['warn', 'warn']
, ['info', 'info']
, ['http', 'debug'] |
@darinspivey Regarding your brief mention of this repository in Issue #53, will there also be a change to support a custom |
@kendallroth Yes, once custom levels are supported, this package will get a |
As Winston allows for the use of custom log levels, now so does LogDNA. Custom levels can be defined for both Winston and LogDNA such that those custom levels will show up on LogDNA's log viewer. BREAKING CHANGE: This removes the log level "translation" that used to be in place to convert Winston levels to ones that would be acceptable by LogDNA. Since LogDNA can now define custom levels as well, this translation is no longer needed, however it may break implementations that are relying on the translated levels. Fixes: #31
As Winston allows for the use of custom log levels, now so does LogDNA. Custom levels can be defined for both Winston and LogDNA such that those custom levels will show up on LogDNA's log viewer. BREAKING CHANGE: This removes the log level "translation" that used to be in place to convert Winston levels to ones that would be acceptable by LogDNA. Since LogDNA can now define custom levels as well, this translation is no longer needed, however it may break implementations that are relying on the translated levels. Fixes: #31
As Winston allows for the use of custom log levels, now so does LogDNA. Custom levels can be defined for both Winston and LogDNA such that those custom levels will show up on LogDNA's log viewer. BREAKING CHANGE: This removes the log level "translation" that used to be in place to convert Winston levels to ones that would be acceptable by LogDNA. Since LogDNA can now define custom levels as well, this translation is no longer needed, however it may break implementations that are relying on the translated levels. Fixes: #31
@kendallroth Please let us know how this change works for you. |
🎉 This issue has been resolved in version 4.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@darinspivey Thank you so much for your work on this; I have tested (albeit not in production yet) and verified that this resolves our use case. Simply being able to use the custom Winston levels along with a quick call to P.S. While testing this I did run into an unrelated bug with the transport |
In our project there is a discrepancy between the log levels supported by
@logdna/logger
and the levels we are using in WinstonJS (we also useCRITICAL
). We have not found a way to "map" between the Winston log levels (custom or otherwise) to the list of supported LogDNA levels.For example, a potential workaround would be mapping our WinstonJS
critical
log level to the LogDNAerror
log level (since they do not supportcritical
). However, currently this is not possible, so any of ourcritical
logs get reported asinfo
in LogDNA.Is there any way to get support for additional log levels, or at least mapping them?
P.S. The LogDNA docs apparently support more common log levels, but their package does not... See slightly different ask in
@logdna/logger
The text was updated successfully, but these errors were encountered: