mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
Log to a (configurable) file
This commit is contained in:
parent
2f4bdaf67a
commit
57975a489f
2 changed files with 12 additions and 4 deletions
|
|
@ -1,13 +1,20 @@
|
|||
require 'rubygems' unless defined?(Gem)
|
||||
|
||||
class Logger
|
||||
def initialize
|
||||
def initialize(
|
||||
f = '/var/log/vmware-host-pooler.log'
|
||||
)
|
||||
@file = f
|
||||
end
|
||||
|
||||
def log level, string
|
||||
time = Time.new
|
||||
stamp = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
puts "[#{stamp}] #{string}"
|
||||
|
||||
open(@file, 'a') do |f|
|
||||
f.puts "[#{stamp}] #{string}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,6 @@ require 'lib/logger'
|
|||
require 'lib/require_relative'
|
||||
require 'lib/vsphere_helper'
|
||||
|
||||
$logger = Logger.new
|
||||
$vsphere_helper = VsphereHelper.new
|
||||
|
||||
Dir.chdir(File.dirname(__FILE__))
|
||||
|
||||
# Load the configuration file
|
||||
|
|
@ -21,6 +18,10 @@ config = YAML.load_file(config_file)
|
|||
pools = config[:pools]
|
||||
vsphere = config[:vsphere]
|
||||
|
||||
# Load logger & vSphere helper libraries
|
||||
$logger = Logger.new config[:config]['logfile']
|
||||
$vsphere_helper = VsphereHelper.new
|
||||
|
||||
# Connect to Redis
|
||||
$redis = Redis.new
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue