Skip to content

101 using adapters

rudionrails edited this page Mar 22, 2012 · 5 revisions

Yell 101 - How To: Using Adapters

Yell allows you to attach adapters in various combinations. This document will cover their basic usage. For more advanced configurations, you continue to reading: How To: Different Adapters for Different Log Levels

Instead of defining logger = Yell.new STDOUT, you may also define it as follows:

logger = Yell.new do
  adapter STDOUT
end

While logging to STDOUT or STDERR remains trivial, you will need to be more concise when logging to files. The following definitions are all equal and will result in using the build-in File adapter:

# 1. Shortcut
logger = Yell.new 'development.log'

# 2. Shortcut (more concise)
logger = Yell.new :file, 'development.log'

# 3. Explicit
logger = Yell.new do
  adapter :file, 'development.log'
end

NOTE: You are not able to default to the File adapter with the shortcut: adapter 'development.log'. In that case, you need to tell which adapter to use.

If you want to know more, continue to How To: The Datefile Adapter