From 9db40cd4a0fa9288a0d36d630c489fc284d52c11 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Wed, 11 Aug 2021 08:24:12 +0200 Subject: [PATCH] Newlog: update channeldb, reputation, tkldb --- src/modules/channeldb.c | 16 +++++++++------- src/modules/reputation.c | 2 +- src/modules/tkldb.c | 16 +++++++++------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/modules/channeldb.c b/src/modules/channeldb.c index 9759a3bd5..2dcce5d63 100644 --- a/src/modules/channeldb.c +++ b/src/modules/channeldb.c @@ -31,9 +31,10 @@ ModuleHeader MOD_HEADER = { #define WARN_WRITE_ERROR(fname) \ do { \ - sendto_realops_and_log("[channeldb] Error writing to temporary database file " \ - "'%s': %s (DATABASE NOT SAVED)", \ - fname, unrealdb_get_error_string()); \ + unreal_log(ULOG_ERROR, "channeldb", "CHANNELDB_FILE_WRITE_ERROR", NULL, \ + "[channeldb] Error writing to temporary database file $filename: $system_error", \ + log_data_string("filename", fname), \ + log_data_string("system_error", unrealdb_get_error_string())); \ } while(0) #define W_SAFE(x) \ @@ -298,7 +299,7 @@ int write_channeldb(void) #endif if (rename(tmpfname, cfg.database) < 0) { - sendto_realops_and_log("[channeldb] Error renaming '%s' to '%s': %s (DATABASE NOT SAVED)", tmpfname, cfg.database, strerror(errno)); + config_error("[channeldb] Error renaming '%s' to '%s': %s (DATABASE NOT SAVED)", tmpfname, cfg.database, strerror(errno)); return 0; } #ifdef BENCHMARK @@ -527,11 +528,12 @@ int read_channeldb(void) unrealdb_close(db); if (added) - sendto_realops_and_log("[channeldb] Added %d persistent channels (+P)", added); + config_status("[channeldb] Added %d persistent channels (+P)", added); #ifdef BENCHMARK gettimeofday(&tv_beta, NULL); - ircd_log(LOG_ERROR, "[channeldb] Benchmark: LOAD DB: %ld microseconds", - ((tv_beta.tv_sec - tv_alpha.tv_sec) * 1000000) + (tv_beta.tv_usec - tv_alpha.tv_usec)); + unreal_log(ULOG_DEBUG, "channeldb", "CHANNELDB_BENCHMARK", NULL, + "[channeldb] Benchmark: LOAD DB: $time_msec microseconds", + log_data_integer("time_msec", ((tv_beta.tv_sec - tv_alpha.tv_sec) * 1000000) + (tv_beta.tv_usec - tv_alpha.tv_usec))); #endif return 1; } diff --git a/src/modules/reputation.c b/src/modules/reputation.c index 0b839f675..616fe5712 100644 --- a/src/modules/reputation.c +++ b/src/modules/reputation.c @@ -467,7 +467,7 @@ void reputation_load_db_old(void) #ifdef BENCHMARK gettimeofday(&tv_beta, NULL); unreal_log(ULOG_DEBUG, "reputation", "REPUTATION_BENCHMARK", NULL, - "Reputation benchmark: LOAD DB: $time_msec microseconds", + "[reputation] Benchmark: LOAD DB: $time_msec microseconds", log_data_integer("time_msec", ((tv_beta.tv_sec - tv_alpha.tv_sec) * 1000000) + (tv_beta.tv_usec - tv_alpha.tv_usec))); #endif } diff --git a/src/modules/tkldb.c b/src/modules/tkldb.c index 3e1188564..89675bbf7 100644 --- a/src/modules/tkldb.c +++ b/src/modules/tkldb.c @@ -57,9 +57,10 @@ ModuleHeader MOD_HEADER = { #define WARN_WRITE_ERROR(fname) \ do { \ - sendto_realops_and_log("[tkldb] Error writing to temporary database file " \ - "'%s': %s (DATABASE NOT SAVED)", \ - fname, unrealdb_get_error_string()); \ + unreal_log(ULOG_ERROR, "tkldb", "TKLDB_FILE_WRITE_ERROR", NULL, \ + "[tkldb] Error writing to temporary database file $filename: $system_error", \ + log_data_string("filename", fname), \ + log_data_string("system_error", unrealdb_get_error_string())); \ } while(0) #define R_SAFE(x) \ @@ -368,7 +369,7 @@ int write_tkldb(void) #endif if (rename(tmpfname, cfg.database) < 0) { - sendto_realops_and_log("[tkldb] Error renaming '%s' to '%s': %s (DATABASE NOT SAVED)", tmpfname, cfg.database, strerror(errno)); + config_error("[tkldb] Error renaming '%s' to '%s': %s (DATABASE NOT SAVED)", tmpfname, cfg.database, strerror(errno)); return 0; } #ifdef BENCHMARK @@ -746,12 +747,13 @@ int read_tkldb(void) unrealdb_close(db); if (added_cnt) - sendto_realops_and_log("[tkldb] Re-added %d *-Lines", added_cnt); + config_status("[tkldb] Re-added %d *-Lines", added_cnt); #ifdef BENCHMARK gettimeofday(&tv_beta, NULL); - ircd_log(LOG_ERROR, "[tkldb] Benchmark: LOAD DB: %lld microseconds", - (long long)(((tv_beta.tv_sec - tv_alpha.tv_sec) * 1000000) + (tv_beta.tv_usec - tv_alpha.tv_usec))); + unreal_log(ULOG_DEBUG, "tkldb", "TKLDB_BENCHMARK", NULL, + "[tkldb] Benchmark: LOAD DB: $time_msec microseconds", + log_data_integer("time_msec", ((tv_beta.tv_sec - tv_alpha.tv_sec) * 1000000) + (tv_beta.tv_usec - tv_alpha.tv_usec))); #endif return 1; }