rotate_test.go 372 B

123456789101112131415161718192021222324252627
  1. // +build linux
  2. package lumberjack_test
  3. import (
  4. "log"
  5. "os"
  6. "os/signal"
  7. "syscall"
  8. "gopkg.in/natefinch/lumberjack.v2"
  9. )
  10. // Example of how to rotate in response to SIGHUP.
  11. func ExampleLogger_Rotate() {
  12. l := &lumberjack.Logger{}
  13. log.SetOutput(l)
  14. c := make(chan os.Signal, 1)
  15. signal.Notify(c, syscall.SIGHUP)
  16. go func() {
  17. for {
  18. <-c
  19. l.Rotate()
  20. }
  21. }()
  22. }