Class: Logging::LogEvent
- Inherits:
-
Object
- Object
- 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 =
RUBY_PLATFORM[%r/^java/i] ? 1 : 2
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#level ⇒ Object
Returns the value of attribute level.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
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.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/logging/log_event.rb', line 28 def initialize( logger, level, data, trace ) @logger = logger @level = level @data = data @file = @line = @method = '' if trace t = Kernel.caller[CALLER_INDEX] return if t.nil? m = CALLER_RGXP.match(t) @file = m[1] @line = Integer(m[2]) @method = m[3] unless m[3].nil? end end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
45 46 47 |
# File 'lib/logging/log_event.rb', line 45 def data @data end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
46 47 48 |
# File 'lib/logging/log_event.rb', line 46 def file @file end |
#level ⇒ Object
Returns the value of attribute level.
45 46 47 |
# File 'lib/logging/log_event.rb', line 45 def level @level end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
46 47 48 |
# File 'lib/logging/log_event.rb', line 46 def line @line end |
#logger ⇒ Object
Returns the value of attribute logger.
45 46 47 |
# File 'lib/logging/log_event.rb', line 45 def logger @logger end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
46 47 48 |
# File 'lib/logging/log_event.rb', line 46 def method @method end |