Module | Eymiha::EasyLog |
In: |
lib/eymiha/util/easylog.rb
|
EasyLog is a quick and convenient way to implement logging in Ruby code. By requiring the eymiha/util/easylog code, Easylog is included into module and is subsequently available to all classes.
There is a natural flow to EasyLog logging. First logging is started somewhere on high
start_logging filename
then messages are written to the log with the appropriate severity (here an informational message is logged)
log_info "something happened: #{foo}"
and optionally, when finished,
finish_logging
The upshot is that logging can be done from anywhere, and is as simple and easy as possible.
The module builds five methods for EasyLog logging corresponding to the five Logger severities: log_debug, log_info, log_warn, log_error and log_fatal. Their arguments are a message to be logged, and optionally one or more EasyLoggers that will be the targets of the message.
Note that the classify attribute of an EasyLogger stores the decision about adding the class name to the end of the message or not; by default it is true and class names are added.
easylogger.classify = false
will turn this off.
Changes the EasyLogger used for EasyLog logging to the given EasyLogger.
Creates a new EasyLogger instance with the given arguments, and uses it for all subsequent EasyLog logging. The arguments are the same as used in EasyLogger creation.