-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Error objects are discarded during logging #280
Comments
+1 This is really bad! |
+1 |
1 similar comment
+1 |
+1 Just bit me |
+1 In the mean time, here's a cheezy hack -- as early as you can (only needs to be done once across all modules of course): // A workaround for a bug in winston:
// See: https://github.com/flatiron/winston/issues/280
(function patchWinston() {
var winstonCommon = require('winston/lib/winston/common')
, _log = winstonCommon.log;
function errorToStack(obj) {
var copy;
if (obj == null || typeof obj != 'object') {
return obj;
}
if (obj instanceof Error) {
return obj.stack;
}
if (obj instanceof Date || obj instanceof RegExp) {
return obj;
}
if (obj instanceof Array) {
copy = [];
for (i in obj) {
copy[i] = errorToStack(obj[i]);
}
return copy;
}
else {
copy = {};
for (k in obj) {
if (obj.hasOwnProperty(k)) {
copy[k] = errorToStack(obj[k]);
}
}
}
}
winstonCommon.log = function (options) {
if (options != null && typeof options === 'object' && typeof options.meta === 'object') {
options.meta = errorToStack(options.meta);
}
return _log(options);
}
})(); And it's possible you might have to add more instanceof checks... |
This is my workaround: |
+1 and I echo the sentiments earlier: this is really bad and it's over 4 months old and it's pretty critical. Is this project dead? |
I think its kinda dead. I switched over to bunyan. very satisfied. On Thu, Nov 14, 2013 at 5:33 PM, WhatFreshHellIsThis <
|
Hey @agsha I wanted to move also to bunyan a time ago but I wasn't because of json logs but I really didn't dig into too much. Do you know if is possible to log as text like winston? thanks! |
Also, I would be interested if bunyan supports email transport. Currently I use winston-email module. |
@jpgarcia bunyan primarily deals with json logs. There is no text mode in bunyan. But you can always log like this:
However I found the json format much more convenient after a while. Almost every object I log has to be json formatted anyway. @lobodpav Bunyan doesnt currently support email transport AFAIK. It seems easy to write one. See bunyan streams |
Thanks @agsha thanks for the hint. I could reuse the winston-mail code to implement bunyan stream. |
@lobodpav As for the issue of ugly json on console, I never read the json logs without the bunyan cli It prints the output very nicely and is very readable. Internally bunyan prints a single line of json per log record and the bunyan cli formats it very nicely. Plus the cli comes packaged with some handy filtering options. |
@agsha I see, piping the output to bunyan CLI is a way to get the stuff readable on console. Although, typing |
agree. its a little painful. On Fri, Nov 15, 2013 at 10:46 AM, Pavel Lobodinský <notifications@github.com
|
Now I realised that actually I can put this script directly into package.json: "scripts": {
"start": "node index.js | bunyan"
} So actually, everything should work nicely as before :) |
…cktrace! (fix winston issue winstonjs#280)
Yesterday, I switched over to bunyan too. No more patience to wait half a year to get logger... actually logging. |
+1 to fixing this issue... And bunyan looks interesting, I'll have to take a deeper look at it. : ) |
This mainly stems from Error objects, as well as other types not always being logged to winston if passed as an argument: winstonjs/winston#280 winstonjs/winston#177 We're not really using some of Winston's more advanced features right now, so log.js seems to do the trick.
+1 |
+1 |
+1 |
Project is not active. On Mon, Mar 17, 2014 at 8:59 AM, pmendelski notifications@github.comwrote:
|
Uh, yes it is. On Mon, Mar 17, 2014 at 1:46 PM, agsha notifications@github.com wrote:
|
Robin, your idea of "active" might differ from the rest of us. |
Please prove that it's still active by fixing this issue ;) |
+1 really annoying :( |
So... This is the first thing I ran into when using Winston. Is this gonna be fixed/changed in the project or what is the proposed solution? |
@Guuz This project appears to be inactive. |
Dammit Winston! Moving to Bunyan then. |
+1 |
2 similar comments
+1 |
+1 |
Dug into this. Very strange behavior. TIL that all properties on |
… non-enumerable __by default.__ Fixes #280.
+1 :) |
+1 |
Fix is already committed for this. Just need to ship |
Yup, saw that. Still need it to be shipped, hence the +1 since I'm affected by the issue. :) |
I thought this project's dead. |
Utterly dead. |
I fell back to console.log 😒
|
Which commit exactly added this feature? @indexzero |
This one on the 0.9.x branch: 8fe22b1 This project is not dead. @pose, @jcrugzz and I have been triaging old issues before shipping 0.9.0, but I expect that to happen before the new year when this will land. If you don't want to use it because of your lack of patience then don't. No one is forcing you, but the Jedi will probably be disappointed in your attitude |
Mmm, the Jedi. :) |
This is shit |
Locked this issue. @desertlynx your negative and unproductive comments will get you nowhere. |
Trying to call logger this way in a callback:
does not print out the
Error
object.By walking through the
common.js
code I found this section inexports.log
which shall print out theerr.stack
:However, this does not work because there is this line:
I.e. calling the
exports.clone(......
causes to return back an empty object instead of theoptions.meta
.The text was updated successfully, but these errors were encountered: