{"action":"created","issue":{"url":"https://api.github.com/repos/winstonjs/winston/issues/1224","repository_url":"https://api.github.com/repos/winstonjs/winston","labels_url":"https://api.github.com/repos/winstonjs/winston/issues/1224/labels{/name}","comments_url":"https://api.github.com/repos/winstonjs/winston/issues/1224/comments","events_url":"https://api.github.com/repos/winstonjs/winston/issues/1224/events","html_url":"https://github.com/winstonjs/winston/issues/1224","id":302100424,"number":1224,"title":"logger.error(null) throws an error! It shouldn't... console.log(null) doesn't","user":{"login":"teneon","id":12419201,"avatar_url":"https://avatars1.githubusercontent.com/u/12419201?v=4","gravatar_id":"","url":"https://api.github.com/users/teneon","html_url":"https://github.com/teneon","followers_url":"https://api.github.com/users/teneon/followers","following_url":"https://api.github.com/users/teneon/following{/other_user}","gists_url":"https://api.github.com/users/teneon/gists{/gist_id}","starred_url":"https://api.github.com/users/teneon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teneon/subscriptions","organizations_url":"https://api.github.com/users/teneon/orgs","repos_url":"https://api.github.com/users/teneon/repos","events_url":"https://api.github.com/users/teneon/events{/privacy}","received_events_url":"https://api.github.com/users/teneon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-04T16:41:47Z","updated_at":"2018-03-05T15:10:03Z","closed_at":null,"author_association":"NONE","body":"Hi there,\r\n\r\ni've been playing with winston@3.0.0-rc1 for the past few days. It's a great project ,thank you guys for the effort! I think i have found one nasty problem/bug that i believe should be fixed in the project itself. This is a simple example from the Winston Github page:\r\n\r\nconst { createLogger, format, transports } = require('winston');\r\nconst { combine, timestamp, label, prettyPrint } = format;\r\n\r\nconst logger = createLogger({\r\n  format: combine(\r\n    label({ label: 'right meow!' }),\r\n    timestamp(),\r\n    prettyPrint()\r\n  ),\r\n  transports: [new transports.Console()]\r\n})\r\n\r\n// This works fine\r\nlogger.log({ level: 'info', message: 'What time is the testing at?' });\r\n// This works fine\r\nlogger.log({ level: 'info', message: null });\r\n// This works fine\r\nlogger.log('info',null);\r\n// **This will CRASH the app!**\r\nlogger.info(null);\r\n// **This will also CRASH the app!**\r\nlogger.error(null);\r\n\r\nHere is the error message:\r\n/node_modules/winston/lib/winston/create-logger.js:43\r\nconst info = msg.message && msg || { message: msg };\r\nTypeError: Cannot read property 'message' of null at DerivedLogger.(anonymous function) [as debug]\r\n...\r\n\r\nBasically the problem is that when you try to log a variable, you are unaware if it is going to be null\r\nor not at the time of writing it into the log.\r\n\r\nFor example:\r\nlet firstName = null;\r\nand let's assume you are unaware that your variable firstName is null or it becomes null under some specific conditions, but of course you would still like to log it.\r\nlogger.info(firstName);   => **This will crash an app.**\r\n\r\nInterestingly, if you try to log a variable that is null with a different method, it works just fine:\r\nlogger.log('info',null);  => this works fine!\r\n\r\nIf you use the standard console.log(null) it simply outputs null to the console, which is also an expected behaviour ,it doesn't crash the app.\r\n\r\nThis is quite a nasty issue in my opinion and until this is fixed i believe logger.error, logger.info, logger.debug and other methods should be avoided. What do you guys think?\r\n\r\nbest regards,\r\nJim\r\n\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/winstonjs/winston/issues/comments/370449418","html_url":"https://github.com/winstonjs/winston/issues/1224#issuecomment-370449418","issue_url":"https://api.github.com/repos/winstonjs/winston/issues/1224","id":370449418,"user":{"login":"teneon","id":12419201,"avatar_url":"https://avatars1.githubusercontent.com/u/12419201?v=4","gravatar_id":"","url":"https://api.github.com/users/teneon","html_url":"https://github.com/teneon","followers_url":"https://api.github.com/users/teneon/followers","following_url":"https://api.github.com/users/teneon/following{/other_user}","gists_url":"https://api.github.com/users/teneon/gists{/gist_id}","starred_url":"https://api.github.com/users/teneon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teneon/subscriptions","organizations_url":"https://api.github.com/users/teneon/orgs","repos_url":"https://api.github.com/users/teneon/repos","events_url":"https://api.github.com/users/teneon/events{/privacy}","received_events_url":"https://api.github.com/users/teneon/received_events","type":"User","site_admin":false},"created_at":"2018-03-05T15:10:03Z","updated_at":"2018-03-05T15:10:03Z","author_association":"NONE","body":"I can see it has already been fixed in pull requests: https://github.com/winstonjs/winston/pull/1189\r\nSo it just needs to be added to the project i guess :)"}}
{"actor":{"display_login":"teneon"}}