Module: FiniteMachine::Logger

Defined in:
lib/finite_machine/logger.rb

Class Method Summary collapse

Class Method Details

.debug(message) ⇒ Object



7
8
9
# File 'lib/finite_machine/logger.rb', line 7

def debug(message)
  FiniteMachine.logger.debug(message)
end

.error(message) ⇒ Object



19
20
21
# File 'lib/finite_machine/logger.rb', line 19

def error(message)
  FiniteMachine.logger.error(message)
end

.format_error(error) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/finite_machine/logger.rb', line 23

def format_error(error)
  message = ["#{error.class}: #{error.message}\n\t"]
  if error.backtrace
    message << "occured at #{error.backtrace.join("\n\t")}"
  else
    message << "EMPTY BACKTRACE\n\t"
  end
  message.join
end

.info(message) ⇒ Object



11
12
13
# File 'lib/finite_machine/logger.rb', line 11

def info(message)
  FiniteMachine.logger.info(message)
end

.report_transition(name, from, to, *args) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/finite_machine/logger.rb', line 33

def report_transition(name, from, to, *args)
  message = ["Transition: @event=#{name} "]
  unless args.empty?
    message << "@with=[#{args.join(',')}] "
  end
  message << "#{from} -> #{to}"
  info(message.join)
end

.warn(message) ⇒ Object



15
16
17
# File 'lib/finite_machine/logger.rb', line 15

def warn(message)
  FiniteMachine.logger.warn(message)
end