Fix string formatting in logging statements using strconv.Itoa

This commit is contained in:
2025-05-17 21:40:12 +03:30
parent 99e3debf7c
commit 0854387eb4

View File

@@ -8,6 +8,7 @@ import (
"CatsOfMastodonBotGo/internal/services"
"context"
"log/slog"
"strconv"
"time"
)
@@ -40,14 +41,13 @@ func main() {
var newAccounts = services.PostServiceInstance.GetNewAccounts(existingAccountIds, newPosts)
// Save to database
slog.Info("Fetched %d posts; %d existing posts; %d new posts and %d new accounts\n", len(posts), len(existingPostIds), len(newPosts), len(newAccounts))
slog.Info("Fetched " + strconv.Itoa(len(posts)) + " posts; " + strconv.Itoa(len(existingPostIds)) + " existing posts; " + strconv.Itoa(len(newPosts)) + " new posts and " + strconv.Itoa(len(newAccounts)) + " new accounts\n")
// Additional logging
if newAccounts != nil {
slog.Info("Inserted %d accounts\n", services.PostServiceInstance.InsertNewAccounts(newAccounts))
slog.Info("Inserted " + strconv.Itoa(services.PostServiceInstance.InsertNewAccounts(newAccounts)) + " accounts\n")
}
if newPosts != nil {
slog.Info("Inserted %d posts\n", services.PostServiceInstance.InsertNewPosts(newPosts))
slog.Info("Inserted " + strconv.Itoa(services.PostServiceInstance.InsertNewPosts(newPosts)) + " posts\n")
}
}