1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/sample/logger/log.rb
nahi 9c219837b3 * 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
2003-09-18 06:31:25 +00:00

27 lines
535 B
Ruby

#!/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)