Class: Logging::LogEvent

Inherits:
Object show all
Defined in:
lib/gems/logging-0.9.4/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

Instance Attribute Summary collapse

Instance Method Summary collapse

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.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/gems/logging-0.9.4/lib/logging/log_event.rb', line 26

def initialize( logger, level, data, trace )
  @logger = logger
  @level = level
  @data = data
  @file = @line = @method = ''

  if trace
    t = Kernel.caller[2]
    return if t.nil?

    m = CALLER_RGXP.match(t)
    @file = m[1]
    @line = m[2]
    @method = m[3] unless m[3].nil?
  end
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



43
44
45
# File 'lib/gems/logging-0.9.4/lib/logging/log_event.rb', line 43

def data
  @data
end

#fileObject (readonly)

Returns the value of attribute file.



44
45
46
# File 'lib/gems/logging-0.9.4/lib/logging/log_event.rb', line 44

def file
  @file
end

#levelObject

Returns the value of attribute level.



43
44
45
# File 'lib/gems/logging-0.9.4/lib/logging/log_event.rb', line 43

def level
  @level
end

#lineObject (readonly)

Returns the value of attribute line.



44
45
46
# File 'lib/gems/logging-0.9.4/lib/logging/log_event.rb', line 44

def line
  @line
end

#loggerObject

Returns the value of attribute logger.



43
44
45
# File 'lib/gems/logging-0.9.4/lib/logging/log_event.rb', line 43

def logger
  @logger
end

#methodObject (readonly)

Returns the value of attribute method.



44
45
46
# File 'lib/gems/logging-0.9.4/lib/logging/log_event.rb', line 44

def method
  @method
end