Class: Logging::LogEvent
- Inherits:
-
Struct
- Object
- Struct
- Logging::LogEvent
- Defined in:
- lib/logging/log_event.rb
Overview
This class defines a logging event.
Constant Summary collapse
- CALLER_RGXP =
Regular expression used to parse out caller information
-
$1 == filename
-
$2 == line number
-
$3 == method name (might be nil)
-
%r/([-\.\/\(\)\w]+):(\d+)(?::in `(\w+)')?/o
- CALLER_INDEX =
CALLER_INDEX = 2
((defined? JRUBY_VERSION and JRUBY_VERSION[%r/^1.6/]) or (defined? RUBY_ENGINE and RUBY_ENGINE[%r/^rbx/i])) ? 1 : 2
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#file ⇒ Object
Returns the value of attribute file.
-
#level ⇒ Object
Returns the value of attribute level.
-
#line ⇒ Object
Returns the value of attribute line.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#method ⇒ Object
Returns the value of attribute method.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
-
#initialize(logger, level, data, trace) ⇒ LogEvent
constructor
call-seq: LogEvent.new( logger, level, [data], trace ).
Constructor Details
#initialize(logger, level, data, trace) ⇒ LogEvent
call-seq:
LogEvent.new( logger, level, [data], trace )
Creates a new log event with the given logger name, numeric level, array of data from the user to be logged, and boolean trace flag. If the trace flag is set to true
then Kernel::caller will be invoked to get the execution trace of the logging method.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/logging/log_event.rb', line 27 def initialize( logger, level, data, trace ) f = l = m = '' if trace stack = Kernel.caller[CALLER_INDEX] return if stack.nil? match = CALLER_RGXP.match(stack) f = match[1] l = Integer(match[2]) m = match[3] unless match[3].nil? end super(logger, level, data, Time.now, f, l, m) end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data
6 7 8 |
# File 'lib/logging/log_event.rb', line 6 def data @data end |
#file ⇒ Object
Returns the value of attribute file
6 7 8 |
# File 'lib/logging/log_event.rb', line 6 def file @file end |
#level ⇒ Object
Returns the value of attribute level
6 7 8 |
# File 'lib/logging/log_event.rb', line 6 def level @level end |
#line ⇒ Object
Returns the value of attribute line
6 7 8 |
# File 'lib/logging/log_event.rb', line 6 def line @line end |
#logger ⇒ Object
Returns the value of attribute logger
6 7 8 |
# File 'lib/logging/log_event.rb', line 6 def logger @logger end |
#method ⇒ Object
Returns the value of attribute method
6 7 8 |
# File 'lib/logging/log_event.rb', line 6 def method @method end |
#time ⇒ Object
Returns the value of attribute time
6 7 8 |
# File 'lib/logging/log_event.rb', line 6 def time @time end |