Class: Vmpooler::Logger
- Inherits:
-
Object
- Object
- Vmpooler::Logger
- Defined in:
- lib/vmpooler/logger.rb
Instance Method Summary collapse
-
#initialize(f = '/var/log/vmpooler.log') ⇒ Logger
constructor
A new instance of Logger.
- #log(_level, string) ⇒ Object
Constructor Details
#initialize(f = '/var/log/vmpooler.log') ⇒ Logger
Returns a new instance of Logger.
7 8 9 10 11 |
# File 'lib/vmpooler/logger.rb', line 7 def initialize( f = '/var/log/vmpooler.log' ) @file = f end |
Instance Method Details
#log(_level, string) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/vmpooler/logger.rb', line 13 def log(_level, string) time = Time.new stamp = time.strftime('%Y-%m-%d %H:%M:%S') puts "[#{stamp}] #{string}" if ENV['VMPOOLER_DEBUG'] File.open(@file, 'a') do |f| f.puts "[#{stamp}] #{string}" end end |