mirror of
https://github.com/fumiama/WireGold.git
synced 2026-06-12 04:43:22 +08:00
add log to file option -l
This commit is contained in:
9
main.go
9
main.go
@@ -24,6 +24,7 @@ func main() {
|
||||
mtu := flag.Int("m", 1500-68, "set the mtu of wg")
|
||||
debug := flag.Bool("d", false, "print debug logs")
|
||||
warn := flag.Bool("w", false, "only show logs above warn level")
|
||||
logfile := flag.String("l", "-", "write log to file")
|
||||
flag.Parse()
|
||||
if *debug {
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
@@ -50,6 +51,14 @@ func main() {
|
||||
fmt.Println("PrivateKey:", helper.BytesToString(prvk[:57]))
|
||||
os.Exit(0)
|
||||
}
|
||||
if *logfile != "-" {
|
||||
f, err := os.Create(*logfile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer f.Close()
|
||||
logrus.SetOutput(f)
|
||||
}
|
||||
if helper.IsNotExist(*file) {
|
||||
f := new(bytes.Buffer)
|
||||
var r string
|
||||
|
||||
Reference in New Issue
Block a user