<NME> colorization.rb
<BEF> # :stopdoc:
#
# The Pattern layout can colorize log events based on a provided color scheme.
# The configuration is a two part process. First the color scheme is defined
# with the level colors and any pattern token colors. This color scheme is
# then passed by name to the Pattern layout when it is created.
#
# The color scheme defines colors to be applied to the level token found in
# the pattern layout. So that the "info" level will have one color, and the
# "fatal" level will have a separate color. This applies only to the level
# token in the Pattern layout.
#
# Common tokens can have their own color, too. The date token can be colored
# blue, and the message token can be colored magenta.
#
# Colorization should only be applied to TTY logging destinations like STDOUT
# and STDERR. Inserting color codes into a log file is generally considered
# bad from; these color codes cause issues for some command lien programs like
# "less" and "more".
#
# A 'default" color scheme is provided with the Logging framework. In the
# example below we create our own color scheme called 'bright' and apply it to
# the 'stdout' appender.
#

  require 'logging'

  # here we setup a color scheme called 'bright'
  Logging.color_scheme( 'bright',
    :levels => {
      :info  => :green,
      :warn  => :yellow,
      :error => :red,
      :fatal => [:white, :on_red]
    },
    :date => :blue,
    :logger => :cyan,
    :message => :magenta
  )

  Logging.appenders.stdout(
    'stdout',
    :layout => Logging.layouts.pattern(
      :pattern => '[%d] %-5l %c: %m\n',
      :color_scheme => 'bright'
    )
  )

  log = Logging.logger['Happy::Colors']
  log.add_appenders 'stdout'
  log.level = :debug

  # these log messages will be nicely colored
  # the level will be colored differently for each message
  #
  log.debug "a very nice little debug message"
  log.info "things are operating nominally"
  log.warn "this is your last warning"
  log.error StandardError.new("something went horribly wrong")
  log.fatal "I Die!"

# :startdoc:

<MSG> Correct spelling errors in colorization.rb example
<DFF> @@ -15,7 +15,7 @@
 #
 # Colorization should only be applied to TTY logging destinations like STDOUT
 # and STDERR. Inserting color codes into a log file is generally considered
-# bad from; these color codes cause issues for some command lien programs like
+# bad form; these color codes cause issues for some command line programs like
 # "less" and "more".
 #
 # A 'default" color scheme is provided with the Logging framework. In the

{'commit': 'diff --git a/examples/colorization.rb b/examples/colorization.rb\nindex 5d28fd0..5f8e359 100644\n--- a/examples/colorization.rb\n+++ b/examples/colorization.rb\n@@ -15,7 +15,7 @@\n #\n # Colorization should only be applied to TTY logging destinations like STDOUT\n # and STDERR. Inserting color codes into a log file is generally considered\n-# bad from; these color codes cause issues for some command lien programs like\n+# bad form; these color codes cause issues for some command line programs like\n # "less" and "more".\n #\n # A \'default" color scheme is provided with the Logging framework. In the\n', 'commit_subject': 'Correct spelling errors in colorization.rb example', 'repo_name': 'TwP/logging', 'committer': {'name': 'Simon Chiang', 'email': 'f343328b9057c9009cb7365278160eef86508534@gmail.com', 'time_sec': '1373381675', 'tz_offset': '-360', 'date': {'seconds': '1373381675'}}, 'commit_tree': 'b1d2b798205ae6dfbb521320b89a37174adfd0e5', 'commit_message': 'Correct spelling errors in colorization.rb example', 'language_name': 'Shell', 'license': 'mit', 'hunks': '@@ -15,7 +15,7 @@\n #\n # Colorization should only be applied to TTY logging destinations like STDOUT\n # and STDERR. Inserting color codes into a log file is generally considered\n-# bad from; these color codes cause issues for some command lien programs like\n+# bad form; these color codes cause issues for some command line programs like\n # "less" and "more".\n #\n # A \'default" color scheme is provided with the Logging framework. In the\n', 'addition_count': 1, 'deletion_count': 1, 'src_file': 'a/examples/colorization.rb', 'tgt_file': 'b/examples/colorization.rb', 'file_extension': '.rb', 'before_file': '# :stopdoc:\n#\n# The Pattern layout can colorize log events based on a provided color scheme.\n# The configuration is a two part process. First the color scheme is defined\n# with the level colors and any pattern token colors. This color scheme is\n# then passed by name to the Pattern layout when it is created.\n#\n# The color scheme defines colors to be applied to the level token found in\n# the pattern layout. So that the "info" level will have one color, and the\n# "fatal" level will have a separate color. This applies only to the level\n# token in the Pattern layout.\n#\n# Common tokens can have their own color, too. The date token can be colored\n# blue, and the message token can be colored magenta.\n#\n# Colorization should only be applied to TTY logging destinations like STDOUT\n# and STDERR. Inserting color codes into a log file is generally considered\n# bad from; these color codes cause issues for some command lien programs like\n# "less" and "more".\n#\n# A \'default" color scheme is provided with the Logging framework. In the\n# example below we create our own color scheme called \'bright\' and apply it to\n# the \'stdout\' appender.\n#\n\n  require \'logging\'\n\n  # here we setup a color scheme called \'bright\'\n  Logging.color_scheme( \'bright\',\n    :levels => {\n      :info  => :green,\n      :warn  => :yellow,\n      :error => :red,\n      :fatal => [:white, :on_red]\n    },\n    :date => :blue,\n    :logger => :cyan,\n    :message => :magenta\n  )\n\n  Logging.appenders.stdout(\n    \'stdout\',\n    :layout => Logging.layouts.pattern(\n      :pattern => \'[%d] %-5l %c: %m\\n\',\n      :color_scheme => \'bright\'\n    )\n  )\n\n  log = Logging.logger[\'Happy::Colors\']\n  log.add_appenders \'stdout\'\n  log.level = :debug\n\n  # these log messages will be nicely colored\n  # the level will be colored differently for each message\n  #\n  log.debug "a very nice little debug message"\n  log.info "things are operating nominally"\n  log.warn "this is your last warning"\n  log.error StandardError.new("something went horribly wrong")\n  log.fatal "I Die!"\n\n# :startdoc:\n', 'message': 'Correct spelling errors in colorization.rb example', 'author_name': 'Simon Chiang', 'lang': 'rb'}