mirror of
https://github.com/netfun2000/rttys_zhaojh329.git
synced 2026-02-27 09:53:24 +08:00
Log to /var/log/rttys.log when stdout is a terminal
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
This commit is contained in:
@@ -22,5 +22,5 @@ require (
|
||||
github.com/rakyll/statik v0.1.6
|
||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
|
||||
github.com/sirupsen/logrus v1.4.1
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 // indirect
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
|
||||
)
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"encoding/hex"
|
||||
"flag"
|
||||
"fmt"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"io"
|
||||
"os"
|
||||
"runtime"
|
||||
@@ -48,6 +49,9 @@ type RttysConfig struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
if terminal.IsTerminal(int(os.Stdout.Fd())) {
|
||||
return
|
||||
}
|
||||
log.AddHook(lfshook.NewHook("/var/log/rttys.log", &log.TextFormatter{}))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user