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 52 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 89 def file @file || (backtrace!; @file) end
hostname()
click to toggle source
Accessor to the hostname
# File lib/yell/event.rb, line 69 def hostname @@hostname end
line()
click to toggle source
Accessor to the line the log event occured
# File lib/yell/event.rb, line 94 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 99 def method @method || (backtrace!; @method) end
pid()
click to toggle source
Accessor to the PID
# File lib/yell/event.rb, line 79 def pid Process.pid end
progname()
click to toggle source
Accessor to the progname
# File lib/yell/event.rb, line 74 def progname @@progname end
thread_id()
click to toggle source
Accessor to the thread's id
# File lib/yell/event.rb, line 84 def thread_id Thread.current.object_id end
Private Instance Methods
backtrace!()
click to toggle source
# File lib/yell/event.rb, line 120 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 116 def caller_index CallerIndex + @caller_offset end
extract!( options )
click to toggle source
# File lib/yell/event.rb, line 106 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