diff options
Diffstat (limited to 'lib/chef/log/formatter.rb')
-rw-r--r-- | lib/chef/log/formatter.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/chef/log/formatter.rb b/lib/chef/log/formatter.rb index d177060d97..1c7044bdb1 100644 --- a/lib/chef/log/formatter.rb +++ b/lib/chef/log/formatter.rb @@ -28,9 +28,20 @@ require 'time' class Chef class Log class Formatter < Logger::Formatter - # Prints a log message as '[time] severity: message' + @@show_time = true + + def self.show_time=(show=false) + @@show_time = show + end + + # Prints a log message as '[time] severity: message' if Chef::Log::Formatter.show_time == true. + # Otherwise, doesn't print the time. def call(severity, time, progname, msg) - sprintf("[%s] %s: %s\n", time.rfc2822(), severity, msg2str(msg)) + if @@show_time + sprintf("[%s] %s: %s\n", time.rfc2822(), severity, msg2str(msg)) + else + sprintf("%s: %s\n", severity, msg2str(msg)) + end end # Converts some argument to a Logger.severity() call to a string. Regular strings pass through like |