class Yell::Event

::new( :info, 'Hello World', { :scope => 'Application' } ) #=> Hello World scope: Application

Constants

CallerIndex

jruby and rubinius seem to have a different caller

CallerRegexp

regex to fetch caller attributes

Attributes

level[R]

Accessor to the log level

messages[R]

Accessor to the log message

name[R]

Accessor to the logger's name

time[R]

Accessor to the time the log event occured

Public Class Methods

new( logger, options, *messages) click to toggle source
# File lib/yell/event.rb, line 54
def initialize( logger, options, *messages)
  @time = Time.now
  @name = logger.name

  extract!(options)

  @messages = messages

  @caller = logger.trace.at?(level) ? caller[caller_index].to_s : ''
  @file = nil
  @line = nil
  @method = nil

  @pid = nil
end

Public Instance Methods

file() click to toggle source

Accessor to filename the log event occured

# File lib/yell/event.rb, line 91
def file
  @file || (backtrace!; @file)
end
hostname() click to toggle source

Accessor to the hostname

# File lib/yell/event.rb, line 71
def hostname
  @@hostname
end
line() click to toggle source

Accessor to the line the log event occured

# File lib/yell/event.rb, line 96
def line
  @line || (backtrace!; @line)
end
method() click to toggle source

Accessor to the method the log event occured

# File lib/yell/event.rb, line 101
def method
  @method || (backtrace!; @method)
end
pid() click to toggle source

Accessor to the PID

# File lib/yell/event.rb, line 81
def pid
  Process.pid
end
progname() click to toggle source

Accessor to the progname

# File lib/yell/event.rb, line 76
def progname
  @@progname
end
thread_id() click to toggle source

Accessor to the thread's id

# File lib/yell/event.rb, line 86
def thread_id
  Thread.current.object_id
end

Private Instance Methods

backtrace!() click to toggle source
# File lib/yell/event.rb, line 122
def backtrace!
  if m = CallerRegexp.match(@caller)
    @file, @line, @method = m[1..-1]
  else
    @file, @line, @method = ['', '', '']
  end
end
caller_index() click to toggle source
# File lib/yell/event.rb, line 118
def caller_index
  CallerIndex + @caller_offset
end
extract!( options ) click to toggle source
# File lib/yell/event.rb, line 108
def extract!( options )
  if options.is_a?(Yell::Event::Options)
    @level = options.severity
    @caller_offset = options.caller_offset
  else
    @level = options
    @caller_offset = 0
  end
end