module Kitlog
Constants
- FORMATTERS
Public Class Methods
configure(destination: STDERR, format: nil)
click to toggle source
rubocop:disable Metrics/MethodLength
# File lib/kitlog.rb, line 26 def self.configure(destination: STDERR, format: nil) format ||= destination.isatty ? :logfmt : :json formatter = FORMATTERS.fetch(format) @logger = Logger.new(destination) @logger.formatter = proc do |_severity, datetime, _progname, payload| formatter.call( payload.merge( ts: datetime.strftime("%Y-%m-%dT%H:%M:%S.%NZ"), tid: Thread.current.object_id, ), ) + "\n" end end
log(**kwargs)
click to toggle source
# File lib/kitlog.rb, line 52 def self.log(**kwargs) @logger.info(kwargs) end
logger()
click to toggle source
# File lib/kitlog.rb, line 44 def self.logger @logger end
with(**context)
click to toggle source
# File lib/kitlog.rb, line 48 def self.with(**context) ContextualLogger.new(@logger, context) end
Public Instance Methods
log(**kwargs)
click to toggle source
# File lib/kitlog.rb, line 56 def log(**kwargs) @logger.info(kwargs) end