From 8854c7872f04c54b69b5ce3e45757fa69a4ad9ac Mon Sep 17 00:00:00 2001 From: vcptr <51714622+vcptr@users.noreply.github.com> Date: Wed, 13 Nov 2019 16:31:09 +0800 Subject: [PATCH] early inited log --- app/log/log.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/log/log.go b/app/log/log.go index 22bba19e..1b47cb56 100644 --- a/app/log/log.go +++ b/app/log/log.go @@ -29,6 +29,13 @@ func New(ctx context.Context, config *Config) (*Instance, error) { } log.RegisterHandler(g) + // start logger instantly on inited + // other modules would log during init + if err := g.startInternal(); err != nil { + return nil, err + } + + newError("Logger started").AtDebug().WriteToLog() return g, nil } @@ -81,13 +88,7 @@ func (g *Instance) startInternal() error { // Start implements common.Runnable.Start(). func (g *Instance) Start() error { - if err := g.startInternal(); err != nil { - return err - } - - newError("Logger started").AtDebug().WriteToLog() - - return nil + return g.startInternal() } // Handle implements log.Handler.