fix: Get logger configuration from app.conf file (#1907)

* feat: Get logger configuration from file

* feat: Get logger configuration from file

* Remove GetConfigLogs()
This commit is contained in:
Sergey Zabodalov 2023-05-30 16:30:09 +03:00 committed by GitHub
parent 4c8648d323
commit 10e66f8020
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View File

@ -21,3 +21,4 @@ isDemoMode = false
batchSize = 100 batchSize = 100
ldapServerPort = 389 ldapServerPort = 389
quota = {"organization": -1, "user": -1, "application": -1, "provider": -1} quota = {"organization": -1, "user": -1, "application": -1, "provider": -1}
logConfig = {"filename": "logs/casdoor.log", "maxdays":99999, "perm":"0770"}

View File

@ -109,3 +109,19 @@ func TestGetConfigQuota(t *testing.T) {
assert.Equal(t, scenery.expected, quota) assert.Equal(t, scenery.expected, quota)
} }
} }
func TestGetConfigLogs(t *testing.T) {
scenarios := []struct {
description string
expected string
}{
{"Default log config", `{"filename": "logs/casdoor.log", "maxdays":99999, "perm":"0770"}`},
}
err := beego.LoadAppConfig("ini", "app.conf")
assert.Nil(t, err)
for _, scenery := range scenarios {
quota := GetConfigString("logConfig")
assert.Equal(t, scenery.expected, quota)
}
}

View File

@ -73,7 +73,7 @@ func main() {
beego.BConfig.WebConfig.Session.SessionCookieLifeTime = 3600 * 24 * 30 beego.BConfig.WebConfig.Session.SessionCookieLifeTime = 3600 * 24 * 30
// beego.BConfig.WebConfig.Session.SessionCookieSameSite = http.SameSiteNoneMode // beego.BConfig.WebConfig.Session.SessionCookieSameSite = http.SameSiteNoneMode
err := logs.SetLogger("file", `{"filename":"logs/casdoor.log","maxdays":99999,"perm":"0770"}`) err := logs.SetLogger(logs.AdapterFile, conf.GetConfigString("logConfig"))
if err != nil { if err != nil {
panic(err) panic(err)
} }