From a6d1a215601b2dc95dfd4de218e4a950cf321075 Mon Sep 17 00:00:00 2001 From: Patrick Lamar <32331521+skyf0cker@users.noreply.github.com> Date: Tue, 26 Mar 2024 19:05:55 +0800 Subject: [PATCH] Fix the panic caused by not starting LogFactory --- server/server.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/server.go b/server/server.go index 0824282..8740fab 100644 --- a/server/server.go +++ b/server/server.go @@ -44,6 +44,7 @@ func New(ctx context.Context, options option.Options) (*Server, error) { ctx = service.ContextWithDefaultRegistry(ctx) createdAt := time.Now() logFactory, err := log.New(log.Options{ + Context: ctx, Options: common.PtrValueOrDefault(options.Log), DefaultWriter: os.Stderr, BaseTime: createdAt, @@ -51,6 +52,7 @@ func New(ctx context.Context, options option.Options) (*Server, error) { if err != nil { return nil, E.Cause(err, "create log factory") } + chiRouter := chi.NewRouter() httpServer := &http.Server{ Addr: options.Listen, @@ -128,7 +130,11 @@ func New(ctx context.Context, options option.Options) (*Server, error) { func (s *Server) Start() error { s.initializeRoutes() - err := s.cacheFile.Start() + err := s.logFactory.Start() + if err != nil { + return err + } + err = s.cacheFile.Start() if err != nil { return err }