mirror of https://github.com/jlelse/GoBlog
Fix missing default logFile config
This commit is contained in:
parent
251fdc07e5
commit
61cecf8454
|
@ -398,6 +398,7 @@ func createDefaultConfig() *config {
|
||||||
Server: &configServer{
|
Server: &configServer{
|
||||||
Port: 8080,
|
Port: 8080,
|
||||||
PublicAddress: "http://localhost:8080",
|
PublicAddress: "http://localhost:8080",
|
||||||
|
LogFile: "data/access.log",
|
||||||
},
|
},
|
||||||
Db: &configDb{
|
Db: &configDb{
|
||||||
File: "data/db.sqlite",
|
File: "data/db.sqlite",
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a *goBlog) initHTTPLog() (err error) {
|
func (a *goBlog) initHTTPLog() (err error) {
|
||||||
if !a.cfg.Server.Logging {
|
if !a.cfg.Server.Logging || a.cfg.Server.LogFile == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
a.logf, err = rotatelogs.New(
|
a.logf, err = rotatelogs.New(
|
||||||
|
|
|
@ -12,6 +12,16 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"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) {
|
func initTestHttpLogs(logFile string) (http.Handler, error) {
|
||||||
|
|
||||||
app := &goBlog{
|
app := &goBlog{
|
||||||
|
|
Loading…
Reference in New Issue