Skip to content

Instantly share code, notes, and snippets.

@fnordfish
Created March 16, 2021 14:02
Show Gist options
  • Save fnordfish/7265102b156496b767c8dba098fd8f51 to your computer and use it in GitHub Desktop.
Save fnordfish/7265102b156496b767c8dba098fd8f51 to your computer and use it in GitHub Desktop.
trap HUP to reopen logfile in ruby
$logger = Logger.new("my.log")
prev_trap = Signal.trap("HUP") do |*args|
$logger.reopen
prev_trap.call(*args) if prev_trap.respond_to?(:call)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment