Class: Recurrent::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/recurrent/logger.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier) ⇒ Logger

Returns a new instance of Logger.



6
7
8
# File 'lib/recurrent/logger.rb', line 6

def initialize(identifier)
  @identifier = identifier
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



4
5
6
# File 'lib/recurrent/logger.rb', line 4

def identifier
  @identifier
end

Class Method Details

.define_log_levels(*log_levels) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/recurrent/logger.rb', line 14

def self.define_log_levels(*log_levels)
  log_levels.each do |log_level|
    define_method(log_level) do |message|
      message = log_message(message)
      puts message unless Configuration.logging == "quiet"
      Configuration.logger.call(message, log_level) if Configuration.logger
    end
  end
end

Instance Method Details

#log_message(message) ⇒ Object



10
11
12
# File 'lib/recurrent/logger.rb', line 10

def log_message(message)
  "[Recurrent - Process:#{@identifier} - Timestamp:#{Time.now.to_s(:seconds)}] - #{message}"
end