lib/sapience/appender/stream.rb in sapience-2.5.4 vs lib/sapience/appender/stream.rb in sapience-2.6.0

- old
+ new

@@ -58,13 +58,11 @@ # Sapience.add_appender(:stream, file_name: 'application.log') # # logger = Sapience['test'] # logger.info 'Hello World' def initialize(options = {}, &block) - unless options[:io] || options[:file_name] - fail ArgumentError, "missing mandatory argument :file_name or :io" - end + fail ArgumentError, "missing mandatory argument :file_name or :io" unless options[:io] || options[:file_name] opts = options.dup if (io = opts.delete(:io)) @log = Sapience.constantize(io) else @@ -73,11 +71,10 @@ end # Set the log level and formatter if supplied super(opts, &block) end - # rubocop:enable AbcSize, CyclomaticComplexity, PerceivedComplexity # After forking an active process call #reopen to re-open # open the file handles etc to resources # # Note: This method will only work if :file_name was supplied @@ -85,10 +82,10 @@ # If :io was supplied, it will need to be re-opened manually. def reopen return unless @file_name ensure_folder_exist - @log = open(@file_name, (::File::WRONLY | ::File::APPEND | ::File::CREAT)) + @log = File.open(@file_name, (::File::WRONLY | ::File::APPEND | ::File::CREAT)) # Force all log entries to write immediately without buffering # Allows multiple processes to write to the same log file simultaneously @log.sync = true @log.set_encoding(Encoding::BINARY) if @log.respond_to?(:set_encoding) @log