FLogger
FLogger (or File Logger (or FLogger)) is an extremely simple and easy-to-use logger that outputs to one or many files. It was created, originally, as a learning project for myself, but has also become a tool that I continue to develop and use.
Installation
The latest stable release of FLogger can be installed via RubyGems:
gem install flogger
Or you can check out the latest source code via Github:
git clone https://github.com/aburdette/flogger.git
Usage and Defaults
Currently, FLogger can output to various predefined logs (and perhaps more in the future). By default, all logs are placed in the logs
directory within your current working directory. To change the default path, specify a different one during initialization:
@log = FLogger::Log.new do |c|
c.debug = 'new/path/to/debug.log'
c.warning = 'new/path/to/warning.log'
end
By default, FLogger outputs messages formatted with a preceding date/time to the application log file. To change these defaults, specify a your changes during initialization (Note: %s
will be replaced with the log message):
@log = FLogger::Log.new do |c|
c.default = :warning
c.format = "#> %s"
end
Example
There are a few more detailed examples in the examples directory. However, below is a simple example of using FLogger to output log messages:
require 'flogger'
@log = FLogger::Log.new
log.puts :debug, 'This message will output to logs/debug.txt by default.'
log.puts :error, 'This message will output to logs/error.txt by default.'
log.puts 'This message will output to logs/application.txt by default.'
Log Types
Currently, there are 4 specific log types, and 1 generic:
- debug
-
For general software debug messages - defaults to
logs/debug.txt
- error
-
For application error messages - defaults to
logs/error.txt
- notice
-
For general notification messages - defaults to
logs/notice.txt
- warning
-
For application warning messages - defaults to
logs/warning.txt
- application
-
General purpose application log messages - defaults to
logs/application.txt