From 980510a99532509552f604728f051498a98d8d99 Mon Sep 17 00:00:00 2001 From: genofire Date: Wed, 29 Sep 2021 14:33:35 +0200 Subject: [PATCH] web/webtest: make Logger configurable --- web/webtest/main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/web/webtest/main.go b/web/webtest/main.go index d529aac..97aa935 100644 --- a/web/webtest/main.go +++ b/web/webtest/main.go @@ -29,6 +29,14 @@ type Option struct { DBReRun bool DBSetup func(db *database.Database) Mailer bool + Logger *zap.Logger +} + +func (option Option) log() *zap.Logger { + if option.Logger != nil { + return option.Logger + } + return zap.L() } // TestServer - to run it without listen an server @@ -64,7 +72,7 @@ func NewWithDBSetup(modules web.ModuleRegisterFunc, dbCall func(db *database.Dat // New allows to configure WebService for testing func (option Option) New() (*TestServer, error) { - log := zap.L() + log := option.log() ws := &web.Service{} ws.SetLog(log)