* lib/logger.rb: Updated typos and output to match modern Logger

output.  Patch by Marcus Stollsteimer.  [Bug #6738]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2012-07-18 00:27:04 +00:00
parent 08f46f0818
commit fe6aa0e16a
2 changed files with 58 additions and 51 deletions

View File

@ -1,3 +1,8 @@
Wed Jul 18 09:26:45 2012 Eric Hodel <drbrain@segment7.net>
* lib/logger.rb: Updated typos and output to match modern Logger
output. Patch by Marcus Stollsteimer. [Bug #6738]
Wed Jul 18 07:59:29 2012 Takeyuki FUJIOKA <xibbar@ruby-lang.org> Wed Jul 18 07:59:29 2012 Takeyuki FUJIOKA <xibbar@ruby-lang.org>
* lib/cgi/util.rb (CGI.escapeHTML,unescapeHTML): Add &apos; for HTML5 escaping. * lib/cgi/util.rb (CGI.escapeHTML,unescapeHTML): Add &apos; for HTML5 escaping.

View File

@ -18,18 +18,19 @@ require 'monitor'
# #
# The messages have associated levels, such as +INFO+ or +ERROR+ that indicate # The messages have associated levels, such as +INFO+ or +ERROR+ that indicate
# their importance. You can then give the Logger a level, and only messages # their importance. You can then give the Logger a level, and only messages
# at that level of higher will be printed. # at that level or higher will be printed.
# #
# The levels are: # The levels are:
# #
# +FATAL+:: an unhandleable error that results in a program crash # +UNKNOWN+:: An unknown message that should always be logged.
# +ERROR+:: a handleable error condition # +FATAL+:: An unhandleable error that results in a program crash.
# +WARN+:: a warning # +ERROR+:: A handleable error condition.
# +INFO+:: generic (useful) information about system operation # +WARN+:: A warning.
# +DEBUG+:: low-level information for developers # +INFO+:: Generic (useful) information about system operation.
# +DEBUG+:: Low-level information for developers.
# #
# For instance, in a production system, you may have your Logger set to # For instance, in a production system, you may have your Logger set to
# +INFO+ or even +WARN+ # +INFO+ or even +WARN+.
# When you are developing the system, however, you probably # When you are developing the system, however, you probably
# want to know about the program's internal state, and would set the Logger to # want to know about the program's internal state, and would set the Logger to
# +DEBUG+. # +DEBUG+.
@ -51,7 +52,10 @@ require 'monitor'
# #
# === Example # === Example
# #
# This creates a logger to the standard output stream, with a level of +WARN+ # This creates a Logger that outputs to the standard output stream, with a
# level of +WARN+:
#
# require 'logger'
# #
# log = Logger.new(STDOUT) # log = Logger.new(STDOUT)
# log.level = Logger::WARN # log.level = Logger::WARN
@ -102,16 +106,16 @@ require 'monitor'
# 3. Create a logger for the specified file. # 3. Create a logger for the specified file.
# #
# file = File.open('foo.log', File::WRONLY | File::APPEND) # file = File.open('foo.log', File::WRONLY | File::APPEND)
# # To create new (and to remove old) logfile, add File::CREAT like; # # To create new (and to remove old) logfile, add File::CREAT like:
# # file = open('foo.log', File::WRONLY | File::APPEND | File::CREAT) # # file = File.open('foo.log', File::WRONLY | File::APPEND | File::CREAT)
# logger = Logger.new(file) # logger = Logger.new(file)
# #
# 4. Create a logger which ages logfile once it reaches a certain size. Leave # 4. Create a logger which ages the logfile once it reaches a certain size.
# 10 "old log files" and each file is about 1,024,000 bytes. # Leave 10 "old" log files where each file is about 1,024,000 bytes.
# #
# logger = Logger.new('foo.log', 10, 1024000) # logger = Logger.new('foo.log', 10, 1024000)
# #
# 5. Create a logger which ages logfile daily/weekly/monthly. # 5. Create a logger which ages the logfile daily/weekly/monthly.
# #
# logger = Logger.new('foo.log', 'daily') # logger = Logger.new('foo.log', 'daily')
# logger = Logger.new('foo.log', 'weekly') # logger = Logger.new('foo.log', 'weekly')
@ -124,13 +128,13 @@ require 'monitor'
# +debug+. +add+ is used below to log a message of an arbitrary (perhaps # +debug+. +add+ is used below to log a message of an arbitrary (perhaps
# dynamic) level. # dynamic) level.
# #
# 1. Message in block. # 1. Message in a block.
# #
# logger.fatal { "Argument 'foo' not given." } # logger.fatal { "Argument 'foo' not given." }
# #
# 2. Message as a string. # 2. Message as a string.
# #
# logger.error "Argument #{ @foo } mismatch." # logger.error "Argument #{@foo} mismatch."
# #
# 3. With progname. # 3. With progname.
# #
@ -168,8 +172,7 @@ require 'monitor'
# #
# logger.level = Logger::INFO # logger.level = Logger::INFO
# #
# DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN # # DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN
#
# #
# == Format # == Format
# #
@ -177,22 +180,22 @@ require 'monitor'
# default. The default format and a sample are shown below: # default. The default format and a sample are shown below:
# #
# Log format: # Log format:
# SeverityID, [Date Time mSec #pid] SeverityLabel -- ProgName: message # SeverityID, [DateTime #pid] SeverityLabel -- ProgName: message
# #
# Log sample: # Log sample:
# I, [Wed Mar 03 02:34:24 JST 1999 895701 #19074] INFO -- Main: info. # I, [1999-03-03T02:34:24.895701 #19074] INFO -- Main: info.
# #
# You may change the date and time format via #datetime_format= # You may change the date and time format via #datetime_format=.
# #
# logger.datetime_format = "%Y-%m-%d %H:%M:%S" # logger.datetime_format = '%Y-%m-%d %H:%M:%S'
# # e.g. "2004-01-03 00:54:26" # # e.g. "2004-01-03 00:54:26"
# #
# Or, you may change the overall format with #formatter= method. # Or, you may change the overall format via the #formatter= method.
# #
# logger.formatter = proc do |severity, datetime, progname, msg| # logger.formatter = proc do |severity, datetime, progname, msg|
# "#{datetime}: #{msg}\n" # "#{datetime}: #{msg}\n"
# end # end
# # e.g. "Thu Sep 22 08:51:08 GMT+9:00 2005: hello world" # # e.g. "2005-09-22 08:51:08 +0900: hello world"
# #
class Logger class Logger
VERSION = "1.2.7" VERSION = "1.2.7"
@ -213,17 +216,17 @@ class Logger
# Logging severity. # Logging severity.
module Severity module Severity
# Low-level information, mostly for developers # Low-level information, mostly for developers.
DEBUG = 0 DEBUG = 0
# generic, useful information about system operation # Generic (useful) information about system operation.
INFO = 1 INFO = 1
# a warning # A warning.
WARN = 2 WARN = 2
# a handleable error condition # A handleable error condition.
ERROR = 3 ERROR = 3
# an unhandleable error that results in a program crash # An unhandleable error that results in a program crash.
FATAL = 4 FATAL = 4
# an unknown message that should always be logged # An unknown message that should always be logged.
UNKNOWN = 5 UNKNOWN = 5
end end
include Severity include Severity
@ -231,7 +234,7 @@ class Logger
# Logging severity threshold (e.g. <tt>Logger::INFO</tt>). # Logging severity threshold (e.g. <tt>Logger::INFO</tt>).
attr_accessor :level attr_accessor :level
# program name to include in log messages. # Program name to include in log messages.
attr_accessor :progname attr_accessor :progname
# Set date-time format. # Set date-time format.
@ -249,9 +252,9 @@ class Logger
# Logging formatter, as a +Proc+ that will take four arguments and # Logging formatter, as a +Proc+ that will take four arguments and
# return the formatted message. The arguments are: # return the formatted message. The arguments are:
# #
# +severity+:: The Severity of the log message # +severity+:: The Severity of the log message.
# +time+:: A Time instance representing when the message was logged # +time+:: A Time instance representing when the message was logged.
# +progname+:: The #progname configured, or passed to the logger method # +progname+:: The #progname configured, or passed to the logger method.
# +msg+:: The _Object_ the user passed to the log message; not necessarily a # +msg+:: The _Object_ the user passed to the log message; not necessarily a
# String. # String.
# #
@ -338,8 +341,8 @@ class Logger
# #
# +true+ if successful, +false+ otherwise. # +true+ if successful, +false+ otherwise.
# #
# When the given severity is not high enough (for this particular logger), log # When the given severity is not high enough (for this particular logger),
# no message, and return +true+. # log no message, and return +true+.
# #
# === Description # === Description
# #
@ -358,7 +361,7 @@ class Logger
# #
# * Logfile is not locked. # * Logfile is not locked.
# * Append open does not need to lock file. # * Append open does not need to lock file.
# * If the OS which supports multi I/O, records possibly be mixed. # * If the OS supports multi I/O, records possibly may be mixed.
# #
def add(severity, message = nil, progname = nil, &block) def add(severity, message = nil, progname = nil, &block)
severity ||= UNKNOWN severity ||= UNKNOWN
@ -402,18 +405,17 @@ class Logger
# #
# :call-seq: # :call-seq:
# info(message) # info(message)
# info(progname,&block) # info(progname, &block)
# #
# Log an +INFO+ message. # Log an +INFO+ message.
# #
# +message+:: the message to log; does not need to be a String # +message+:: The message to log; does not need to be a String.
# +progname+:: in the block form, this is the #progname to use in the # +progname+:: In the block form, this is the #progname to use in the
# the log message. The default can be set with #progname= # log message. The default can be set with #progname=.
# <tt>&block</tt>:: evaluates to the message to log. This is not evaluated # +block+:: Evaluates to the message to log. This is not evaluated unless
# unless the logger's level is sufficient # the logger's level is sufficient to log the message. This
# to log the message. This allows you to create # allows you to create potentially expensive logging messages that
# potentially expensive logging messages that are # are only called when the logger is configured to show them.
# only called when the logger is configured to show them.
# #
# === Examples # === Examples
# #
@ -463,7 +465,7 @@ class Logger
# #
# Log an +UNKNOWN+ message. This will be printed no matter what the logger's # Log an +UNKNOWN+ message. This will be printed no matter what the logger's
# level. # level is.
# #
# See #info for more information. # See #info for more information.
# #
@ -480,7 +482,7 @@ class Logger
private private
# Severity label for logging. (max 5 char) # Severity label for logging (max 5 chars).
SEV_LABEL = %w(DEBUG INFO WARN ERROR FATAL ANY) SEV_LABEL = %w(DEBUG INFO WARN ERROR FATAL ANY)
def format_severity(severity) def format_severity(severity)
@ -492,7 +494,7 @@ private
end end
# Default formatter for log messages # Default formatter for log messages.
class Formatter class Formatter
Format = "%s, [%s#%d] %5s -- %s: %s\n" Format = "%s, [%s#%d] %5s -- %s: %s\n"
@ -678,13 +680,13 @@ private
# #
# == Description # == Description
# #
# Application -- Add logging support to your application. # Application --- Add logging support to your application.
# #
# == Usage # == Usage
# #
# 1. Define your application class as a sub-class of this class. # 1. Define your application class as a sub-class of this class.
# 2. Override 'run' method in your class to do many things. # 2. Override the +run+ method in your class to do many things.
# 3. Instantiate it and invoke 'start'. # 3. Instantiate it and invoke #start.
# #
# == Example # == Example
# #