diff options
author | Matthew Landauer <matthew@openaustralia.org> | 2012-10-10 14:34:01 +1100 |
---|---|---|
committer | Matthew Landauer <matthew@openaustralia.org> | 2012-10-10 14:34:01 +1100 |
commit | 4869338b35a6e1fed6498f3d8ed24ee2139e65d6 (patch) | |
tree | 4cd39f5339d44dba828afe2cfde15e17d9297c84 | |
parent | 36de9e0f243470c8a9377498d3de2abf57263d26 (diff) |
Now can load postfix log files in the main method
-rw-r--r-- | app/models/exim_log.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/app/models/exim_log.rb b/app/models/exim_log.rb index 5e10f9d51..eb3099b5c 100644 --- a/app/models/exim_log.rb +++ b/app/models/exim_log.rb @@ -27,7 +27,7 @@ class EximLog < ActiveRecord::Base # Load in exim log file from disk, or update if we already have it # Assumes files are named with date, rather than cyclically. # Doesn't do anything if file hasn't been modified since it was last loaded. - def EximLog.load_file(file_name) + def EximLog.load_file(file_name, type = :exim) is_gz = file_name.include?(".gz") file_name_db = is_gz ? file_name.gsub(".gz", "") : file_name @@ -52,7 +52,14 @@ class EximLog < ActiveRecord::Base done.save! f = is_gz ? Zlib::GzipReader.open(file_name) : File.open(file_name, 'r') - load_exim_log_data(f, done) + case(type) + when :exim + load_exim_log_data(f, done) + when :postfix + load_postfix_log_data(f, done) + else + raise "Unexpected MTA type: #{type}" + end end end |