Class | Ramaze::Logger::RotatingInformer
In: | lib/ramaze/log/rotatinginformer.rb
Parent: | Object

A customized logger (based on Informer) that creates multiple log files based on time

### Methods

base_dir= closed? log log_interpolate new shutdown timestamp

### Included Modules

Innate::Traited Logging

### Attributes

base_dir | [R] |
log_levels | [RW] |
time_format | [RW] |

### Public Class methods

new(base_dir, time_format = '%Y-%m-%d.log', log_levels = [:debug, :error, :info, :warn])

Create a new instance of RotatingInformer.

base_dir is the directory where all log files will be stored

time_format is the time format used to name the log files. Possible formats are identical to those accepted by Time.strftime

log_levelse is an array describing what kind of messages that the log receives. The array may contain any or all of the symbols :debug, :error, :info and/or :warn

Examples:

      RotatingInformer.new('logs')
                                      #=> Creates logs in directory called logs.
                                          The generated filenames will be in the
                                          form YYYY-MM-DD.log
      RotatingInformer.new('logs', '%Y-%m.txt')
                                      #=> Creates logs in directory called logs.
                                          The generated filenames will be in the
                                          form YYYY-MM.txt
      RotatingInformer.new('logs', '%Y-%m.txt', [:error])
                                      #=> Creates logs in directory called logs.
                                          The generated filenames will be in the
                                          form YYYY-MM.txt. Only errors will be
                                          logged to the files.

### Public Instance methods

base_dir=(directory, raise_exception = false)

Set the base directory for log files

If this method is called with the raise_exception parameter set to true the method will raise an exception if the specified directory does not exist or is unwritable.

If raise_exception is set to false, the method will just silently fail if the specified directory does not exist or is unwritable

closed?()

is @out closed?

log(tag, *messages)

Integration to Logging.

log_interpolate(prefix, text, time = timestamp)

Takes the prefix (tag), text and timestamp and applies it to the :format trait.

shutdown()

Close the file we log to if it isn‘t closed already.

timestamp()

This uses timestamp trait or a date in the format of

      %Y-%m-%d %H:%M:%S
      # => "2007-01-19 21:09:32"

[Validate]