diff options
author | Tim Smith <tsmith@chef.io> | 2019-08-07 09:49:52 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-07 09:49:52 -0700 |
commit | c7756710233ef80e383ecabef25074f5b7968544 (patch) | |
tree | e184ac80d8abb766fb817c023a64f32bb029c4c5 /lib/mixlib/log | |
parent | 51dcee25b0ae6e614e5ebbc42eca0e1e3041865b (diff) | |
parent | 76b305a788968538b5ce0c7223b8b0fe470f0c31 (diff) | |
download | mixlib-log-c7756710233ef80e383ecabef25074f5b7968544.tar.gz |
Merge pull request #56 from chef/bk_fixes
Add windows testing in Buildkite
Diffstat (limited to 'lib/mixlib/log')
-rw-r--r-- | lib/mixlib/log/child.rb | 4 | ||||
-rw-r--r-- | lib/mixlib/log/formatter.rb | 2 | ||||
-rw-r--r-- | lib/mixlib/log/logger.rb | 6 | ||||
-rw-r--r-- | lib/mixlib/log/logging.rb | 2 |
4 files changed, 8 insertions, 6 deletions
diff --git a/lib/mixlib/log/child.rb b/lib/mixlib/log/child.rb index 56376c5..2d7de00 100644 --- a/lib/mixlib/log/child.rb +++ b/lib/mixlib/log/child.rb @@ -36,14 +36,14 @@ module Mixlib # Note that we *only* query the default logger (@logger) and not any other # loggers that may have been added, even though it is possible to configure # two (or more) loggers at different log levels. - [:trace?, :debug?, :info?, :warn?, :error?, :fatal?].each do |method_name| + %i{trace? debug? info? warn? error? fatal?}.each do |method_name| define_method(method_name) do parent.send(method_name) end end def add(severity, message = nil, progname = nil, data: {}, &block) - data = metadata.merge(data) if data.kind_of?(Hash) + data = metadata.merge(data) if data.is_a?(Hash) parent.send(:pass, severity, message, progname, data: data, &block) end diff --git a/lib/mixlib/log/formatter.rb b/lib/mixlib/log/formatter.rb index 1727452..680836f 100644 --- a/lib/mixlib/log/formatter.rb +++ b/lib/mixlib/log/formatter.rb @@ -31,7 +31,7 @@ module Mixlib # Otherwise, doesn't print the time. def call(severity, time, progname, msg) if @@show_time - sprintf("[%s] %s: %s\n", time.iso8601(), severity, msg2str(msg)) + sprintf("[%s] %s: %s\n", time.iso8601, severity, msg2str(msg)) else sprintf("%s: %s\n", severity, msg2str(msg)) end diff --git a/lib/mixlib/log/logger.rb b/lib/mixlib/log/logger.rb index f227f23..e1f8929 100644 --- a/lib/mixlib/log/logger.rb +++ b/lib/mixlib/log/logger.rb @@ -45,14 +45,16 @@ module Mixlib def add_data(severity, message, progname, data: {}) return true if @logdev.nil? || severity < @level + data ||= {} - if message.kind_of?(::Exception) + if message.is_a?(::Exception) data[:err] = message else data[:msg] = message end @logdev.write( - format_message(to_label(severity), Time.now, progname, data)) + format_message(to_label(severity), Time.now, progname, data) + ) true end alias_method :add, :add_data diff --git a/lib/mixlib/log/logging.rb b/lib/mixlib/log/logging.rb index 524900b..5a7a076 100644 --- a/lib/mixlib/log/logging.rb +++ b/lib/mixlib/log/logging.rb @@ -41,7 +41,7 @@ module Mixlib # Define the standard logger methods on this class programmatically. # No need to incur method_missing overhead on every log call. - [:trace, :debug, :info, :warn, :error, :fatal].each do |method_name| + %i{trace debug info warn error fatal}.each do |method_name| level = LEVELS[method_name] define_method(method_name) do |msg = nil, data: {}, &block| pass(level, msg, data: data, &block) |