Class: Yell::Event
- Inherits:
-
Object
- Object
- Yell::Event
- Defined in:
- lib/yell/event.rb
Overview
Yell::Event.new( :info, ‘Hello World’, { :scope => ‘Application’ } ) #=> Hello World scope: Application
Defined Under Namespace
Classes: Options
Constant Summary collapse
- CallerRegexp =
regex to fetch caller attributes
/^(.+?):(\d+)(?::in `(.+)')?/
- CallerIndex =
jruby and rubinius seem to have a different caller
defined?(RUBY_ENGINE) && ["rbx", "jruby"].include?(RUBY_ENGINE) ? 1 : 2
- @@hostname =
Prefetch those values (no need to do that on every new instance)
Socket.gethostname rescue nil
- @@progname =
$0
Instance Attribute Summary collapse
-
#level ⇒ Object
readonly
Accessor to the log level.
-
#messages ⇒ Object
readonly
Accessor to the log message.
-
#name ⇒ Object
readonly
Accessor to the logger’s name.
-
#time ⇒ Object
readonly
Accessor to the time the log event occured.
Instance Method Summary collapse
-
#file ⇒ Object
Accessor to filename the log event occured.
-
#hostname ⇒ Object
Accessor to the hostname.
-
#initialize(logger, options, *messages) ⇒ Event
constructor
A new instance of Event.
-
#line ⇒ Object
Accessor to the line the log event occured.
-
#method ⇒ Object
Accessor to the method the log event occured.
-
#pid ⇒ Object
Accessor to the PID.
-
#progname ⇒ Object
Accessor to the progname.
-
#thread_id ⇒ Object
Accessor to the thread’s id.
Constructor Details
#initialize(logger, options, *messages) ⇒ Event
Returns a new instance of Event.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/yell/event.rb', line 54 def initialize( logger, , *) @time = Time.now @name = logger.name extract!() @messages = @caller = logger.trace.at?(level) ? caller[caller_index].to_s : '' @file = nil @line = nil @method = nil @pid = nil end |
Instance Attribute Details
#level ⇒ Object (readonly)
Accessor to the log level
42 43 44 |
# File 'lib/yell/event.rb', line 42 def level @level end |
#messages ⇒ Object (readonly)
Accessor to the log message
45 46 47 |
# File 'lib/yell/event.rb', line 45 def @messages end |
#name ⇒ Object (readonly)
Accessor to the logger’s name
51 52 53 |
# File 'lib/yell/event.rb', line 51 def name @name end |
#time ⇒ Object (readonly)
Accessor to the time the log event occured
48 49 50 |
# File 'lib/yell/event.rb', line 48 def time @time end |
Instance Method Details
#file ⇒ Object
Accessor to filename the log event occured
91 92 93 |
# File 'lib/yell/event.rb', line 91 def file @file || (backtrace!; @file) end |
#hostname ⇒ Object
Accessor to the hostname
71 72 73 |
# File 'lib/yell/event.rb', line 71 def hostname @@hostname end |
#line ⇒ Object
Accessor to the line the log event occured
96 97 98 |
# File 'lib/yell/event.rb', line 96 def line @line || (backtrace!; @line) end |
#method ⇒ Object
Accessor to the method the log event occured
101 102 103 |
# File 'lib/yell/event.rb', line 101 def method @method || (backtrace!; @method) end |
#pid ⇒ Object
Accessor to the PID
81 82 83 |
# File 'lib/yell/event.rb', line 81 def pid Process.pid end |
#progname ⇒ Object
Accessor to the progname
76 77 78 |
# File 'lib/yell/event.rb', line 76 def progname @@progname end |
#thread_id ⇒ Object
Accessor to the thread’s id
86 87 88 |
# File 'lib/yell/event.rb', line 86 def thread_id Thread.current.object_id end |