Sha256: 0f1c58ad8bf5e960a8b8f4bc06dc32f4a23f46b3f46159002fc5df0d5cdd25fa

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 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, message, opts = {})
      return if (!message || (String === message && message.empty?)) && skip_empty
      return if level && severity < level
      return if ignore && ignore.any? { |pattern| message =~ pattern}

      message = Logster::Message.new(severity, progname, message, 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

      save message

      message
    end

    private

    def not_implemented
      raise "Not Implemented"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logster-0.1.1 lib/logster/base_store.rb