Class: InstanceLogger
- Inherits:
-
Object
- Object
- InstanceLogger
- Defined in:
- lib/instance_logger.rb
Overview
The instance logger writes to a file in a given directory. The file is determined by the instance_id in the message. The file is opened and closed each time something is written.
Instance Method Summary collapse
-
#initialize(dir) ⇒ InstanceLogger
constructor
A new instance of InstanceLogger.
- #puts(instance, msg) ⇒ Object (also: #debug, #info, #notice, #warning, #err, #error, #alert, #emerg, #crit)
Constructor Details
#initialize(dir) ⇒ InstanceLogger
Returns a new instance of InstanceLogger.
5 6 7 |
# File 'lib/instance_logger.rb', line 5 def initialize(dir) @directory = dir end |
Instance Method Details
#puts(instance, msg) ⇒ Object Also known as: debug, info, notice, warning, err, error, alert, emerg, crit
9 10 11 12 13 |
# File 'lib/instance_logger.rb', line 9 def puts(instance, msg) File.open(File.join(@directory, instance), "a") do |fd| fd.puts msg end end |