::new( :info, 'Hello World', { :scope => 'Application' } ) #=> Hello World scope: Application
jruby and rubinius seem to have a different caller
regex to fetch caller attributes
Accessor to the log level
Accessor to the log message
Accessor to the logger's name
Accessor to the time the log event occured
# File lib/yell/event.rb, line 53 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
Accessor to filename the log event occured
# File lib/yell/event.rb, line 90 def file @file || (backtrace!; @file) end
Accessor to the hostname
# File lib/yell/event.rb, line 70 def hostname @@hostname end
Accessor to the line the log event occured
# File lib/yell/event.rb, line 95 def line @line || (backtrace!; @line) end
Accessor to the method the log event occured
# File lib/yell/event.rb, line 100 def method @method || (backtrace!; @method) end
Accessor to the PID
# File lib/yell/event.rb, line 80 def pid Process.pid end
Accessor to the progname
# File lib/yell/event.rb, line 75 def progname @@progname end
Accessor to the thread's id
# File lib/yell/event.rb, line 85 def thread_id Thread.current.object_id end
# File lib/yell/event.rb, line 121 def backtrace! if m = CallerRegexp.match(@caller) @file, @line, @method = m[1..-1] else @file, @line, @method = ['', '', ''] end end
# File lib/yell/event.rb, line 117 def caller_index CallerIndex + @caller_offset end
# File lib/yell/event.rb, line 107 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