aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-10-22 20:36:01 +0100
committerGravatar Sadie Powell2022-10-22 21:25:31 +0100
commitdc21a3036fec8a147254ecf353fdb6951f31b1fb (patch)
tree90281292d0a2c7891908c113fd3b0ffdc23eece0 /src/modules
parentAdd a workaround for a conflict between libmysqlclient and pcre2. (diff)
Avoid spamming opers with notices when a SQL log provider is down.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_log_sql.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/modules/m_log_sql.cpp b/src/modules/m_log_sql.cpp
index 7e02d43f9..4ace5ad3a 100644
--- a/src/modules/m_log_sql.cpp
+++ b/src/modules/m_log_sql.cpp
@@ -51,6 +51,7 @@ class SQLMethod final
private:
std::string query;
dynamic_reference<SQL::Provider> sql;
+ time_t lastwarning = 0;
public:
SQLMethod(const dynamic_reference<SQL::Provider>& s, const std::string& q)
@@ -63,7 +64,12 @@ public:
{
if (!sql)
{
- ServerInstance->SNO.WriteGlobalSno('a', "Unable to write to SQL log (database %s not available).", sql->GetId().c_str());
+ // Only give a warning every 5 minutes to avoid log spam.
+ if (ServerInstance->Time() - lastwarning > 300)
+ {
+ lastwarning = ServerInstance->Time();
+ ServerInstance->SNO.WriteGlobalSno('a', "Unable to write to SQL log (database %s not available).", sql->GetId().c_str());
+ }
return;
}