Sha256: 79ea9e612ed636182305e3564a4ddd11ac7c57ebd914531198e8a078256ae462

Contents?: true

Size: 1.33 KB

Versions: 10

Compression:

Stored size: 1.33 KB

Contents

module Logging

  # This class defines a logging event.
  #
  LogEvent = Struct.new( :logger, :level, :data, :time, :file, :line, :method ) {
    # :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 `([^']+)')?/o
    #CALLER_INDEX = 2
    CALLER_INDEX = ((defined? JRUBY_VERSION and JRUBY_VERSION > '1.6') or (defined? RUBY_ENGINE and RUBY_ENGINE[%r/^rbx/i])) ? 1 : 2
    # :startdoc:

    # 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.
    #
    def initialize( logger, level, data, caller_tracing )
      f = l = m = ''

      if caller_tracing
        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
  }
end  # module Logging

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/logging-2.1.0/lib/logging/log_event.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/gems/logging-2.1.0/lib/logging/log_event.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/gems/logging-2.1.0/lib/logging/log_event.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/gems/logging-2.1.0/lib/logging/log_event.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/gems/logging-2.1.0/lib/logging/log_event.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/logging-2.1.0/lib/logging/log_event.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/logging-2.1.0/lib/logging/log_event.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/logging-2.1.0/lib/logging/log_event.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/logging-2.1.0/lib/logging/log_event.rb
logging-2.1.0 lib/logging/log_event.rb