Project

General

Profile

Bug #6759 ยป lib_logger_rdoc_improve_example.patch

stomar (Marcus Stollsteimer), 07/20/2012 09:10 PM

View differences:

logger.rb (Arbeitskopie)
57 57
#
58 58
#   require 'logger'
59 59
#
60
#   log = Logger.new(STDOUT)
61
#   log.level = Logger::WARN
60
#   logger = Logger.new(STDOUT)
61
#   logger.level = Logger::WARN
62 62
#
63
#   log.debug("Created logger")
64
#   log.info("Program started")
65
#   log.warn("Nothing to do!")
63
#   logger.debug("Created logger")
64
#   logger.info("Program started")
65
#   logger.warn("Nothing to do!")
66 66
#
67
#   path = 'a_non_existent_file'
68
#
67 69
#   begin
68
#     File.each_line(path) do |line|
70
#     File.foreach(path) do |line|
69 71
#       unless line =~ /^(\w+) = (.*)$/
70
#         log.error("Line in wrong format: #{line}")
72
#         logger.error("Line in wrong format: #{line.chomp}")
71 73
#       end
72 74
#     end
73 75
#   rescue => err
74
#     log.fatal("Caught exception; exiting")
75
#     log.fatal(err)
76
#     logger.fatal("Caught exception; exiting")
77
#     logger.fatal(err)
76 78
#   end
77 79
#
78 80
# Because the Logger's level is set to +WARN+, only the warning, error, and