Module: LogStruct::SemanticLogger::ReopenAfterFork

Extended by:
T::Sig
Defined in:
lib/log_struct/semantic_logger/reopen_after_fork.rb

Overview

SemanticLogger writes lines from a background thread, and a forked child doesn't get its parent's threads, so lines logged in Puma, Unicorn, Passenger or Pitchfork workers, Resque jobs and other forked children were never written. Ruby calls Process._fork for every fork, so each child reopens the appenders (a new writer thread).

Defined Under Namespace

Modules: ForkHook

Class Method Summary collapse

Class Method Details

.install! ⇒ void

This method returns an undefined value.



15
16
17
18
19
20
# File 'lib/log_struct/semantic_logger/reopen_after_fork.rb', line 15

def self.install!
  return if @installed
  @installed = true

  Process.singleton_class.prepend(ForkHook)
end