Fix broken logging

This commit is contained in:
Melon 2024-06-04 18:26:07 +01:00
parent dee4b7ee3a
commit 5532aa9782
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
6 changed files with 11 additions and 11 deletions

View File

@ -46,7 +46,7 @@ func (s *serveCmd) Execute(ctx context.Context, f *flag.FlagSet, args ...interfa
if os.IsNotExist(err) {
logger.Logger.Info("[Orchid] Error: missing config file")
} else {
logger.Logger.Info("[Orchid] Error: open config file: ", err)
logger.Logger.Info("[Orchid] Error: open config file: ", "err", err)
}
return subcommands.ExitFailure
}
@ -54,7 +54,7 @@ func (s *serveCmd) Execute(ctx context.Context, f *flag.FlagSet, args ...interfa
var conf startUpConfig
err = yaml.NewDecoder(openConf).Decode(&conf)
if err != nil {
logger.Logger.Info("[Orchid] Error: invalid config file: ", err)
logger.Logger.Info("[Orchid] Error: invalid config file: ", "err", err)
return subcommands.ExitFailure
}

View File

@ -146,12 +146,12 @@ func (h *HttpAcmeProvider) saveLoginTokens() {
// acme login token
openTokens, err := os.Create(h.tokenFile)
if err != nil {
logger.Logger.Info("[Orchid] Failed to open token file:", err)
logger.Logger.Info("[Orchid] Failed to open token file:", "err", err)
}
defer openTokens.Close()
err = yaml.NewEncoder(openTokens).Encode(AcmeLogin{Access: h.accessToken, Refresh: h.refreshToken})
if err != nil {
logger.Logger.Info("[Orchid] Failed to write tokens file:", err)
logger.Logger.Info("[Orchid] Failed to write tokens file:", "err", err)
}
}

View File

@ -212,7 +212,7 @@ func (s *Service) renewalRoutine(wg *sync.WaitGroup) {
Logger.Info("Doing quick certificate check before starting...")
err := s.renewalCheck()
if err != nil {
Logger.Info("Certificate check, should not error first try: ", err)
Logger.Info("Certificate check, should not error first try: ", "err", err)
return
}
@ -231,7 +231,7 @@ func (s *Service) renewalRoutine(wg *sync.WaitGroup) {
// run a renewal check and log errors, but ignore ErrAlreadyRenewing
err := s.renewalCheck()
if err != nil && !errors.Is(err, ErrAlreadyRenewing) {
Logger.Info("Certificate check, an error occurred: ", err)
Logger.Info("Certificate check, an error occurred: ", "err", err)
}
}()
}
@ -337,7 +337,7 @@ func (s *Service) setupLegoClient() (*lego.Client, error) {
// getDnsProvider loads a DNS challenge provider using the provided name and
// token
func (s *Service) getDnsProvider(name, token string) (challenge.Provider, error) {
Logger.Info("Loading dns provider: %s with token %s*****\n", name, token[:3])
Logger.Info("Loading dns provider", "name", name, "token", token[:3]+"*****")
switch name {
case "duckdns":
return duckdns.NewDNSProviderConfig(&duckdns.Config{

View File

@ -106,7 +106,7 @@ func setupPebbleTest(t *testing.T, serverTls *certgen.CertGen) (*Service, *sql.D
db2, err := sql.Open("sqlite3", dbFile)
assert.NoError(t, err)
Logger.Info("DB File:", dbFile)
Logger.Info("DB File:", "db", dbFile)
certDir, err := os.MkdirTemp("", "orchid-certs")
keyDir, err := os.MkdirTemp("", "orchid-keys")

View File

@ -56,7 +56,7 @@ func NewApiServer(listen string, db *database.Queries, signer mjwt.Verifier, dom
// query database
rows, err := db.FindOwnedCerts(context.Background())
if err != nil {
logger.Logger.Info("Failed after reading certificates from database: ", err)
logger.Logger.Info("Failed after reading certificates from database:", "err", err)
http.Error(rw, "Database Error", http.StatusInternalServerError)
return
}
@ -86,7 +86,7 @@ func NewApiServer(listen string, db *database.Queries, signer mjwt.Verifier, dom
// get etld+1
topFqdn, found := vUtils.GetTopFqdn(d)
if !found {
logger.Logger.Info("Invalid domain found: ", d)
logger.Logger.Info("Invalid domain found:", "domain", d)
http.Error(rw, "Database Error", http.StatusInternalServerError)
return
}

View File

@ -63,7 +63,7 @@ func checkAuthForCertificate(verify mjwt.Verifier, perm string, db *database.Que
return
}
apiError(rw, http.StatusInsufficientStorage, "Database error")
logger.Logger.Info("[API] Failed to find certificate owner: ", err)
logger.Logger.Info("[API] Failed to find certificate owner:", "err", err)
return
}