Class RADUM::Logger
In: lib/radum/logger.rb
Parent: Object

The Logger class handles all logging output. Any output RADUM generates aside from exceptions goes through the Logger class. The possible log levels are:

  • LOG_NONE: Do not output any log information.
  • LOG_NORMAL: Output normal messages (warnings) for certain situations.
  • LOG_DEBUG: Output verbose debugging information.

The RADUM module automatically instantiates a Logger instance for the module that is accessible through the RADUM::logger method.

Methods

log   new   output_file  

Attributes

default_level  [RW]  The default logger level. Logger levels less than or equal to the default logger level will be displayed. Other messages will be ignored. If the logger level is set to LOG_NONE, no log messages will be displayed.

Public Class methods

Create a new Logger instance. A Logger object is automatically created with a default_level of LOG_NORMAL.

Parameter Types

  • default_level [integer => RADUM log level constant]

[Source]

    # File lib/radum/logger.rb, line 29
29:     def initialize(default_level)
30:       @default_level = default_level
31:       @output = $stdout
32:     end

Public Instance methods

Print a long message with the given log level. If the log level is LOG_NONE, the message will be discarded, otherwise the message will be processed as long as the log level is less than or equal to the default log level. The log level defaults to LOG_NORMAL.

Parameter Types

  • mesg [String]
  • log_level [integer => RADUM log level constant]

[Source]

    # File lib/radum/logger.rb, line 43
43:     def log(mesg, log_level = LOG_NORMAL)
44:       if @default_level != LOG_NONE && log_level != LOG_NONE &&
45:          log_level <= @default_level
46:         @output.puts mesg
47:       end
48:     end

Set the logger output file. The file is opened with mode "a" so it is created if needed and then appended to.

Parameter Types

  • filename [String]

[Source]

    # File lib/radum/logger.rb, line 56
56:     def output_file(filename)
57:       @output = open(filename, "a")
58:     end

[Validate]