diff --git a/config/postal.defaults.yml b/config/postal.defaults.yml index 5f3eb32..dd6741f 100644 --- a/config/postal.defaults.yml +++ b/config/postal.defaults.yml @@ -41,6 +41,9 @@ logging: root: # Automatically determined based on config root max_log_file_size: 20 max_log_files: 10 + greylog: + host: + port: 12201 message_db: host: 127.0.0.1 diff --git a/lib/postal/app_logger.rb b/lib/postal/app_logger.rb index 555e9b5..112c7b6 100644 --- a/lib/postal/app_logger.rb +++ b/lib/postal/app_logger.rb @@ -3,11 +3,6 @@ require 'logger' module Postal class AppLogger < Logger - def self.greylog_notifier - @greylog_notifier ||= Postal.config.logging.greylog ? GELF::Notifier.new(Postal.config.logging.greylog.host, Postal.config.logging.greylog.port) : nil - - end - def initialize(log_name, *args) @log_name = log_name super(*args) @@ -33,6 +28,14 @@ module Postal end true end + + def self.greylog? + !!Postal.config.logging.greylog&.host + end + + def self.greylog_notifier + @greylog_notifier ||= greylog? ? GELF::Notifier.new(Postal.config.logging.greylog.host, Postal.config.logging.greylog.port) : nil + end end class LogFormatter