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 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.

Two other convenience methods for each of the five Logger severities are also provided for checking and adjusting EasyLog threshold levels. The log_debug?, log_info?, log_warn?, log_error? and log_fatal? methods return true if a message at that level will be reported. Respectively, the log_level_debug, log_level_info, log_level_warn, log_level_error and log_level_fatal methods will set the threshold to pass only messages at or above the selected severity.

Methods

Public Instance methods

Changes the EasyLogger used for EasyLog logging to the given EasyLogger.

Returns the EasyLogger that is being used for EasyLog logging.

Turns off EasyLog logging until restarted.

Returns the threshold of the EasyLog, or nil if no Easylogger is set.

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.

[Validate]