Skip to content

BillionMail gives you open-source MailServer, NewsLetter, Email Marketing — fully self-hosted, dev-friendly, and free from monthly fees. Join the discord: https://discord.gg/asfXzBUhZr

Adjust the logging print level

lotkf5614e209b82
diff --git a/core/internal/controller/batch_mail/batch_mail_v1_list_tasks.go b/core/internal/controller/batch_mail/batch_mail_v1_list_tasks.go
index e8ca4be3..01afc448 100644
--- a/core/internal/controller/batch_mail/batch_mail_v1_list_tasks.go
+++ b/core/internal/controller/batch_mail/batch_mail_v1_list_tasks.go
@@ -50,7 +50,7 @@ func (c *ControllerV1) ListTasks(ctx context.Context, req *v1.ListTasksReq) (res
} else {
// If still inconsistent, set unsent count to 0
detail.UnsentCount = 0
- g.Log().Warning(ctx, "Task %d has inconsistent data: recipient_count(%d) < sent_count(%d)",
+ g.Log().Infof(ctx, "Task %d has inconsistent data: recipient_count(%d) < sent_count(%d)",
task.Id, task.RecipientCount, sentCount)
}
diff --git a/core/internal/controller/batch_mail/batch_mail_v1_unsubscribe.go b/core/internal/controller/batch_mail/batch_mail_v1_unsubscribe.go
index 02f97e8a..eeb6b246 100644
--- a/core/internal/controller/batch_mail/batch_mail_v1_unsubscribe.go
+++ b/core/internal/controller/batch_mail/batch_mail_v1_unsubscribe.go
@@ -33,7 +33,7 @@ func (c *ControllerV1) Unsubscribe(ctx context.Context, req *v1.UnsubscribeReq)
}
if len(req.GroupId) == 0 {
- g.Log().Warning(ctx, "No group IDs provided for unsubscribe - Email: %s", claims.Email)
+ g.Log().Debugf(ctx, "No group IDs provided for unsubscribe - Email: %s", claims.Email)
res.SetError(gerror.New(public.LangCtx(ctx, "No group IDs provided for unsubscribe")))
return
diff --git a/core/internal/controller/contact/contact_v1_import_contacts.go b/core/internal/controller/contact/contact_v1_import_contacts.go
index d75ff8e6..5e8d5458 100644
--- a/core/internal/controller/contact/contact_v1_import_contacts.go
+++ b/core/internal/controller/contact/contact_v1_import_contacts.go
@@ -126,7 +126,7 @@ func parseCSVContent(ctx context.Context, content string) ([]*entity.Contact, er
break
}
if err != nil {
- g.Log().Warning(ctx, "Error reading CSV record: %v", err)
+ g.Log().Debugf(ctx, "Error reading CSV record: %v", err)
continue
}
@@ -137,7 +137,7 @@ func parseCSVContent(ctx context.Context, content string) ([]*entity.Contact, er
// Validate email format
if err := gvalid.New().Rules("email").Data(email).Run(ctx); err != nil {
- g.Log().Warning(ctx, "Invalid email format in CSV, skipping: %s", email)
+ g.Log().Debugf(ctx, "Invalid email format in CSV, skipping: %s", email)
continue
}
@@ -163,7 +163,7 @@ func parseCSVContent(ctx context.Context, content string) ([]*entity.Contact, er
if attribsStr != "" {
attribs, err := parseJSONAttributes(ctx, attribsStr)
if err != nil {
- g.Log().Warning(ctx, "Failed to parse attributes for email %s: %v", email, err)
+ g.Log().Debugf(ctx, "Failed to parse attributes for email %s: %v", email, err)
} else {
contact_s.Attribs = attribs
}
@@ -290,7 +290,7 @@ func (c *ControllerV1) ImportContacts(ctx context.Context, req *v1.ImportContact
contactInfo.GroupId = groupId
if err := gvalid.New().Rules("email").Data(contactInfo.Email).Run(ctx); err != nil {
- g.Log().Warning(ctx, "Invalid email format in CSV, skipping: %s", contactInfo.Email)
+ g.Log().Debugf(ctx, "Invalid email format in CSV, skipping: %s", contactInfo.Email)
continue
}
diff --git a/core/internal/controller/contact/contact_v1_list_contacts.go b/core/internal/controller/contact/contact_v1_list_contacts.go
index 51e0a951..02257d11 100644
--- a/core/internal/controller/contact/contact_v1_list_contacts.go
+++ b/core/internal/controller/contact/contact_v1_list_contacts.go
@@ -58,7 +58,7 @@ func (c *ControllerV1) ListContacts(ctx context.Context, req *v1.ListContactsReq
for email, contactInfo := range emailMap {
groups, err := contact.GetContactGroupsInfo(ctx, email, req.Status)
if err != nil {
- g.Log().Warningf(ctx, "Failed to get groups for contact %s: %v", email, err)
+ g.Log().Debugf(ctx, "Failed to get groups for contact %s: %v", email, err)
continue
}
diff --git a/core/internal/controller/contact/contact_v1_list_contacts_ndp.go b/core/internal/controller/contact/contact_v1_list_contacts_ndp.go
index 69fa7e67..ea27cc94 100644
--- a/core/internal/controller/contact/contact_v1_list_contacts_ndp.go
+++ b/core/internal/controller/contact/contact_v1_list_contacts_ndp.go
@@ -51,7 +51,7 @@ func (c *ControllerV1) ListContactsNDP(ctx context.Context, req *v1.ListContacts
for email, contactInfo := range list {
groups, err := contact.GetGroup(ctx, contactInfo.GroupId)
if err != nil {
- g.Log().Warningf(ctx, "Failed to get groups for contact %s: %v", email, err)
+ g.Log().Debugf(ctx, "Failed to get groups for contact %s: %v", email, err)
continue
}
diff --git a/core/internal/controller/domains/domains_v1_add_domain.go b/core/internal/controller/domains/domains_v1_add_domain.go
index 8c1968b8..339b34b2 100644
--- a/core/internal/controller/domains/domains_v1_add_domain.go
+++ b/core/internal/controller/domains/domains_v1_add_domain.go
@@ -42,10 +42,10 @@ func (c *ControllerV1) AddDomain(ctx context.Context, req *v1.AddDomainReq) (res
if accErr == nil {
certErr := domains.ApplyLetsEncryptCertWithHttp(ctx, req.Domain, acc)
if certErr != nil {
- g.Log().Warningf(ctx, "Domain name [%s] added successfully, but auto-request certificate failed: %v", req.Domain, certErr)
+ g.Log().Debugf(ctx, "Domain name [%s] added successfully, but auto-request certificate failed: %v", req.Domain, certErr)
}
} else {
- g.Log().Warningf(ctx, "The domain name [%s] was added successfully, but the current account failed to obtain the certificate automatically: %v", req.Domain, accErr)
+ g.Log().Debugf(ctx, "The domain name [%s] was added successfully, but the current account failed to obtain the certificate automatically: %v", req.Domain, accErr)
}
})
diff --git a/core/internal/controller/mail_services/mail_services_v1_get_postfix_config.go b/core/internal/controller/mail_services/mail_services_v1_get_postfix_config.go
index a3081e8e..0d1403aa 100644
--- a/core/internal/controller/mail_services/mail_services_v1_get_postfix_config.go
+++ b/core/internal/controller/mail_services/mail_services_v1_get_postfix_config.go
@@ -27,7 +27,7 @@ func (c *ControllerV1) GetPostfixConfig(ctx context.Context, req *v1.GetPostfixC
mainCfPath := v1.ServiceType_Postfix
file, err := os.Open(mainCfPath)
if err != nil {
- g.Log().Warning(ctx, "Failed to open main.cf, use default values:", err)
+ g.Log().Debug(ctx, "Failed to open main.cf, use default values:", err)
for _, key := range params {
config[key] = defaultConfig[key]
}
diff --git a/core/internal/controller/mail_services/mail_services_v1_save_config_file.go b/core/internal/controller/mail_services/mail_services_v1_save_config_file.go
index 1b7de25e..1826071e 100644
--- a/core/internal/controller/mail_services/mail_services_v1_save_config_file.go
+++ b/core/internal/controller/mail_services/mail_services_v1_save_config_file.go
@@ -45,7 +45,7 @@ func (c *ControllerV1) SaveConfigFile(ctx context.Context, req *v1.SaveConfigFil
if gfile.Exists(configPath) {
backupPath = configPath + ".bak." + time.Now().Format("20060102150405")
if err := gfile.Copy(configPath, backupPath); err != nil {
- g.Log().Warningf(ctx, "Failed to back up configuration file %s: %v", configPath, err)
+ g.Log().Debugf(ctx, "Failed to back up configuration file %s: %v", configPath, err)
} else {
g.Log().Infof(ctx, "A configuration file backup has been created: %s", backupPath)
backupMade = true
diff --git a/core/internal/controller/middleware/ip_whitelist.go b/core/internal/controller/middleware/ip_whitelist.go
index 968e7c0f..803d0864 100644
--- a/core/internal/controller/middleware/ip_whitelist.go
+++ b/core/internal/controller/middleware/ip_whitelist.go
@@ -36,7 +36,7 @@ func isExcludedPath(path string) bool {
if strings.HasPrefix(path, "/.well-known/acme-challenge") ||
strings.HasPrefix(path, "/pmta/") ||
strings.HasPrefix(path, "/roundcube") {
- g.Log().Warning(context.Background(), "[IP Whitelist 2] Excluded path: ", path, " allowed")
+ g.Log().Debug(context.Background(), "[IP Whitelist 2] Excluded path: ", path, " allowed")
return true
}
@@ -106,7 +106,7 @@ func IPWhitelist(r *ghttp.Request) {
// 1. If the whitelist feature is not enabled, allow access directly
if !isIPWhitelistEnabled(envMap) {
r.Middleware.Next()
- // g.Log().Warningf(r.Context(), "[IP Whitelist] Not enabled, allowing access directly")
+ // g.Log().Debug(r.Context(), "[IP Whitelist] Not enabled, allowing access directly")
return
}
// 2. Check if the path is in the exclusion list
@@ -120,12 +120,12 @@ func IPWhitelist(r *ghttp.Request) {
// 3. Check if the client IP is in the whitelist
clientIP := r.GetClientIp()
if isIPAllowed(clientIP) {
- g.Log().Warningf(r.Context(), "[IP Whitelist] Access allowed: %s", clientIP)
+ g.Log().Infof(r.Context(), "[IP Whitelist] Access allowed: %s", clientIP)
r.Middleware.Next()
return
}
- g.Log().Warningf(r.Context(), "[IP Whitelist] Blocked non-whitelisted IP: %s, UA: %s, Path: %s", clientIP, r.Request.UserAgent(), r.Request.URL.Path)
+ g.Log().Infof(r.Context(), "[IP Whitelist] Blocked non-whitelisted IP: %s, UA: %s, Path: %s", clientIP, r.Request.UserAgent(), r.Request.URL.Path)
r.Response.WriteStatus(403, "IP not allowed")
r.Exit()
}
diff --git a/core/internal/controller/relay/relay_v1_list_relay_configs.go b/core/internal/controller/relay/relay_v1_list_relay_configs.go
index 84a53d32..c5636014 100644
--- a/core/internal/controller/relay/relay_v1_list_relay_configs.go
+++ b/core/internal/controller/relay/relay_v1_list_relay_configs.go
@@ -83,7 +83,7 @@ func (c *ControllerV1) ListRelayConfigs(ctx context.Context, req *v1.ListRelayCo
Scan(&mappings)
if err != nil {
- g.Log().Warning(ctx, "Failed to query domain mappings for relay ID", config.Id, ":", err)
+ g.Log().Debug(ctx, "Failed to query domain mappings for relay ID", config.Id, ":", err)
} else {
for _, mapping := range mappings {
@@ -196,7 +196,7 @@ func GetRealSPFRecord(ctx context.Context, domain string) (string, error) {
var finalErr error
txts, err := net.LookupTXT(domain)
if err != nil {
- g.Log().Warning(ctx, "DNS TXT query failed:", domain, "Error:", err)
+ g.Log().Debug(ctx, "DNS TXT query failed:", domain, "Error:", err)
finalErr = err
} else {
found := false
diff --git a/core/internal/controller/subscribe_list/subscribe_list.go b/core/internal/controller/subscribe_list/subscribe_list.go
index e18c1e57..0ed56cfb 100644
--- a/core/internal/controller/subscribe_list/subscribe_list.go
+++ b/core/internal/controller/subscribe_list/subscribe_list.go
@@ -113,7 +113,7 @@ func readTemplateFiles(baseFilename string) (htmlContent string, txtContent stri
txtBytes, err := os.ReadFile(txtPath)
if err != nil {
if !os.IsNotExist(err) {
- g.Log().Warningf(context.Background(),
+ g.Log().Debugf(context.Background(),
"failed to read TXT template: %v, path: %s", err, txtPath)
}
txtBytes = []byte("") // Return empty content if file does not exist
diff --git a/core/internal/service/abnormal_recipient/abnormal_recipient.go b/core/internal/service/abnormal_recipient/abnormal_recipient.go
index dafba59e..f58f6ff7 100644
--- a/core/internal/service/abnormal_recipient/abnormal_recipient.go
+++ b/core/internal/service/abnormal_recipient/abnormal_recipient.go
@@ -200,6 +200,6 @@ func setLastStatTime(ctx context.Context, t int64) {
OnConflict("name").
Save()
if err != nil {
- g.Log().Warningf(ctx, "[abnormal Recipient] Error occurred in the last statistics time recording: %v", err)
+ g.Log().Debugf(ctx, "[abnormal Recipient] Error occurred in the last statistics time recording: %v", err)
}
}
diff --git a/core/internal/service/batch_mail/batch_mail.go b/core/internal/service/batch_mail/batch_mail.go
index df39fe92..e47bb1fa 100644
--- a/core/internal/service/batch_mail/batch_mail.go
+++ b/core/internal/service/batch_mail/batch_mail.go
@@ -140,7 +140,7 @@ func CreateTask(ctx context.Context, args CreateTaskArgs) (int, error) {
"add_type": args.AddType,
})
if err != nil {
- g.Log().Warning(ctx, "Failed to create campaign:", err.Error())
+ g.Log().Debug(ctx, "Failed to create campaign:", err.Error())
return 0, err
}
@@ -233,7 +233,7 @@ func ImportRecipients(ctx context.Context, taskId int, contacts []*entity.Contac
// Count affected rows
affected, err := result.RowsAffected()
if err != nil {
- g.Log().Warning(ctx, "Could not get affected rows for batch %d/%d: %v", i+1, totalBatches, err)
+ g.Log().Debugf(ctx, "Could not get affected rows for batch %d/%d: %v", i+1, totalBatches, err)
} else {
totalImported += int(affected)
}
@@ -322,7 +322,7 @@ func CreateTaskWithRecipients(ctx context.Context, req *v1.CreateTaskReq, addTyp
Scan(&abnormalRecipients)
if err != nil {
- g.Log().Warning(ctx, "Failed to get the exception recipient list: %v", err)
+ g.Log().Debugf(ctx, "Failed to get the exception recipient list: %v", err)
}
abnormalMap := make(map[string]int)
diff --git a/core/internal/service/batch_mail/jwt.go b/core/internal/service/batch_mail/jwt.go
index 9b1cabc2..63ce07a5 100644
--- a/core/internal/service/batch_mail/jwt.go
+++ b/core/internal/service/batch_mail/jwt.go
@@ -77,7 +77,7 @@ func getOrGenerateSecret(ctx context.Context) string {
Insert()
if err != nil {
- g.Log().Warning(ctx, "Failed to persist JWT secret to database:", err)
+ g.Log().Debug(ctx, "Failed to persist JWT secret to database:", err)
val, err := g.DB().Model("bm_options").
Where("name", JWT_SECRET_KEY).
@@ -233,7 +233,7 @@ func getOrGenerateSubscribeConfirmSecret(ctx context.Context) string {
WhereNull("value").
Insert()
if err != nil {
- g.Log().Warning(ctx, "Failed to persist subscribe confirm JWT secret to database:", err)
+ g.Log().Debug(ctx, "Failed to persist subscribe confirm JWT secret to database:", err)
val, err := g.DB().Model("bm_options").
Where("name", SUBSCRIBE_CONFIRM_JWT_SECRET).
Value("value")
diff --git a/core/internal/service/batch_mail/stat_service.go b/core/internal/service/batch_mail/stat_service.go
index 5069065f..b55255aa 100644
--- a/core/internal/service/batch_mail/stat_service.go
+++ b/core/internal/service/batch_mail/stat_service.go
@@ -172,7 +172,7 @@ func (s *TaskStatService) fillChartDataHourly(data []map[string]interface{}, fil
hour = h
}
default:
- g.Log().Warningf(context.Background(), "Unexpected type for hour: %T, value: %v", item[fillKey], item[fillKey])
+ g.Log().Debugf(context.Background(), "Unexpected type for hour: %T, value: %v", item[fillKey], item[fillKey])
continue
}
dataMap[hour] = item
diff --git a/core/internal/service/batch_mail/task_executor.go b/core/internal/service/batch_mail/task_executor.go
index 8b1669f5..d6df2d37 100644
--- a/core/internal/service/batch_mail/task_executor.go
+++ b/core/internal/service/batch_mail/task_executor.go
@@ -654,7 +654,7 @@ func (e *TaskExecutor) processRecipientBatch(ctx context.Context, task *entity.E
return err
}
// record error but continue
- g.Log().Warning(ctx, "Rate limit wait error: %v", err)
+ g.Log().Debugf(ctx, "Rate limit wait error: %v", err)
}
@@ -887,7 +887,7 @@ func (e *TaskExecutor) processSendResults(ctx context.Context, resultChan <-chan
} else {
failedIDs = append(failedIDs, result.RecipientID)
- g.Log().Warning(ctx, "send email to recipient %d failed: %v",
+ g.Log().Debugf(ctx, "send email to recipient %d failed: %v",
result.RecipientID, result.Error)
}
@@ -1152,7 +1152,7 @@ func (e *TaskExecutor) sendEmailMock(ctx context.Context, task *entity.EmailTask
}
_, err = g.DB().Model("mailstat_senders").InsertIgnore(senderRecord)
if err != nil {
- g.Log().Warningf(ctx, "sendEmailMock: failed to insert mailstat_senders: %v", err)
+ g.Log().Debugf(ctx, "sendEmailMock: failed to insert mailstat_senders: %v", err)
}
// 2. Create MailMessageID record
@@ -1165,7 +1165,7 @@ func (e *TaskExecutor) sendEmailMock(ctx context.Context, task *entity.EmailTask
}
_, err = g.DB().Model("mailstat_message_ids").InsertIgnore(messageIDRecord)
if err != nil {
- g.Log().Warningf(ctx, "sendEmailMock: failed to insert mailstat_message_ids: %v", err)
+ g.Log().Debugf(ctx, "sendEmailMock: failed to insert mailstat_message_ids: %v", err)
}
// 3. Create MailSendRecord record
@@ -1206,7 +1206,7 @@ func (e *TaskExecutor) sendEmailMock(ctx context.Context, task *entity.EmailTask
"postfix_message_id": postfixMessageID,
})
if err != nil {
- g.Log().Warningf(ctx, "sendEmailMock: failed to insert mailstat_opened: %v", err)
+ g.Log().Debugf(ctx, "sendEmailMock: failed to insert mailstat_opened: %v", err)
}
// If opened, simulate a 20% click rate
@@ -1220,7 +1220,7 @@ func (e *TaskExecutor) sendEmailMock(ctx context.Context, task *entity.EmailTask
"postfix_message_id": postfixMessageID,
})
if err != nil {
- g.Log().Warningf(ctx, "sendEmailMock: failed to insert mailstat_clicked: %v", err)
+ g.Log().Debugf(ctx, "sendEmailMock: failed to insert mailstat_clicked: %v", err)
}
}
}
diff --git a/core/internal/service/contact/contact.go b/core/internal/service/contact/contact.go
index 565cad87..5844161b 100644
--- a/core/internal/service/contact/contact.go
+++ b/core/internal/service/contact/contact.go
@@ -124,7 +124,7 @@ func BatchCreateContactsIgnoreDuplicate(ctx context.Context, contacts []*entity.
// Count affected rows
affected, err := result.RowsAffected()
if err != nil {
- g.Log().Warning(ctx, "Could not get affected rows for batch %d/%d: %v", i+1, totalBatches, err)
+ g.Log().Debugf(ctx, "Could not get affected rows for batch %d/%d: %v", i+1, totalBatches, err)
} else {
totalAffected += int(affected)
g.Log().Debug(ctx, "Batch %d/%d inserted %d records successfully", i+1, totalBatches, affected)
diff --git a/core/internal/service/database_initialization/smtp_relay.go b/core/internal/service/database_initialization/smtp_relay.go
index 885a955d..c58bd27d 100644
--- a/core/internal/service/database_initialization/smtp_relay.go
+++ b/core/internal/service/database_initialization/smtp_relay.go
@@ -103,7 +103,7 @@ func migrateRelayData(ctx context.Context) error {
return gerror.Wrap(err, "Failed to query record count of new table")
}
if newCount > 0 {
- g.Log().Warning(ctx, "bm_relay_config already has data (%d records), skip migration to prevent duplication", newCount)
+ g.Log().Debugf(ctx, "bm_relay_config already has data (%d records), skip migration to prevent duplication", newCount)
return nil
}
diff --git a/core/internal/service/domains/baseurl.go b/core/internal/service/domains/baseurl.go
index 153b35cc..7536e1f5 100644
--- a/core/internal/service/domains/baseurl.go
+++ b/core/internal/service/domains/baseurl.go
@@ -33,7 +33,7 @@ func GetBaseURLBySender(sender string) string {
err := g.Validator().Data(sender).Rules("email").Run(context.Background())
if err != nil {
- g.Log().Warning(context.Background(), "GetBaseURLBySender --> Invalid email address", sender, err)
+ g.Log().Debug(context.Background(), "GetBaseURLBySender --> Invalid email address", sender, err)
return GetBaseURL()
}
diff --git a/core/internal/service/maillog_stat/maillog_stat.go b/core/internal/service/maillog_stat/maillog_stat.go
index 2bd8d138..d5df0457 100644
--- a/core/internal/service/maillog_stat/maillog_stat.go
+++ b/core/internal/service/maillog_stat/maillog_stat.go
@@ -385,7 +385,7 @@ func (ms *MaillogStat) Analysis(ctx context.Context) (<-chan MailRecorfContract,
g.Log().Debug(ctx, "Total scanned lines:", n)
if err != nil {
- g.Log().Warning(ctx, "Error reading maillog: %v\n", err)
+ g.Log().Debugf(ctx, "Error reading maillog: %v\n", err)
}
}()