Sha256: bd10a4ae3bc8209357650ff03a2221385dca0a153258c710e2563f8dc350a6de
Contents?: true
Size: 956 Bytes
Versions: 1
Compression:
Stored size: 956 Bytes
Contents
require 'logger' require 'json' require 'time' require File.expand_path('../common', __FILE__) require File.expand_path('../common_json', __FILE__) module Ruby module JSONFormatter class Base < ::Logger::Formatter include Logifyer::Common include Logifyer::Common::JSON ANSI_ESCAPE_REGEX = /\e\[(?:\d+;\d+;?\d*|[\d\w])m/.freeze def initialize(app = nil, ext = {}) @app = app @ext = ext.is_a?(Hash) ? ext : {ext_info: ext.inspect} @config = { level: :log_level, app: :application, timestamp: :timestamp } yield @config if block_given? end def call(severity, time, progname, message) cleaned_message = strip_ansi_escape_codes(message) @event = build_event(cleaned_message, severity, time) end private def strip_ansi_escape_codes(text) text.gsub(ANSI_ESCAPE_REGEX, '') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
logifyer-0.1.0 | lib/logifyer/json_logifyer.rb |