Show version info in server log

This commit is contained in:
Justin Hawkins 2025-04-25 13:20:43 +09:30
parent 9f0d81e7f1
commit 531abdafde
2 changed files with 12 additions and 3 deletions

14
main.go
View File

@ -100,9 +100,7 @@ func main() {
flag.Parse()
if versionFlag != nil && *versionFlag {
fmt.Printf("netgiv %s, built at %s\n", version, date)
fmt.Printf("commit: %s\n", commit)
fmt.Print("http://github.com/tardisx/netgiv\n")
fmt.Print(versionInfo(true))
os.Exit(0)
}
@ -212,3 +210,13 @@ environment variable. This may be preferable in some environments.
}
}
}
func versionInfo(verbose bool) string {
out := ""
out += fmt.Sprintf("netgiv %s, built at %s\n", version, date)
if verbose {
out += fmt.Sprintf("commit: %s\n", commit)
out += fmt.Sprintf("http://github.com/tardisx/netgiv\n")
}
return out
}

View File

@ -42,6 +42,7 @@ var ngfs []NGF
var globalId uint32
func (s *Server) Run() {
log.Info(versionInfo(false))
log.Infof("starting server on :%d", s.port)
address := fmt.Sprintf(":%d", s.port)
networkAddress, _ := net.ResolveTCPAddr("tcp", address)