From f1d2c02862dd63147e9e6ab969eb07d91d997a29 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Fri, 16 Dec 2022 11:39:03 -0500 Subject: [PATCH] 2022-12-16 Fred Gleason * Added a 'LogSqlQueries=' directive to the '[Debugging]' section of rd.conf(5). Signed-off-by: Fred Gleason --- ChangeLog | 3 +++ conf/rd.conf-sample | 9 ++++++++- lib/rdconfig.cpp | 17 +++++++++++++++++ lib/rdconfig.h | 4 ++++ lib/rddb.cpp | 4 ++++ 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2e289468..c2869344 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23818,3 +23818,6 @@ 2022-12-14 Fred Gleason * Fixed a regression in rdlogedit(1) that broke the 'Estimated' start time mode. +2022-12-16 Fred Gleason + * Added a 'LogSqlQueries=' directive to the '[Debugging]' + section of rd.conf(5). diff --git a/conf/rd.conf-sample b/conf/rd.conf-sample index 49300655..a527af69 100644 --- a/conf/rd.conf-sample +++ b/conf/rd.conf-sample @@ -225,4 +225,11 @@ LogSearchStrings= ; See the 'level' parameter in the syslog(3) man page for the set of available ; priority levels. An empty argument disables logging. ; LogLogRefresh=LOG_DEBUG -LogLogRefresh= \ No newline at end of file +LogLogRefresh= + +; Send all SQL queries (including 'select' queries) to the syslog at the +; specified priority level. +; See the 'level' parameter in the syslog(3) man page for the set of available +; priority levels. An empty argument disables logging. +; LogSqlQueries=LOG_DEBUG +LogSqlQueries= diff --git a/lib/rdconfig.cpp b/lib/rdconfig.cpp index 1a2ca166..39101753 100644 --- a/lib/rdconfig.cpp +++ b/lib/rdconfig.cpp @@ -423,6 +423,18 @@ int RDConfig::logLogRefreshLevel() const } +bool RDConfig::logSqlQueries() const +{ + return conf_log_sql_queries; +} + + +int RDConfig::logSqlQueriesLevel() const +{ + return conf_log_sql_queries_level; +} + + int RDConfig::meterBasePort() const { return conf_meter_base_port; @@ -655,6 +667,9 @@ bool RDConfig::load() conf_log_log_refresh_level= SyslogPriorityLevel(profile->stringValue("Debugging","LogLogRefresh",""), &conf_log_log_refresh); + conf_log_sql_queries_level= + SyslogPriorityLevel(profile->stringValue("Debugging","LogSqlQueries",""), + &conf_log_sql_queries); conf_meter_base_port= profile->intValue("Hacks","MeterPortBaseNumber",RD_DEFAULT_METER_SOCKET_BASE_UDP_PORT); conf_meter_port_range= @@ -788,6 +803,8 @@ void RDConfig::clear() conf_log_search_strings_level=LOG_DEBUG; conf_log_log_refresh=false; conf_log_log_refresh_level=LOG_DEBUG; + conf_log_sql_queries=false; + conf_log_sql_queries_level=LOG_DEBUG; conf_lock_rdairplay_memory=false; conf_meter_base_port=RD_DEFAULT_METER_SOCKET_BASE_UDP_PORT; conf_meter_port_range=RD_METER_SOCKET_PORT_RANGE; diff --git a/lib/rdconfig.h b/lib/rdconfig.h index a9f23597..d15752bc 100644 --- a/lib/rdconfig.h +++ b/lib/rdconfig.h @@ -109,6 +109,8 @@ class RDConfig int logSearchStringsLevel() const; bool logLogRefresh() const; int logLogRefreshLevel() const; + bool logSqlQueries() const; + int logSqlQueriesLevel() const; bool enableMixerLogging() const; uid_t uid() const; gid_t gid() const; @@ -186,6 +188,8 @@ class RDConfig int conf_log_search_strings_level; bool conf_log_log_refresh; int conf_log_log_refresh_level; + bool conf_log_sql_queries; + int conf_log_sql_queries_level; bool conf_lock_rdairplay_memory; QString conf_save_webget_files_directory; bool conf_suppress_rdcatch_meter_updates; diff --git a/lib/rddb.cpp b/lib/rddb.cpp index 01b33859..e6c85a20 100644 --- a/lib/rddb.cpp +++ b/lib/rddb.cpp @@ -65,6 +65,10 @@ RDSqlQuery::RDSqlQuery (const QString &query,bool reconnect): } if(isActive()) { + if((rda!=NULL)&&(rda->config()->logSqlQueries())) { + rda->syslog(rda->config()->logSqlQueriesLevel(), + "SQL: %s",query.toUtf8().constData()); + } //printf("QUERY: %s\n",(const char *)query.toUtf8()); QStringList f0=query.split(" "); if(f0[0].toLower()=="select") {