summaryrefslogtreecommitdiff
path: root/sample/logger/log.rb
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-18 06:31:25 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-18 06:31:25 +0000
commit9c219837b3b275fdd2cba39d23050ecfe1c38e97 (patch)
tree461e98568e32b6bbd39ba683620f976c5def73d3 /sample/logger/log.rb
parentea2e8d3592aa35148da0c28f99d6a74855c5b585 (diff)
* lib/logger.rb: new file. Logger, formerly called devel-logger or
Devel::Logger. * sample/logger/*: new file. samples of logger.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/logger/log.rb')
-rw-r--r--sample/logger/log.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/sample/logger/log.rb b/sample/logger/log.rb
new file mode 100644
index 0000000..aab80e4
--- /dev/null
+++ b/sample/logger/log.rb
@@ -0,0 +1,27 @@
+#!/usr/bin/env ruby
+
+require 'logger'
+
+log = Logger.new(STDERR)
+
+def do_log(log)
+ log.debug('do_log1') { "debug" }
+ log.info('do_log2') { "info" }
+ log.warn('do_log3') { "warn" }
+ log.error('do_log4') { "error" }
+ log.fatal('do_log6') { "fatal" }
+ log.unknown('do_log7') { "unknown" }
+end
+
+log.level = Logger::DEBUG # Default.
+do_log(log)
+
+puts "Set severity threshold 'WARN'."
+
+log.level = Logger::WARN
+do_log(log)
+
+puts "Change datetime format. Thanks to Daniel Berger."
+
+log.datetime_format = "%d-%b-%Y@%H:%M:%S"
+do_log(log)