Set logging preferences via command line flags. Closes #20
This commit is contained in:
22
main.go
22
main.go
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user