Sha256: 34522ffc86ff007dd83e24716cb9ed610ae1106ddefd135a4268c8e2c313677c
Contents?: true
Size: 768 Bytes
Versions: 4
Compression:
Stored size: 768 Bytes
Contents
module Insque class JsonLogger < ::Logger attr_accessor :additional_fields def initialize(logdev, level: INFO, sync: true, additional_fields: {}) super logdev self.level = level logdev.sync = sync if logdev.respond_to?(:sync=) @default_formatter = JsonFormatter.new @additional_fields = additional_fields end def format_message(severity, datetime, progname, msg) (@formatter || @default_formatter).call(severity, datetime, progname, msg: msg, additional_fields: additional_fields) end private # Severity label for logging (max 5 chars). SEV_LABEL = %w(debug info warn error fatal any).each(&:freeze).freeze def format_severity(severity) SEV_LABEL[severity] || 'any' end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
insque-0.7.4 | lib/insque/json_logger.rb |
insque-0.7.3 | lib/insque/json_logger.rb |
insque-0.7.2 | lib/insque/json_logger.rb |
insque-0.7.1 | lib/insque/json_logger.rb |