lib/semantic_logger/appenders.rb in semantic_logger-4.8.0 vs lib/semantic_logger/appenders.rb in semantic_logger-4.8.1
- old
+ new
@@ -9,26 +9,22 @@
end
def add(**args, &block)
appender = SemanticLogger::Appender.factory(**args, &block)
- if appender.is_a?(Appender::File) && console_output?
- logger.warn "Ignoring attempt to add a second console appender since it would result in duplicate console output."
+ if appender.respond_to?(:console_output?) && appender.console_output? && console_output?
+ logger.warn "Ignoring attempt to add a second console appender: #{appender.class.name} since it would result in duplicate console output."
return
end
self << appender
appender
end
# Whether any of the existing appenders already output to the console?
# I.e. Writes to stdout or stderr.
def console_output?
- any? do |appender|
- next unless appender.is_a?(Appender::File)
-
- [$stderr, $stdout].include?(appender.instance_variable_get(:@log))
- end
+ any? { |appender| appender.respond_to?(:console_output?) && appender.console_output? }
end
def log(log)
each do |appender|
appender.log(log) if appender.should_log?(log)