Halcyon

Notice: The website is currently being udpated. Sorry for any inconvenience.

Logging

When troubleshooting your application or monitoring its activity, logging
provides a central source of statistics and a record of events. In Halcyon,
several types of loggers are support, including the Ruby standard Logger, but
also Analogger, Logging, and Log4r.

Configuration

The default configuration for logging is to just output straight to standard
out, including all debugging information. However, this can be adjusted
according to your needs (such as in production).

The logging configuration settings are found in config/config.yml under the
logging heading. Depending on which logger client specified, the options
available can change, but by default you have file and level.

If file is nil (commented out or left blank), standard output is used
instead of logging to a file. However, if you would like to log to a file, it
is suggested to log to log/<em>environment</em>.log (where
environment is which environment you’re running in, development,
test, or @production@). This can be anything at all, though, including
/var/log/app_name.log (as long as the application is being run with the right
permissions or access levels).

For example, to only log messages of type WARN with the standard Ruby logger
to the local production log, the following configuration options would suffice:

1 ---
2 ## config/config.yml
3 logging:
4   type: Logger
5   file: log/production.log
6   level: warn

Logging Messages

If you’re needing log messages, every object is extended by the Logging helper
and provides a method called logger. In most circumstances, you can call the
logger like this:

 1 class Messages < Application
 2   def create
 3     msg = Message.new
 4     msg.values.merge! params
 5     if id = msg.save
 6       self.logger.debug "Created Message with #{msg.values.inspect}"
 7       ok id
 8     else
 9       msg.errors.each do |error|
10         self.logger.warn "Unable to save model: " << error
11       end
12       raise UnprocessableEntity.new
13     end
14   end
15 end

The essence is self.logger.<em>level</em> where level is an
acceptable logging level, including debug, info, warn, error, and
fatal for the default Ruby logger.