lib/logspot.rb in logspot-0.6.2 vs lib/logspot.rb in logspot-0.6.3
- old
+ new
@@ -2,12 +2,12 @@
class LoGspot
LOG_LEVELS = %w(DEBUG INFO WARN ERROR FATAL)
def initialize(file_or_file_name = STDOUT, wrapper: nil, tag_format: '[%{time} %{level}] ', time_format: '%Y/%m/%d %H:%M:%S', tag_block: nil)
- wrapper = ->(output, data) {
- base = tag_block ? tag_block.(Time.current, level) : tag_format % { time: Time.current.strftime(time_format), level: level }
+ wrapper ||= ->(output, data) {
+ base = tag_block ? tag_block.(Time.current, data[:level]) : tag_format % { time: Time.current.strftime(time_format), level: data[:level] }
if data[:space]
base = ' ' * uncolorize_str(base).length
end
output.puts(message: "#{base}#{data[:message]}")
}
@@ -104,11 +104,10 @@
private
attr_reader :raw_output, :top_output, :output, :level
def write(l, *args, &block)
- @level = l
- output.puts(message: args[0], args: args, arg_block: block)
+ output.puts(level: l, message: args[0], args: args, arg_block: block)
end
def wrap_output(block, *args, &wrapper)
previous_output, @output = output, Output::Wrap.new(wrapper, output)
res = block.call(*args)