lib/boty/logger.rb in boty-0.0.17.1 vs lib/boty/logger.rb in boty-0.1.0
- old
+ new
@@ -15,23 +15,40 @@
def logger
Logger.adapter
end
- def log_level(level)
- logger.level = level
+ 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(*args)
@logs = []
end
def add(*args, &block)
- _, _, message = args
- @logs << message
+ @logs << if block_given?
+ block.call
+ else
+ args[2]
+ end
end
end
class Null < ::Logger
def initialize(*args); end