lib/semantic_logger/subscriber.rb in semantic_logger-4.5.0 vs lib/semantic_logger/subscriber.rb in semantic_logger-4.6.0.beta1

- old
+ new

@@ -3,11 +3,11 @@ # Abstract base class for all appenders. module SemanticLogger class Subscriber < SemanticLogger::Base # Every appender has its own formatter attr_reader :formatter - attr_writer :application, :host, :logger, :metrics + attr_writer :application, :environment, :host, :logger, :metrics # Returns the current log level if set, otherwise it logs everything it receives. def level @level || :trace end @@ -30,10 +30,15 @@ # Allow application name to be set globally or on a per subscriber basis. def application @application || SemanticLogger.application end + # Allow environment name to be set globally or on a per subscriber basis. + def environment + @environment || SemanticLogger.environment + end + # Allow host name to be set globally or on a per subscriber basis. def host @host || SemanticLogger.host end @@ -90,12 +95,13 @@ # Default: SemanticLogger.host # # metrics: [Boolean] # Whether to log metric only entries with this subscriber. # Default: false - def initialize(level: nil, formatter: nil, filter: nil, application: nil, host: nil, metrics: false, &block) + def initialize(level: nil, formatter: nil, filter: nil, application: nil, environment: nil, host: nil, metrics: false, &block) self.formatter = block || formatter @application = application + @environment = environment @host = host @metrics = metrics # Subscribers don't take a class name, so use this class name if a subscriber # is logged to directly.