syslog.go 262 B

123456789101112131415
  1. package logx
  2. import "log"
  3. type redirector struct{}
  4. // CollectSysLog redirects system log into logx info
  5. func CollectSysLog() {
  6. log.SetOutput(new(redirector))
  7. }
  8. func (r *redirector) Write(p []byte) (n int, err error) {
  9. Info(string(p))
  10. return len(p), nil
  11. }