lib/semantic_logger/appender/file.rb in semantic_logger-4.8.1 vs lib/semantic_logger/appender/file.rb in semantic_logger-4.8.2
- old
+ new
@@ -60,12 +60,17 @@
# logger = SemanticLogger['test']
# logger.info 'Hello World'
def initialize(io: nil, file_name: nil, **args, &block)
if io
@log = io
+ unless @log.respond_to?(:write)
+ raise(ArgumentError, "SemanticLogging::Appender::File :io is not a valid IO instance: #{io.inspect}")
+ end
else
@file_name = file_name
- raise "SemanticLogging::Appender::File missing mandatory parameter :file_name or :io" unless file_name
+ unless file_name
+ raise(ArgumentError, "SemanticLogging::Appender::File missing mandatory parameter :file_name or :io")
+ end
reopen
end
super(**args, &block)