1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-12-22 09:00:10 +00:00

Add debug flag; warning label for debug mode

This commit is contained in:
Harvey Tindall 2020-08-19 14:09:48 +01:00
parent 6366239ec4
commit ec7609ed8c
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2
3 changed files with 10 additions and 3 deletions

View File

@ -147,7 +147,8 @@
"required": false,
"requires_restart": true,
"type": "bool",
"value": false
"value": false,
"description": "Enables debug logging and exposes pprof as a route (Don't use in production!)"
},
"contact_message": {
"name": "Contact message",

View File

@ -184,7 +184,8 @@
"required": false,
"requires_restart": true,
"type": "bool",
"value": false
"value": false,
"description": "Enables debug logging and exposes pprof as a route (Don't use in production!)"
},
"contact_message": {
"name": "Contact message",

View File

@ -108,6 +108,7 @@ func main() {
configPath := flag.String("config", app.config_path, "alternate path to config file.")
host := flag.String("host", "", "alternate address to host web ui on.")
port := flag.Int("port", 0, "alternate port to host web ui on.")
debug := flag.Bool("debug", false, "Enables debug logging and exposes pprof.")
flag.Parse()
if app.config_path == *configPath && app.data_path != *dataPath {
@ -164,8 +165,12 @@ func main() {
}
app.version = app.config.Section("jellyfin").Key("version").String()
debugMode = app.config.Section("ui").Key("debug").MustBool(true)
debugMode = app.config.Section("ui").Key("debug").MustBool(false)
if *debug {
debugMode = true
}
if debugMode {
app.info.Println("WARNING: Don't use debug mode in production, as it exposes pprof on the network.")
app.debug = log.New(os.Stdout, "[DEBUG] ", log.Ltime|log.Lshortfile)
} else {
app.debug = log.New(ioutil.Discard, "", 0)