add command line option for log file

cc #739
This commit is contained in:
Gokcehan committed 2022-02-06 19:51:52 +03:00
1 parent 5d393da572
commit 47620fa680
11 files changed
+38 -15

No files matched your search

+14 -3
View File
@@ -30,7 +30,6 @@ var (
gSocketProt string
gSocketPath string
gLogPath string
gServerLogPath string
gSelect string
gConfigPath string
gCommands arrayFlag
@@ -251,6 +250,11 @@ func main() {
"command",
"command to execute on client initialization")
flag.StringVar(&gLogPath,
"log",
"",
"path to the log file to write messages")
flag.Parse()
gSocketProt = gDefaultSocketProt
@@ -277,8 +281,15 @@ func main() {
log.Fatalf("remote command: %s", err)
}
case *serverMode:
if gLogPath != "" && !filepath.IsAbs(gLogPath) {
wd, err := os.Getwd()
if err != nil {
log.Fatalf("getting current directory: %s", err)
} else {
gLogPath = filepath.Join(wd, gLogPath)
}
}
os.Chdir(gUser.HomeDir)
gServerLogPath = filepath.Join(os.TempDir(), fmt.Sprintf("lf.%s.server.log", gUser.Username))
serve()
default:
gSingleMode = *singleMode
@@ -288,7 +299,7 @@ func main() {
}
gClientID = os.Getpid()
gLogPath = filepath.Join(os.TempDir(), fmt.Sprintf("lf.%s.%d.log", gUser.Username, gClientID))
switch flag.NArg() {
case 0:
_, err := os.Getwd()