Weetbix / facebot

Slackbot for facebook messaging integration in slack
MIT License
93 stars 21 forks source link

Logging improvements #20

Open mitchcapper opened 7 years ago

mitchcapper commented 7 years ago

I think it would be good to update the logging functionality a bit. I would like to add some more diagnostic logging functions (ie for events etc).

There are a few console.log's in places and then sendDebugMessage as well. I think it might be good to add a central logging function that takes the message and the log level. There would then be two configurable variables I see: SLACK_LOG_LEVEL, CONSOLE_LOG_LEVEL that specifies what logging to do to each. Technically we could also just do one LOG_LEVEL variable and then use the existing DEBUG_MESSAGES env variable to determine if we send the logs to slack. This gives better back compat but sacrifices functionality. Other option is to use the two new variables and then just in code set SLACK_LOG_LEVEL to something reasonable if DEBUG_MESSAGES is specified.

I would recommend something along the lines of CRIT,ERROR,WARN,INFO,DEBUG.

DEBUG would dump all events, and we would now allow SLACK_LOG_LEVEL to be set that high (otherwise a nice loop where informing of the slack message sent would generate another sent message;).

Once we have a design direction I can submit a PR (will wait for some other items first.