Skip to content

Commit

Permalink
Merge pull request #92 from tilfin/fix/broadcast
Browse files Browse the repository at this point in the history
Fix broadcast
  • Loading branch information
tilfin authored Aug 29, 2019
2 parents a58469f + a10e188 commit ac10d1c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
3 changes: 2 additions & 1 deletion lib/ougai/formatters/readable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def initialize(app_name = nil, hostname = nil, opts = {})
load_dependent
end

def _call(severity, time, progname, data)
def _call(severity, time, progname, _data)
data = _data.dup
msg = data.delete(:msg)
level = @plain ? severity : colored_level(severity)
dt = format_datetime(time)
Expand Down
10 changes: 3 additions & 7 deletions lib/ougai/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ def inherited(subclass)
# @param logger [Logger] The logger receiving broadcast logs.
def self.broadcast(logger)
Module.new do |mdl|
Logger::Severity.constants.each do |severity|
method_name = severity.downcase.to_sym

mdl.send(:define_method, method_name) do |*args|
logger.send(method_name, *args)
super(*args)
end
define_method(:log) do |*args|
logger.log(*args)
super(*args)
end

define_method(:level=) do |level|
Expand Down
3 changes: 1 addition & 2 deletions lib/ougai/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ def weak_merge!(base_data, inferior_data)
end
end

private

# @private
def log(severity, message, ex, data, block)
return true if level > severity
args = block ? block.call : [message, ex, data]
Expand Down
2 changes: 1 addition & 1 deletion spec/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ def to_hash
end

it 'outputs info log with block on both loggers' do
logger.info(log_msg, foo: 2)
logger.info { [log_msg, { foo: 2 }] }
expect(item).to be_log_message(log_msg, 30)
expect(item).to include_data(foo: 2)
expect(another_item).to be_log_message(log_msg, 30)
Expand Down

0 comments on commit ac10d1c

Please sign in to comment.