Sha256: 8c6f8b4fe67e6303e8fd97f780cf5e585ec80d74f2a16f1c8d1b9c1ce479d869
Contents?: true
Size: 1.23 KB
Versions: 5
Compression:
Stored size: 1.23 KB
Contents
require "logger" module Boty module Logger attr_writer :logger def self.adapter=(adapter) @adapter = adapter end def self.adapter @adapter ||= ::Logger.new(STDOUT).tap { |logger| logger.level = ::Logger::DEBUG } end def logger Logger.adapter end def log_error(error, message) logger.error do "#{message}\n#{error.message}" end logger.debug do error.backtrace.reduce("") { |a, e| a << "#{e}\n" } end end class Multi < ::Logger def initialize(adapters) @adapters = adapters end def level=(level) @adapters.each do |adapter| adapter.level = level end end def add(*args, &block) @adapters.each do |adapter| adapter.add(*args, &block) end end end class Memory < ::Logger attr_reader :logs def initialize(*) @logs = [] end def add(*args, &block) @logs << if block_given? block.call else args[2] end end end class Null < ::Logger def initialize(*); end def add(*, &block); end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
boty-1.0.1 | lib/boty/logger.rb |
boty-1.0.0 | lib/boty/logger.rb |
boty-0.2.0 | lib/boty/logger.rb |
boty-0.1.2 | lib/boty/logger.rb |
boty-0.1.1 | lib/boty/logger.rb |