diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-13 16:02:50 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-13 16:02:50 +0100 |
commit | e140af144e987ff7f6d767f2dc48b9cf685803fd (patch) | |
tree | 4a01971890865b4b3ca837d563bc673cbb787de8 /lib/mauve/processor.rb | |
parent | d28af4ec946c6aa4b645b73cef47d7e0c680bc0d (diff) |
Big commit
* Added manpages for all binaries
* Added log-reopening for mauvealert-server, and logrotate snippet
* mauveserver now adds a user on install, and runs as that user
* Big logging tidy-up
* Alert subjects are only overwritten by the source, when the subject in the databse is empty
* Removed various attr_writer methods that were being redifined
* Added a notes box to the acknowledge form, but this doesn't work yet
Diffstat (limited to 'lib/mauve/processor.rb')
-rw-r--r-- | lib/mauve/processor.rb | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/mauve/processor.rb b/lib/mauve/processor.rb index 083b9a1..f36dacb 100644 --- a/lib/mauve/processor.rb +++ b/lib/mauve/processor.rb @@ -11,9 +11,7 @@ module Mauve attr_accessor :transmission_cache_expire_time, :sleep_interval def initialize - # Set the logger up - @logger = Log4r::Logger.new(self.class.to_s) - + super # # Set up the transmission id cache # @@ -22,10 +20,11 @@ module Mauve @transmission_cache_checked_at = Time.now end - def main_loop - - logger.info("Buffer has packets waiting...") if Server.packet_buffer_size > 0 + def logger + @logger ||= Log4r::Logger.new(self.class.to_s) + end + def main_loop # # Only do the loop a maximum of 10 times every @sleep_interval seconds # @@ -39,7 +38,9 @@ module Mauve Timer.instance.freeze unless Timer.instance.frozen? - @logger.debug("Got #{data.inspect} from #{client.inspect}") + raise ArgumentError, "arse" + + logger.debug("Got #{data.inspect} from #{client.inspect}") ip_source = "#{client[3]}:#{client[1]}" update = Proto::AlertUpdate.new @@ -48,14 +49,14 @@ module Mauve update.parse_from_string(data) if @transmission_id_cache[update.transmission_id.to_s] - @logger.debug("Ignoring duplicate transmission id #{update.transmission_id}") + logger.info("Ignoring duplicate transmission id #{update.transmission_id}") # # Continue with next packet. # next end - @logger.debug "Update #{update.transmission_id} sent at #{update.transmission_time} from "+ + logger.info "Update #{update.transmission_id} sent at #{update.transmission_time} from "+ "'#{update.source}'@#{ip_source} alerts #{update.alert.length}" Alert.receive_update(update, received_at) @@ -64,10 +65,10 @@ module Mauve NotImplementedError, DataObjects::IntegrityError => ex - @logger.error "#{ex} (#{ex.class}) while parsing #{data.length} bytes "+ + logger.error "#{ex} (#{ex.class}) while parsing #{data.length} bytes "+ "starting '#{data[0..15].inspect}' from #{ip_source}" - @logger.debug ex.backtrace.join("\n") + logger.debug ex.backtrace.join("\n") ensure @transmission_id_cache[update.transmission_id.to_s] = MauveTime.now |