require 'json' class Object def to_semlogger [self.class.name.to_sym, self.respond_to?( :serializable_hash) ? self.serializable_hash : self ] end end class Exception def to_semlogger [:exception] + super end end class String def to_semlogger [:String, self] end end %w[Numeric FalseClass TrueClass NilClass].each do |cl| Object.const_get( cl).class_eval do def to_semlogger [:const, self] end end end class Semlogger < ::Logger class Base attr_accessor :logger def add severity, progname = nil, &block @logger.add severity, self, progname = nil, &block end ::Semlogger::Severity.constants.each do |severity| module_eval "def #{severity.downcase}( *a, &e) add #{::Semlogger::Severity.const_get severity}, *a, &e end", __FILE__, __LINE__ end end class CustomType < Base def initialize name, *obj @name, @obj = name.to_s.to_sym, obj end def to_semlogger [@name] + @obj end end attr_accessor :logdev, :level, :progname class <