Class: DataObjects::Logger

Class | DataObjects::Logger
In: | lib/data_objects/logger.rb
Parent: | Object

#### Public DataObjects Logger API

Logger taken from Merb :)

To replace an existing logger with a new one:

     DataObjects::Logger.set_log(log{String, IO},level{Symbol, String})

Available logging levels are

      DataObjects::Logger::{ Fatal, Error, Warn, Info, Debug }

Logging via:

      DataObjects.logger.fatal(message<String>)
      DataObjects.logger.error(message<String>)
      DataObjects.logger.warn(message<String>)
      DataObjects.logger.info(message<String>)
      DataObjects.logger.debug(message<String>)

Flush the buffer to

      DataObjects.logger.flush

Remove the current log object

      DataObjects.logger.close

#### Private DataObjects Logger API

To initialize the logger you create a new object, proxies to set_log.

      DataObjects::Logger.new(log{String, IO},level{Symbol, String})

Logger will not create the file until something is actually logged This avoids file creation on DataObjects init when it creates the default logger.

### Methods

<< close flush level= new push set_log

### Constants

LEVELS | = | { :off => 99999, :fatal => 7, :error => 6, :warn => 4, :info => 3, :debug => 0 |  | @note
      Ruby (standard) logger levels:
        off:   absolutely nothing
        fatal: an unhandleable error that results in a program crash
        error: a handleable error condition
        warn:  a warning
        info:  generic (useful) information about system operation
        debug: low-level information for developers

      DataObjects::Logger::LEVELS[:off, :fatal, :error, :warn, :info, :debug]

### External Aliases

write_nonblock | -> | write_method
write | -> | write_method
push_opened | -> | internal_push
push_closed | -> | internal_push

### Attributes

aio | [RW] | Use asynchronous I/O?
buffer | [R] | Direct access to the buffer
delimiter | [RW] | delimiter to use between message sections
level | [R] | a symbol representing the log level from {:off, :fatal, :error, :warn, :info, :debug}
log | [R] | The name of the log file

### Public Class methods

new(*args)

To initialize the logger you create a new object, proxies to set_log.

      DataObjects::Logger.new(log{String, IO},level{Symbol, String})

@param log<IO,String> either an IO object or a name of a logfile. @param log_level<String> the message string to be logged @param delimiter<String> delimiter to use between message sections @param log_creation<Boolean> log that the file is being created

### Public Instance methods

<<(string)

Alias for push

close()

Close and remove the current log object.

      DataObjects.logger.close

flush()

Flush the entire buffer to the log object.

      DataObjects.logger.flush

level=(new_level)

Set the log level (use the level symbols as documented)

push(string)

@note

      Note that the string is discarded if the string's log level less than the
      logger's log level.

@note

      Note that if the logger is aio capable then the logger will use
      non-blocking asynchronous writes.

@param level<Fixnum> the logging level as an integer @param string<String> the message string to be logged

set_log(log, log_level = :off, delimiter = " ~ ", log_creation = false)

To replace an existing logger with a new one:

     DataObjects::Logger.set_log(log{String, IO},level{Symbol, String})

@param log<IO,String> either an IO object or a name of a logfile. @param log_level<Symbol> a symbol representing the log level from

      {:off, :fatal, :error, :warn, :info, :debug}

@param delimiter<String> delimiter to use between message sections @param log_creation<Boolean> log that the file is being created

[Validate]