Browse Source

Fix missing default logFile config

pull/10/head
Jan-Lukas Else 6 months ago
parent
commit
61cecf8454
  1. 1
      config.go
  2. 2
      httpLogs.go
  3. 10
      httpLogs_test.go

1
config.go

@ -398,6 +398,7 @@ func createDefaultConfig() *config {
Server: &configServer{
Port: 8080,
PublicAddress: "http://localhost:8080",
LogFile: "data/access.log",
},
Db: &configDb{
File: "data/db.sqlite",

2
httpLogs.go

@ -9,7 +9,7 @@ import (
)
func (a *goBlog) initHTTPLog() (err error) {
if !a.cfg.Server.Logging {
if !a.cfg.Server.Logging || a.cfg.Server.LogFile == "" {
return nil
}
a.logf, err = rotatelogs.New(

10
httpLogs_test.go

@ -12,6 +12,16 @@ import (
"github.com/stretchr/testify/require"
)
func Test_httpLogsConfig(t *testing.T) {
app := &goBlog{
cfg: createDefaultTestConfig(t),
}
_ = app.initConfig()
assert.Equal(t, false, app.cfg.Server.Logging)
assert.Equal(t, "data/access.log", app.cfg.Server.LogFile)
}
func initTestHttpLogs(logFile string) (http.Handler, error) {
app := &goBlog{

Loading…
Cancel
Save