Sha256: 2d3c3c812d5e30ad3a50fbf675a6a3f9b957a1dda604932e68fff21fa9c33962

Contents?: true

Size: 1.47 KB

Versions: 9

Compression:

Stored size: 1.47 KB

Contents

module Logster
  class BaseStore

    attr_accessor :level, :max_retention, :skip_empty, :ignore

    def initialize
      @dedup = false
      @max_retention = 60 * 60 * 24 * 7
      @skip_empty = true
    end

    def save(message)
      not_implemented
    end

    def count
      not_implemented
    end

    def clear
      not_implemented
    end

    def clear_all
      not_implemented
    end

    def get(message_key)
      not_implemented
    end

    def protect(message_key)
      not_implemented
    end

    def unprotect(message_key)
      not_implemented
    end

    def report(severity, progname, msg, opts = {})
      return if (!msg || (String === msg && msg.empty?)) && skip_empty
      return if level && severity < level

      message = Logster::Message.new(severity, progname, msg, opts[:timestamp])

      env = opts[:env]
      backtrace = opts[:backtrace]

      if env
        if env[:backtrace]
          # Special - passing backtrace through env
          backtrace = env.delete(:backtrace)
        end

        message.populate_from_env(env)
      end

      if backtrace
        if backtrace.respond_to? :join
          backtrace = backtrace.join("\n")
        end
        message.backtrace = backtrace
      else
        message.backtrace = caller.join("\n")
      end

      return if ignore && ignore.any? { |pattern| message =~ pattern}

      save message

      message
    end

    private

    def not_implemented
      raise "Not Implemented"
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
logster-0.8.1 lib/logster/base_store.rb
logster-0.8.0 lib/logster/base_store.rb
logster-0.1.8 lib/logster/base_store.rb
logster-0.1.7 lib/logster/base_store.rb
logster-0.1.6 lib/logster/base_store.rb
logster-0.1.5 lib/logster/base_store.rb
logster-0.1.4 lib/logster/base_store.rb
logster-0.1.3 lib/logster/base_store.rb
logster-0.1.2 lib/logster/base_store.rb