add log path for save it

This commit is contained in:
YouROK
2021-01-18 11:13:28 +03:00
parent 538f7a2481
commit 41a1763934
2 changed files with 17 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ import (
type args struct {
Port string `arg:"-p" help:"web server port"`
Path string `arg:"-d" help:"database path"`
LogPath string `arg:"-l" help:"log path"`
RDB bool `arg:"-r" help:"start in read-only DB mode"`
DontKill bool `arg:"-k" help:"dont kill program on signal"`
}
@@ -39,6 +40,8 @@ func main() {
}
settings.Path = params.Path
log.Init(params.LogPath)
dnsResolve()
Preconfig(params.DontKill)

View File

@@ -2,8 +2,22 @@ package log
import (
"log"
"os"
)
func Init(path string) {
if path != "" {
ff, err := os.Create(path)
if err != nil {
TLogln("Error create log file:", err)
return
}
os.Stdout = ff
os.Stderr = ff
}
}
func TLogln(v ...interface{}) {
log.Println(v...)
}