Class: Yell::Event
- Inherits:
-
Object
- Object
- Yell::Event
- Defined in:
- lib/yell/event.rb
Constant Summary collapse
- @@caller_regexp =
regex to fetch caller attributes
/^(.+?):(\d+)(?::in `(.+)')?/
- @@caller_index =
jruby and rubinius seemsto have a different caller
1
- @@hostname =
Prefetch those values (no need to do that on every new instance)
Socket.gethostname rescue nil
- @@pid =
Process.pid
Instance Attribute Summary collapse
-
#level ⇒ Object
readonly
Accessor to the log level.
-
#message ⇒ Object
readonly
Accessor to the log message.
-
#thread_id ⇒ Object
readonly
Accessor to the current tread_id.
-
#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 pid.
-
#initialize(level, message = nil, &block) ⇒ 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 hostname.
Constructor Details
#initialize(level, message = nil, &block) ⇒ Event
Returns a new instance of Event.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/yell/event.rb', line 35 def initialize( level, = nil, &block ) @time = Time.now @level = level @message = block ? block.call : @thread_id = Thread.current.object_id @caller = caller[@@caller_index].to_s @file = nil @line = nil @method = nil end |
Instance Attribute Details
#level ⇒ Object (readonly)
Accessor to the log level
23 24 25 |
# File 'lib/yell/event.rb', line 23 def level @level end |
#message ⇒ Object (readonly)
Accessor to the log message
26 27 28 |
# File 'lib/yell/event.rb', line 26 def @message end |
#thread_id ⇒ Object (readonly)
Accessor to the current tread_id
32 33 34 |
# File 'lib/yell/event.rb', line 32 def thread_id @thread_id end |
#time ⇒ Object (readonly)
Accessor to the time the log event occured
29 30 31 |
# File 'lib/yell/event.rb', line 29 def time @time end |
Instance Method Details
#file ⇒ Object
Accessor to filename the log event occured
59 60 61 62 |
# File 'lib/yell/event.rb', line 59 def file _caller! if @file.nil? @file end |
#hostname ⇒ Object
Accessor to the pid
49 50 51 |
# File 'lib/yell/event.rb', line 49 def hostname @@hostname end |
#line ⇒ Object
Accessor to the line the log event occured
65 66 67 68 |
# File 'lib/yell/event.rb', line 65 def line _caller! if @line.nil? @line end |
#method ⇒ Object
Accessor to the method the log event occured
71 72 73 74 |
# File 'lib/yell/event.rb', line 71 def method _caller! if @method.nil? @method end |
#pid ⇒ Object
Accessor to the hostname
54 55 56 |
# File 'lib/yell/event.rb', line 54 def pid @@pid end |