Module: Cabin::Mixins::Logger

Included in:
Channel
Defined in:
lib/cabin/mixins/logger.rb

Overview

This module implements methods that act somewhat like Ruby’s Logger class It is included in Cabin::Channel

Constant Summary collapse

LEVELS =
{
  :fatal => 0,
  :error => 1,
  :warn => 2,
  :info => 3,
  :debug => 4
}
BACKTRACE_RE =
/([^:]+):([0-9]+)(?::in `(.*)')?/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#levelObject

Returns the value of attribute level.



17
18
19
# File 'lib/cabin/mixins/logger.rb', line 17

def level
  @level
end

Class Method Details

.included(klass) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/cabin/mixins/logger.rb', line 7

def self.included(klass)
  klass.condition do |event, subscription|
    if subscription.nil?
      true
    else
      LEVELS[(subscription.options[:level] || :debug)] >= LEVELS[event[:level]].to_i
    end
  end
end

Instance Method Details

#log(message, data = {}) ⇒ Object

def log_with_level



93
94
95
# File 'lib/cabin/mixins/logger.rb', line 93

def log(message, data={})
  _log(message, data)
end