agraubert/agutil

Add logger class

Closed this issue · 4 comments

Allow for logging (duh). Messages can be printed to stdout, a file, or both. Allow for printing to different channels, and for different verbosity levels. IO should happen on a background thread, with a synchronous method to add a message to the logging queue. Integrate into all agutil.io and agutil.security classes (to use a Logger instead of print() ).

Security 2.0 ( #52 ) will mark the 0.5.0b release and this will follow in 0.6.0b

I'm thinking about using tiered verbosity levels. The logger is set with a specific verbosity level, and only anything which is logged at that level or lower is actually logged (messages logged at higher levels are ignored). For example:

  • 5 - Debug Extra (Also log detailed messages of arguments, io, flag status, etc)
  • 4 - Debug (Also log step-by-step messages of the activities of the program)
  • 3 - Info (Also log basic informational messages)
  • 2 - Warnings (Also log warnings and and anything else logged to the warnings channel)
  • 1 - Errors (Log only error messages and anything else logged to the error channel)
  • 0 - None (Print no messages)

The log() method will take a message, channel name, and sender name. It will quickly check if the desired channel is enabled, then acquire a data lock to insert the message into a logging queue.

In addition to logging levels pre-setting which channels are enabled, the logger api should allow a user to individually enable/disable logging on each channel. Even for channels beyond the default ones (above)

Allow for two different verbosity levels (as well as channel filters, as mentioned in the last comment). One for logging, and one for printing. Messages are logged to the logfile if logging is enabled for the specified channel, and messages are printed to stdout if the printing is enabled for the channel.