mirror of
https://github.com/vale981/agent
synced 2025-03-04 09:01:42 -05:00
log-file param added
This commit is contained in:
parent
19b20b5736
commit
5cddd77b45
3 changed files with 19 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
.idea
|
||||
.indihub-agent
|
||||
indihub.json
|
||||
*.log
|
||||
bin/
|
||||
|
|
17
main.go
17
main.go
|
@ -43,6 +43,7 @@ var (
|
|||
flagAPIPort uint64
|
||||
flagAPIOrigins string
|
||||
flagMode string
|
||||
flagLogFile string
|
||||
|
||||
indiServerAddr string
|
||||
|
||||
|
@ -123,11 +124,27 @@ robotic - equipment sharing is not possible, your equipment is controlled by IND
|
|||
"",
|
||||
"comma-separated list of origins allowed to connect to API-server",
|
||||
)
|
||||
flag.StringVar(
|
||||
&flagLogFile,
|
||||
"log-file",
|
||||
"",
|
||||
"path to log file (STDOUT by default)",
|
||||
)
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
if flagLogFile != "" {
|
||||
// redirect log output to file
|
||||
logFile, err := os.OpenFile(flagLogFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
|
||||
if err != nil {
|
||||
log.Fatalf("error opening log file '%s': %s\n", flagLogFile, err)
|
||||
}
|
||||
defer logFile.Close()
|
||||
log.SetOutput(logFile)
|
||||
}
|
||||
|
||||
if flagMode != lib.ModeSolo && flagMode != lib.ModeShare && flagMode != lib.ModeRobotic {
|
||||
log.Fatalf("Unknown mode '%s' provided\n", flagMode)
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ var AgentVersion = "1.0.4"
|
|||
|
||||
func CheckAgentVersion(latestVer string) {
|
||||
log.Println("Current agent version:", AgentVersion)
|
||||
log.Println("Latest agent version:", latestVer)
|
||||
|
||||
if AgentVersion < latestVer {
|
||||
log.Println("Latest agent version:", latestVer)
|
||||
yc := color.New(color.FgYellow)
|
||||
yc.Println()
|
||||
yc.Println(" ************************************************************")
|
||||
|
|
Loading…
Add table
Reference in a new issue