---
 deltacloud-aggregator.spec.in |    4 ++++
 src/dbomatic/dbomatic.rb      |   27 ++++++++++++++++++++++++---
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/deltacloud-aggregator.spec.in b/deltacloud-aggregator.spec.in
index c2ef1fd..5bb3d70 100644
--- a/deltacloud-aggregator.spec.in
+++ b/deltacloud-aggregator.spec.in
@@ -105,6 +105,8 @@ mv %{buildroot}/%{app_root}/doc 
%{buildroot}/%{app_root}/test %{buildroot}/%{doc
 # these files will no longer be added explicitly here.
 touch %{buildroot}%{_localstatedir}/log/%{name}/mongrel.log
 touch %{buildroot}%{_localstatedir}/log/%{name}/rails.log
+touch %{buildroot}%{_localstatedir}/log/dbomatic/dbomatic
+touch %{buildroot}%{_localstatedir}/run/dbomatic/event_log_position
 
 # remove the files not needed for the installation
 %{__rm} -f  %{buildroot}%{app_root}/vendor/plugins/will_paginate/.gitignore
@@ -157,6 +159,8 @@ fi
 %attr(-, dcloud, dcloud) %{_localstatedir}/lib/%{name}
 %attr(-, dcloud, dcloud) %{_localstatedir}/run/%{name}
 %attr(-, dcloud, dcloud) %{_localstatedir}/log/%{name}
+%attr(-, dcloud, dcloud) %{_localstatedir}/run/dbomatic
+%attr(-, dcloud, dcloud) %{_localstatedir}/log/dbomatic
 %doc AUTHORS COPYING
 
 %files doc
diff --git a/src/dbomatic/dbomatic.rb b/src/dbomatic/dbomatic.rb
index 154d766..ec335bd 100644
--- a/src/dbomatic/dbomatic.rb
+++ b/src/dbomatic/dbomatic.rb
@@ -25,7 +25,9 @@ require 'optparse'
 help = false
 
 condor_event_log_dir    =   "/var/log/condor"
+dbomatic_log_dir        =   "/var/log/dbomatic"
 dbomatic_run_dir        =   "/var/run/dbomatic"
+dbomatic_log_stdout     =   false
 
 optparse = OptionParser.new do |opts|
 
@@ -41,6 +43,12 @@ BANNER
   opts.on( '-r', '--run PATH', 'Use PATH to the dbomatic runtime directory') 
do |newpath|
     dbomatic_run_dir = newpath
   end
+  opts.on( '-l', '--log PATH', 'Use PATH to the dbomatic log directory') do 
|newpath|
+    dbomatic_log_dir = newpath
+  end
+  opts.on( '-s', '--stdout', 'Write dbomatic log to stdout') do
+    dbomatic_log_stdout     =   true
+  end
   opts.on( '-h', '--help', '') { help = true }
 end
 
@@ -59,11 +67,24 @@ end
 
 CONDOR_EVENT_LOG_FILE   =   "#{condor_event_log_dir}/EventLog"
 EVENT_LOG_POS_FILE      =   "#{dbomatic_run_dir}/event_log_position"
+if dbomatic_log_stdout
+  DBOMATIC_LOG_FILE       =    STDOUT
+else
+  DBOMATIC_LOG_FILE       =   "#{dbomatic_log_dir}/dbomatic"
+end
+
+logger = Logger.new DBOMATIC_LOG_FILE
+logger.level = Logger::INFO
+logger.info "Starting up"
 
 # Handle the event log's xml
 class CondorEventLog < Nokogiri::XML::SAX::Document
   attr_accessor :tag, :event_type, :event_cmd, :event_time
 
+  def initialize(logger)
+    @logger = logger
+  end
+
   # Store the name of the event log attribute we're looking at
   def start_element(element, attributes)
     @tag = attributes[1] if element == "a"
@@ -90,9 +111,9 @@ class CondorEventLog < Nokogiri::XML::SAX::Document
       inst_name = @event_cmd[4,@event_cmd.size-4].gsub(/_[0-9]*$/, '')
       inst = Instance.find(:first, :conditions => ['name = ?', inst_name])
       if inst.nil?
-        puts "Unexpected nil instance, skipping..."
+        @logger.info "Unexpected nil instance, skipping..."
       else
-        puts "Instance event #{inst.name} #...@event_type} #...@event_time}"
+        @logger.info "Instance event #{inst.name} #...@event_type} 
#...@event_time}"
         InstanceEvent.create! :instance => inst,
                               :event_type => @event_type,
                               :event_time => @event_time
@@ -101,7 +122,7 @@ class CondorEventLog < Nokogiri::XML::SAX::Document
     end
   end
 end
-parser = Nokogiri::XML::SAX::PushParser.new(CondorEventLog.new)
+parser = Nokogiri::XML::SAX::PushParser.new(CondorEventLog.new(logger))
 
 # XXX hack, condor event log doesn't seem to have a top level element
 # enclosing everything else in the doc (as standards conforming xml must).
-- 
1.7.2.1

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to