Method: Logging::LogEvent#initialize
- Defined in:
- lib/logging/log_event.rb
#initialize(logger, level, data, caller_tracing) ⇒ LogEvent
call-seq:
LogEvent.new( logger, level, [data], caller_tracing )
Creates a new log event with the given logger name, numeric level, array of data from the user to be logged, and boolean caller_tracing flag. If the caller_tracing 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 44 45 46 47 48 49 |
# File 'lib/logging/log_event.rb', line 28 def initialize( logger, level, data, caller_tracing ) self.logger = logger self.level = level self.data = data self.time = Time.now.freeze if caller_tracing stack = Kernel.caller[CALLER_INDEX] return if stack.nil? match = CALLER_RGXP.match(stack) self.file = match[1] self.line = Integer(match[2]) self.method_name = match[3] unless match[3].nil? if (bp = ::Logging.basepath) && !bp.empty? && file.index(bp) == 0 self.file = file.slice(bp.length + 1, file.length - bp.length) end else self.file = self.line = self.method_name = '' end end |