Class: RbRotate::Log
Overview
Logfile.
Constant Summary collapse
- @@self =
Singletone instance.
nil
Class Method Summary collapse
-
.get ⇒ Object
Returns its singletone instance.
-
.write(message, caller = nil) ⇒ Object
Alias for #write.
Instance Method Summary collapse
-
#initialize(path) ⇒ Log
constructor
Constructor.
-
#write(message, caller = nil) ⇒ Object
Writes to log.
Constructor Details
#initialize(path) ⇒ Log
Constructor.
48 49 50 |
# File 'lib/rb.rotate/log.rb', line 48 def initialize(path) @path = path end |
Class Method Details
.get ⇒ Object
Returns its singletone instance.
28 29 30 31 32 33 34 |
# 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 |
.write(message, caller = nil) ⇒ Object
Alias for #write.
40 41 42 |
# File 'lib/rb.rotate/log.rb', line 40 def self.write(, caller = nil) self::get.write(, caller) end |
Instance Method Details
#write(message, caller = nil) ⇒ Object
Writes to log.
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rb.rotate/log.rb', line 56 def write(, caller = nil) output = "[" << Time.now.strftime("%Y-%m-%d %H:%M:%S.%L") << "] " if caller output << caller.class.name << ": " end output << << "\n" ::File.open(@path, "a") do |io| io.write(output) end end |