From dc21a3036fec8a147254ecf353fdb6951f31b1fb Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 22 Oct 2022 20:36:01 +0100 Subject: Avoid spamming opers with notices when a SQL log provider is down. --- src/modules/m_log_sql.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/modules/m_log_sql.cpp') 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; + time_t lastwarning = 0; public: SQLMethod(const dynamic_reference& 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; } -- cgit v1.3.1-10-gc9f91