mirror of
https://github.com/certimate-go/certimate.git
synced 2026-06-22 21:05:48 +08:00
chore: improve logging
This commit is contained in:
parent
09e938e77f
commit
1b0f652de3
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user