Set logging preferences via command line flags. Closes #20

This commit is contained in:
Gabe Kangas
2020-07-06 21:27:31 -07:00
parent 1133edf716
commit 259923b303
12 changed files with 38 additions and 22 deletions

22
main.go
View File

@@ -23,10 +23,13 @@ var (
)
func main() {
log.Println(getVersion())
configureLogging()
log.Infoln(getVersion())
configFile := flag.String("configFile", "config.yaml", "Config File full path. Defaults to current folder")
enableDebugOptions := flag.Bool("enableDebugFeatures", false, "Enable additional debugging options.")
enableVerboseLogging := flag.Bool("enableVerboseLogging", false, "Enable additional logging.")
flag.Parse()
@@ -34,23 +37,36 @@ func main() {
logrus.SetReportCaller(true)
}
if *enableVerboseLogging {
log.SetLevel(log.TraceLevel)
} else {
log.SetLevel(log.InfoLevel)
}
if err := config.Load(*configFile, getVersion()); err != nil {
panic(err)
}
// starts the core
if err := core.Start(); err != nil {
log.Println("failed to start the core package")
log.Error("failed to start the core package")
panic(err)
}
if err := router.Start(); err != nil {
log.Println("failed to start/run the router")
log.Error("failed to start/run the router")
panic(err)
}
}
//getVersion gets the version string
func getVersion() string {
return fmt.Sprintf("Owncast v%s-%s (%s)", BuildVersion, BuildType, GitCommit)
}
func configureLogging() {
log.SetFormatter(&log.TextFormatter{
FullTimestamp: true,
})
}