diff options
| author | 2022-10-22 20:36:01 +0100 | |
|---|---|---|
| committer | 2022-10-22 21:25:31 +0100 | |
| commit | dc21a3036fec8a147254ecf353fdb6951f31b1fb (patch) | |
| tree | 90281292d0a2c7891908c113fd3b0ffdc23eece0 /src/modules/m_log_sql.cpp | |
| parent | Add 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/m_log_sql.cpp')
| -rw-r--r-- | src/modules/m_log_sql.cpp | 8 |
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; } |
