summaryrefslogtreecommitdiff
path: root/lib/chef/log
diff options
context:
space:
mode:
authorAdam Jacob <adam@hjksolutions.com>2008-04-27 22:44:28 -0700
committerAdam Jacob <adam@hjksolutions.com>2008-04-27 22:44:28 -0700
commitbab9b3459fe41849970e50cb9b96ea62370fbad0 (patch)
treec685354e2798bf08905dca308f9c58a52b94e33a /lib/chef/log
parent39c0a0994cb5af59e4fbb9fefbc487f6bc21d2fb (diff)
downloadchef-bab9b3459fe41849970e50cb9b96ea62370fbad0.tar.gz
chef compiles
Diffstat (limited to 'lib/chef/log')
-rw-r--r--lib/chef/log/formatter.rb15
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