From 1b0f652de3ed3a512420b75bf587f60d80ebecd3 Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Fri, 5 Sep 2025 21:04:43 +0800 Subject: [PATCH] chore: improve logging --- internal/workflow/engine/engine.go | 2 +- internal/workflow/engine/executor_bizapply.go | 14 +++++++------- internal/workflow/engine/executor_bizdeploy.go | 4 ++-- internal/workflow/engine/executor_bizmonitor.go | 2 +- internal/workflow/engine/executor_biznotify.go | 2 +- internal/workflow/engine/executor_bizupload.go | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/internal/workflow/engine/engine.go b/internal/workflow/engine/engine.go index 210c800c..39a13143 100644 --- a/internal/workflow/engine/engine.go +++ b/internal/workflow/engine/engine.go @@ -180,7 +180,7 @@ func (we *workflowEngine) executeNode(wfCtx *WorkflowContext, node *Node) error }) } if _, err := we.wfoutputRepo.Save(execCtx.ctx, output); err != nil { - we.syslog.Warn("failed to save node output") + we.syslog.Error("failed to save node output", slog.Any("error", err)) } } diff --git a/internal/workflow/engine/executor_bizapply.go b/internal/workflow/engine/executor_bizapply.go index 2d6c1921..7f8e16f4 100644 --- a/internal/workflow/engine/executor_bizapply.go +++ b/internal/workflow/engine/executor_bizapply.go @@ -87,7 +87,7 @@ func (ne *bizApplyNodeExecutor) Execute(execCtx *NodeExecutionContext) (*NodeExe // 解析证书 certX509, err := xcert.ParseCertificateFromPEM(obtainResp.FullChainCertificate) if err != nil { - ne.logger.Warn("failed to parse certificate, may be the CA responded error") + ne.logger.Warn("could not parse certificate, may be the CA responded error") return execRes, err } @@ -106,7 +106,7 @@ func (ne *bizApplyNodeExecutor) Execute(execCtx *NodeExecutionContext) (*NodeExe } certificate.PopulateFromX509(certX509) if certificate, err := ne.certificateRepo.Save(execCtx.ctx, certificate); err != nil { - ne.logger.Warn("failed to save certificate") + ne.logger.Warn("could not save certificate") return execRes, err } else { ne.logger.Info("certificate saved", slog.String("recordId", certificate.Id)) @@ -232,7 +232,7 @@ func (ne *bizApplyNodeExecutor) executeObtain(execCtx *NodeExecutionContext, nod } legoConfig, err := certapply.NewACMEConfig(legoOptions) if err != nil { - ne.logger.Warn("failed to initialize acme config") + ne.logger.Warn("could not initialize acme config") return nil, err } else { ne.logger.Info("acme config initialized", slog.String("acmeDirUrl", legoConfig.CADirUrl)) @@ -242,7 +242,7 @@ func (ne *bizApplyNodeExecutor) executeObtain(execCtx *NodeExecutionContext, nod // 注意此步骤仍需在主进程中进行,以保证并发安全 legoUser, err := certapply.NewACMEAccountWithSingleFlight(legoConfig, nodeCfg.ContactEmail) if err != nil { - ne.logger.Warn("failed to initialize acme account") + ne.logger.Warn("could not initialize acme account") return nil, err } else { ne.logger.Info("acme account initialized", slog.String("acmeAcctUrl", legoUser.ACMEAcctUrl)) @@ -320,7 +320,7 @@ func (ne *bizApplyNodeExecutor) executeObtain(execCtx *NodeExecutionContext, nod Request: obtainReq, }) if err != nil { - ne.logger.Warn("failed to obtain certificate") + ne.logger.Warn("could not obtain certificate") return nil, err } @@ -339,14 +339,14 @@ func (ne *bizApplyNodeExecutor) executeObtain(execCtx *NodeExecutionContext, nod return nil }) if err != nil { - ne.logger.Warn("failed to initialize acme client") + ne.logger.Warn("could not initialize acme client") return nil, err } // 执行申请证书请求 obtainResp, err := legoClient.ObtainCertificate(execCtx.ctx, obtainReq) if err != nil { - ne.logger.Warn("failed to obtain certificate") + ne.logger.Warn("could not obtain certificate") return nil, err } diff --git a/internal/workflow/engine/executor_bizdeploy.go b/internal/workflow/engine/executor_bizdeploy.go index 9f8b98b8..1f05e5f5 100644 --- a/internal/workflow/engine/executor_bizdeploy.go +++ b/internal/workflow/engine/executor_bizdeploy.go @@ -43,7 +43,7 @@ func (ne *bizDeployNodeExecutor) Execute(execCtx *NodeExecutionContext) (*NodeEx if len(s) == 2 { certificate, err := ne.certificateRepo.GetById(execCtx.ctx, s[1]) if err != nil { - ne.logger.Warn("failed to get input certificate") + ne.logger.Warn("could not get input certificate") return execRes, err } @@ -89,7 +89,7 @@ func (ne *bizDeployNodeExecutor) Execute(execCtx *NodeExecutionContext) (*NodeEx PrivateKey: inputCertificate.PrivateKey, } if _, err := deployClient.DeployCertificate(execCtx.ctx, deployReq); err != nil { - ne.logger.Warn("failed to deploy certificate") + ne.logger.Warn("could not deploy certificate") return execRes, err } diff --git a/internal/workflow/engine/executor_bizmonitor.go b/internal/workflow/engine/executor_bizmonitor.go index d4616e01..b3304e71 100644 --- a/internal/workflow/engine/executor_bizmonitor.go +++ b/internal/workflow/engine/executor_bizmonitor.go @@ -67,7 +67,7 @@ func (ne *bizMonitorNodeExecutor) Execute(execCtx *NodeExecutionContext) (*NodeE } if err != nil { - ne.logger.Warn("failed to monitor certificate") + ne.logger.Warn("could not retrieve certificate") return execRes, err } else { if len(certs) == 0 { diff --git a/internal/workflow/engine/executor_biznotify.go b/internal/workflow/engine/executor_biznotify.go index e1410fae..5ba43d72 100644 --- a/internal/workflow/engine/executor_biznotify.go +++ b/internal/workflow/engine/executor_biznotify.go @@ -49,7 +49,7 @@ func (ne *bizNotifyNodeExecutor) Execute(execCtx *NodeExecutionContext) (*NodeEx Message: nodeCfg.Message, } if _, err := notifyClient.SendNotification(execCtx.ctx, notifyReq); err != nil { - ne.logger.Warn("failed to send notification") + ne.logger.Warn("could not send notification") return execRes, err } diff --git a/internal/workflow/engine/executor_bizupload.go b/internal/workflow/engine/executor_bizupload.go index aa8a5eef..c62cea79 100644 --- a/internal/workflow/engine/executor_bizupload.go +++ b/internal/workflow/engine/executor_bizupload.go @@ -63,7 +63,7 @@ func (ne *bizUploadNodeExecutor) Execute(execCtx *NodeExecutionContext) (*NodeEx } certificate.PopulateFromPEM(nodeCfg.Certificate, nodeCfg.PrivateKey) if certificate, err := ne.certificateRepo.Save(execCtx.ctx, certificate); err != nil { - ne.logger.Warn("failed to save certificate") + ne.logger.Warn("could not save certificate") return execRes, err } else { ne.logger.Info("certificate saved", slog.String("recordId", certificate.Id))