Class: MetricCollect::Log
- Inherits:
-
Object
- Object
- MetricCollect::Log
- Defined in:
- lib/metric_collect/log.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(log_file = nil) ⇒ Log
constructor
A new instance of Log.
Constructor Details
#initialize(log_file = nil) ⇒ Log
Returns a new instance of Log.
20 21 22 |
# File 'lib/metric_collect/log.rb', line 20 def initialize(log_file=nil) @log_file = log_file end |
Class Method Details
.build_time ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/metric_collect/log.rb', line 38 def self.build_time time = Time.now year = "%04d" % time.year month = "%02d" % time.month day = "%02d" % time.day hour = "%02d" % time.hour min = "%02d" % time.min sec = "%02d" % time.sec "#{year}-#{month}-#{day} #{hour}:#{min}:#{sec}" end |
.fatal(msg, error = nil) ⇒ Object
32 33 34 35 36 |
# File 'lib/metric_collect/log.rb', line 32 def self.fatal(msg, error=nil) Log.write(msg, "FATAL") raise error if error exit end |
.info(msg) ⇒ Object
24 25 26 |
# File 'lib/metric_collect/log.rb', line 24 def self.info(msg) Log.write(msg, "INFO") end |
.warn(msg) ⇒ Object
28 29 30 |
# File 'lib/metric_collect/log.rb', line 28 def self.warn(msg) Log.write(msg, "WARN") end |