Sha256: 9499e81895a38deb439d6d72d809f531791c7960c76db3319e7bbad7a62e36b8

Contents?: true

Size: 981 Bytes

Versions: 3

Compression:

Stored size: 981 Bytes

Contents

# encoding: utf-8

module FiniteMachine
  module Logger
    module_function

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

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

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

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

    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
    end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
finite_machine-0.10.2 lib/finite_machine/logger.rb
finite_machine-0.10.1 lib/finite_machine/logger.rb
finite_machine-0.10.0 lib/finite_machine/logger.rb