Browse Source

early inited log

vcptr 6 years ago
parent
commit
8854c7872f
1 changed files with 8 additions and 7 deletions
  1. 8 7
      app/log/log.go

+ 8 - 7
app/log/log.go

@@ -29,6 +29,13 @@ func New(ctx context.Context, config *Config) (*Instance, error) {
 	}
 	}
 	log.RegisterHandler(g)
 	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
 	return g, nil
 }
 }
 
 
@@ -81,13 +88,7 @@ func (g *Instance) startInternal() error {
 
 
 // Start implements common.Runnable.Start().
 // Start implements common.Runnable.Start().
 func (g *Instance) Start() error {
 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.
 // Handle implements log.Handler.