From cd5637dec3b730364eee639df9f3924b6f368326 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Wed, 7 Dec 2022 12:38:16 -0500 Subject: [PATCH] 2022-12-07 Fred Gleason * Added a 'LogSearchStrings=' directive to the '[Debugging]' section of rd.conf(5). Signed-off-by: Fred Gleason --- ChangeLog | 3 +++ conf/rd.conf-sample | 8 ++++++ lib/rdcartfilter.cpp | 6 +++++ lib/rdconfig.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++ lib/rdconfig.h | 7 ++++++ 5 files changed, 84 insertions(+) diff --git a/ChangeLog b/ChangeLog index ec4336db..568227b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23761,3 +23761,6 @@ fail to appear in the 'Ext Data' column of the 'Edit Log' dialog. 2022-12-06 Fred Gleason * Incremented the package version to 4.0.0rc0int5. +2022-12-07 Fred Gleason + * Added a 'LogSearchStrings=' directive to the '[Debugging]' + section of rd.conf(5). diff --git a/conf/rd.conf-sample b/conf/rd.conf-sample index 9c698f52..9095aa5d 100644 --- a/conf/rd.conf-sample +++ b/conf/rd.conf-sample @@ -207,3 +207,11 @@ TranscodingDelay=0 ; Suppress meter update messages on the notification multicast channel. ; ;SuppressRdcatchMeterUpdates=No + +[Debugging] +; Log all filter search strings 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. +; +; LogSearchStrings=LOG_DEBUG +LogSearchStrings= diff --git a/lib/rdcartfilter.cpp b/lib/rdcartfilter.cpp index 6ee0f6d2..a1ada13e 100644 --- a/lib/rdcartfilter.cpp +++ b/lib/rdcartfilter.cpp @@ -740,6 +740,12 @@ void RDCartFilter::UpdateModel() if((filterSql()!=d_model_filter_sql)||(cartLimit()!=d_model_cart_limit)) { d_model_filter_sql=filterSql(); d_model_cart_limit=cartLimit(); + if(rda->config()->logSearchStrings()) { + rda->syslog(rda->config()->logSearchStringsLevel(), + "searching cart library by string: \"%s\" [%s]", + d_filter_edit->text().toUtf8().constData(), + RDConfig::hexify(d_filter_edit->text()).toUtf8().constData()); + } emit filterChanged(d_model_filter_sql,d_model_cart_limit); } } diff --git a/lib/rdconfig.cpp b/lib/rdconfig.cpp index 12c076cb..8ab05820 100644 --- a/lib/rdconfig.cpp +++ b/lib/rdconfig.cpp @@ -399,6 +399,18 @@ bool RDConfig::suppressRdcatchMeterUpdates() const } +bool RDConfig::logSearchStrings() const +{ + return conf_log_search_strings; +} + + +int RDConfig::logSearchStringsLevel() const +{ + return conf_log_search_strings_level; +} + + int RDConfig::meterBasePort() const { return conf_meter_base_port; @@ -625,6 +637,9 @@ bool RDConfig::load() profile->boolValue("Hacks","DisableMaintChecks",false); conf_suppress_rdcatch_meter_updates= profile->boolValue("Hacks","SuppressRdcatchMeterUpdates",false); + conf_log_search_strings_level= + SyslogPriorityLevel(profile->stringValue("Debugging","LogSearchStrings",""), + &conf_log_search_strings); conf_meter_base_port= profile->intValue("Hacks","MeterPortBaseNumber",RD_DEFAULT_METER_SOCKET_BASE_UDP_PORT); conf_meter_port_range= @@ -754,6 +769,8 @@ void RDConfig::clear() conf_disable_maint_checks=false; conf_save_webget_files_directory=""; conf_suppress_rdcatch_meter_updates=false; + conf_log_search_strings=false; + conf_log_search_strings_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; @@ -854,3 +871,46 @@ QString RDConfig::rdselectExitCodeText(RDSelectExitCode code) return ret; } + + +QString RDConfig::hexify(const QByteArray &data) +{ + QString ret; + + for(int i=0;i levels; + + levels["LOG_EMERG"]=LOG_EMERG; + levels["LOG_ALERT"]=LOG_ALERT; + levels["LOG_CRIT"]=LOG_CRIT; + levels["LOG_ERR"]=LOG_ERR; + levels["LOG_WARNING"]=LOG_WARNING; + levels["LOG_NOTICE"]=LOG_NOTICE; + levels["LOG_INFO"]=LOG_INFO; + levels["LOG_DEBUG"]=LOG_DEBUG; + int ret=levels.value(str.trimmed().toUpper(),-1); + if(ret<0) { + ret=LOG_DEBUG; + *ok=false; + } + else { + *ok=true; + } + + return ret; +} diff --git a/lib/rdconfig.h b/lib/rdconfig.h index d1269d27..9abacdf1 100644 --- a/lib/rdconfig.h +++ b/lib/rdconfig.h @@ -105,6 +105,8 @@ class RDConfig int meterPortRange() const; QString saveWebgetFilesDirectory() const; bool suppressRdcatchMeterUpdates() const; + bool logSearchStrings() const; + int logSearchStringsLevel() const; bool enableMixerLogging() const; uid_t uid() const; gid_t gid() const; @@ -126,8 +128,11 @@ class RDConfig void clear(); static QString createTablePostfix(const QString &engine); static QString rdselectExitCodeText(RDSelectExitCode code); + static QString hexify(const QByteArray &data); + static QString hexify(const QString &str); private: + int SyslogPriorityLevel(const QString &str,bool *ok) const; QString conf_filename; QString conf_module_name; QString conf_mysql_hostname; @@ -175,6 +180,8 @@ class RDConfig int conf_font_default_size; QString conf_http_user_agent; bool conf_disable_maint_checks; + bool conf_log_search_strings; + int conf_log_search_strings_level; bool conf_lock_rdairplay_memory; QString conf_save_webget_files_directory; bool conf_suppress_rdcatch_meter_updates;