Sha256: dfc08cc9549d01ff3575cf34ae38b6267b25c24ac2259e9aae604d7d08c56827

Contents?: true

Size: 1.53 KB

Versions: 42

Compression:

Stored size: 1.53 KB

Contents

# :stopdoc:
#
# The formatting of log messages is controlled by the layout given to the
# appender. By default all appenders use the Basic layout. It's pretty
# basic. However, a more sophisticated Pattern layout can be used or one of
# the Parseable layouts -- JSON or YAML.
#
# The available layouts are:
#
#   Logging.layouts.basic
#   Logging.layouts.pattern
#   Logging.layouts.json
#   Logging.layouts.yaml
#
# After you configure a layout, you can reuse that layout among different
# appenders if you so choose. This enables you to have some the style of log
# output being sent to multiple destinations.
#
# We will store a Layout instance in a local variable, and then pass that
# instance to each appender.
#

  require 'logging'

  # create our pattern layout instance
  layout = Logging.layouts.pattern \
    :pattern      => '[%d] %-5l %c: %m\n',
    :date_pattern => '%Y-%m-%d %H:%M:%S'

  # only show "info" or higher messages on STDOUT using our layout
  Logging.appenders.stdout \
    :level  => :info,
    :layout => layout

  # send all log events to the development log (including debug) using our layout
  Logging.appenders.rolling_file \
    'development.log',
    :age    => 'daily',
    :layout => layout

  log = Logging.logger['Foo::Bar']
  log.add_appenders 'stdout', 'development.log'
  log.level = :debug

  log.debug "a very nice little debug message"
  log.info "things are operating normally"
  log.warn "this is your last warning"
  log.error StandardError.new("something went horribly wrong")
  log.fatal "I Die!"

# :startdoc:

Version data entries

42 entries across 34 versions & 3 rubygems

Version Path
logging-2.4.0 examples/reusing_layouts.rb
logging-2.3.1 examples/reusing_layouts.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/gems/logging-2.3.0/examples/reusing_layouts.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/gems/logging-2.3.0/examples/reusing_layouts.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/gems/logging-2.3.0/examples/reusing_layouts.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/gems/logging-2.3.0/examples/reusing_layouts.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.7.0/gems/logging-2.3.0/examples/reusing_layouts.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/logging-2.3.0/examples/reusing_layouts.rb
logging-2.3.0 examples/reusing_layouts.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/logging-2.2.2/examples/reusing_layouts.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/logging-2.2.2/examples/reusing_layouts.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/logging-2.2.2/examples/reusing_layouts.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/logging-2.2.2/examples/reusing_layouts.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/examples/reusing_layouts.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/examples/reusing_layouts.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/examples/reusing_layouts.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/examples/reusing_layouts.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/examples/reusing_layouts.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/logging-2.2.2/examples/reusing_layouts.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/logging-2.2.2/examples/reusing_layouts.rb