winston-cloudwatch icon indicating copy to clipboard operation
winston-cloudwatch copied to clipboard

Options should be optional

Open melbourne2991 opened this issue 8 years ago • 6 comments
trafficstars

Currently if you do not provide options you will get "cannot get property level of undefined"

melbourne2991 avatar Oct 15 '17 13:10 melbourne2991

Coverage Status

Coverage increased (+0.03%) to 93.617% when pulling acf3fd16f24ee887a70c33a16c2a757861fd8f51 on melbourne2991:patch-1 into ece0847c03e057b501f1dae01d62d59e92833095 on lazywithclass:master.

coveralls avatar Oct 15 '17 13:10 coveralls

Could you please provide a code example showing in which case that error is shown?

lazywithclass avatar Oct 15 '17 13:10 lazywithclass

winston.add(WinstonCloudWatch);

melbourne2991 avatar Oct 15 '17 23:10 melbourne2991

I see. Then I don't think the fix is to let someone add to winston a configuration that will surely not work, because it doesn't have any information on where to store logs.

What's your use case? Why would you need to be able to use this library without, for example, a log stream and a log group?

lazywithclass avatar Oct 16 '17 08:10 lazywithclass

If you don't allow an empty object it fails but the error message is unclear and not relevant to the actual problem - "cannot get property level of undefined", when you do allow an empty object the code will fail when it tries to get logGroupName and the error is more relevant (something along the lines of "logGroupName" not defined). I was confused about "level" being undefined because the Readme says level defaults to "info". So I spent quite a bit of time trying to figure out what was wrong with my "level" when really the problem was that I was missing logGroupName and logStreamName.

melbourne2991 avatar Oct 17 '17 00:10 melbourne2991

Cool, looks like we're talking about validation. Thanks for the details, they're really helpful for me to understand what the problem is.

I think I would like to do some basic validation on the options, so that we check that at least logGroup and logStream are there.

lazywithclass avatar Oct 17 '17 08:10 lazywithclass