class RbRotate::Log

Logfile.

Public Class Methods

get() click to toggle source

Returns its singletone instance.

# File lib/rb.rotate/log.rb, line 28
def self.get
    if @@self.nil?
        @@self = self::new(Configuration::get.paths[:"log file"])
    end
    
    return @@self
end
new(path) click to toggle source

Constructor.

# File lib/rb.rotate/log.rb, line 48
def initialize(path)
    @path = path
end
write(message, caller = nil) click to toggle source

Alias for write.

# File lib/rb.rotate/log.rb, line 40
def self.write(message, caller = nil)
    self::get.write(message, caller)
end

Public Instance Methods

write(message, caller = nil) click to toggle source

Writes to log.

# File lib/rb.rotate/log.rb, line 56
def write(message, caller = nil)
    output = "[" << Time.now.strftime("%Y-%m-%d %H:%M:%S.%L") << "] "
    if caller
        output << caller.class.name << ": "
    end
    output << message << "\n"
    
    ::File.open(@path, "a") do |io|
        io.write(output)
    end
end