Sha256: 514b2f2814d936ff057de139e15b59a619e04376bd5d7059312359c92a192307

Contents?: true

Size: 1.23 KB

Versions: 16

Compression:

Stored size: 1.23 KB

Contents

module Logging

  # This class defines a logging event.
  #
  class LogEvent

    # :stopdoc:

    # Regular expression used to parse out caller information
    #
    # * $1 == filename
    # * $2 == line number
    # * $3 == method name (might be nil)
    CALLER_RGXP = %r/([\.\/\(\)\w]+):(\d+)(?::in `(\w+)')?/o

    CALLER_INDEX = RUBY_PLATFORM[%r/^java/i] ? 1 : 2
    # :startdoc:

    # 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.
    #
    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

    attr_accessor :logger, :level, :data
    attr_reader :file, :line, :method

  end  # class LogEvent
end  # module Logging

# EOF

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
TwP-logging-0.9.8.1 lib/logging/log_event.rb
TwP-logging-0.9.8.2 lib/logging/log_event.rb
TwP-logging-1.0.0 lib/logging/log_event.rb
TwP-logging-1.1.0 lib/logging/log_event.rb
TwP-logging-1.1.1 lib/logging/log_event.rb
TwP-logging-1.1.2 lib/logging/log_event.rb
TwP-logging-1.1.3 lib/logging/log_event.rb
TwP-logging-1.1.4 lib/logging/log_event.rb
pjstadig-logging-1.1.4.1 lib/logging/log_event.rb
pjstadig-logging-1.1.4.2 lib/logging/log_event.rb
logging-1.1.1 lib/logging/log_event.rb
logging-1.1.0 lib/logging/log_event.rb
logging-1.0.0 lib/logging/log_event.rb
logging-1.1.4 lib/logging/log_event.rb
logging-1.1.3 lib/logging/log_event.rb
logging-1.1.2 lib/logging/log_event.rb