Method: SemanticLogger::Appender::File#log

Defined in:
lib/semantic_logger/appender/file.rb

#log(log) ⇒ Object

Since only one appender thread will be writing to the file at a time it is not necessary to protect access to the file with a semaphore.



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/semantic_logger/appender/file.rb', line 183

def log(log)
  reopen if time_to_reopen?

  count = 0
  begin
    message = formatter.call(log, self) << "\n"
    @file.write(message)
    @log_count += 1
    @log_size  += message.size
  rescue StandardError => e
    if count < retry_count
      count += 1
      reopen
      retry
    end
    raise(e)
  end
  true
end