2024-04-26 Fred Gleason <fredg@paravelsystems.com>

* Added a 'KillPypadAfterError=' directive to the '[Debugging]'
	section of rd.conf(5).
	* Documented the '[Debugging]' section in the rd.conf(5) man page.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2024-04-26 13:18:45 -04:00
parent 43761e9508
commit fe58694448
6 changed files with 122 additions and 6 deletions

View File

@ -24726,3 +24726,7 @@
* Fixed a regression in rdlibrary(1) that caused output of the Cart * Fixed a regression in rdlibrary(1) that caused output of the Cart
Report to not reflect the current filter and sorting state of the Report to not reflect the current filter and sorting state of the
library list. library list.
2024-04-26 Fred Gleason <fredg@paravelsystems.com>
* Added a 'KillPypadAfterError=' directive to the '[Debugging]'
section of rd.conf(5).
* Documented the '[Debugging]' section in the rd.conf(5) man page.

View File

@ -929,7 +929,7 @@ class Receiver(object):
# Open the syslog # Open the syslog
pypad_name=sys.argv[0].split('/')[-1] pypad_name=sys.argv[0].split('/')[-1]
syslog.openlog(pypad_name,logoption=syslog.LOG_PID,facility=int(rd_config.get('Identity','SyslogFacility',fallback=syslog.LOG_USER))) syslog.openlog(pypad_name,logoption=syslog.LOG_PID|syslog.LOG_PERROR,facility=int(rd_config.get('Identity','SyslogFacility',fallback=syslog.LOG_USER)))
# Connect to the PAD feed # Connect to the PAD feed
sock=socket.socket(socket.AF_INET) sock=socket.socket(socket.AF_INET)
@ -960,9 +960,18 @@ class Receiver(object):
linebytes=line.decode('utf-8','replace') linebytes=line.decode('utf-8','replace')
msg+=linebytes msg+=linebytes
if linebytes=='\n': if linebytes=='\n':
jdata=json.loads(msg) ok=False
if (not self.__active_now_groups and not self.__active_next_groups) or (jdata['padUpdate'] is not None and jdata['padUpdate']['now'] is not None and jdata['padUpdate']['now']['groupName'] in self.__active_now_groups) or (jdata['padUpdate'] is not None and jdata['padUpdate']['next'] is not None and jdata['padUpdate']['next']['groupName'] in self.__active_next_groups): try:
self.__pypad_Process(Update(jdata,self.__config_parser,rd_config)) jdata=json.loads(msg)
ok=True
except:
priority=syslog.LOG_WARNING|(int(rd_config.get('Identity','SyslogFacility',fallback=syslog.LOG_USER))<<3)
syslog.syslog(priority,'error parsing JSON: "'+msg+'"')
if rd_config.get('Debugging','KillPypadAfterJsonError',fallback='no').lower()=='yes':
sys.exit(1)
if ok:
if (not self.__active_now_groups and not self.__active_next_groups) or (jdata['padUpdate'] is not None and jdata['padUpdate']['now'] is not None and jdata['padUpdate']['now']['groupName'] in self.__active_now_groups) or (jdata['padUpdate'] is not None and jdata['padUpdate']['next'] is not None and jdata['padUpdate']['next']['groupName'] in self.__active_next_groups):
self.__pypad_Process(Update(jdata,self.__config_parser,rd_config))
msg="" msg=""
line=bytes() line=bytes()
if self.__timer_interval!=None: if self.__timer_interval!=None:

View File

@ -276,3 +276,8 @@ LogLogRefresh=
; priority levels. An empty argument disables logging. ; priority levels. An empty argument disables logging.
; LogSqlQueries=LOG_DEBUG ; LogSqlQueries=LOG_DEBUG
LogSqlQueries= LogSqlQueries=
; Kill a PyPAD script if it encounters a JSON parsing error. This should
; generate a useful error message in
; RDAdmin->ManageHosts->PyPADInstances->ErrorLog.
KillPypadAfterJsonError=No

View File

@ -901,6 +901,93 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
<variablelist>
<varlistentry>
<term>
<userinput>[Debugging]</userinput>
</term>
<listitem>
<para>
The directives in this section can send large amounts of data to the
syslog. These directives should be enabled for debugging purposes
only!
</para>
<variablelist>
<varlistentry>
<term>
<userinput>LogSearchString = <replaceable>level</replaceable></userinput>
</term>
<listitem>
<para>
Log all cart filter search strings to the syslog, at the
<replaceable>level</replaceable> priority level.
</para>
<para>
See the 'level' parameter in the syslog(3) man page for the
set of available priority levels. An empty argument disables
logging.
</para>
</listitem>
</varlistentry>
</variablelist>
<variablelist>
<varlistentry>
<term>
<userinput>LogLogRefresh = <replaceable>level</replaceable></userinput>
</term>
<listitem>
<para>
Send detailed debugging information to the syslog at priority
<replaceable>level</replaceable> whenever a log refresh
is performed in
<command>rdairplay</command><manvolnum>1</manvolnum> or
<command>rdvairplayd</command><manvolnum>8</manvolnum>.
</para>
<para>
See the 'level' parameter in the syslog(3) man page for the
set of available priority levels. An empty argument disables
logging.
</para>
</listitem>
</varlistentry>
</variablelist>
<variablelist>
<varlistentry>
<term>
<userinput>LogSqlQueries = <replaceable>level</replaceable></userinput>
</term>
<listitem>
<para>
Send all SQL queries (including 'select' queries) to the
syslog at the <replaceable>level</replaceable> priority
level.
</para>
<para>
See the 'level' parameter in the syslog(3) man page for the
set of available priority levels. An empty argument disables
logging.
</para>
</listitem>
</varlistentry>
</variablelist>
<variablelist>
<varlistentry>
<term>
<userinput>KillPypadAfterJsonError = Yes</userinput>|<userinput>No</userinput>
</term>
<listitem>
<para>
Kill a PyPAD script if it encounters a JSON parsing error.
This should generate a useful error message in
RDAdmin->ManageHosts->PyPADInstances->ErrorLog.
</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
</variablelist>
</refsect1> </refsect1>
<refsect1 id='bugs'><title>Bugs</title> <refsect1 id='bugs'><title>Bugs</title>

View File

@ -2,7 +2,7 @@
// //
// A container class for a Rivendell Base Configuration // A container class for a Rivendell Base Configuration
// //
// (C) Copyright 2002-2023 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2024 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as // it under the terms of the GNU General Public License version 2 as
@ -435,6 +435,12 @@ bool RDConfig::logSqlQueries() const
} }
bool RDConfig::killPypadAfterJsonError() const
{
return conf_kill_pypad_after_json_error;
}
int RDConfig::logSqlQueriesLevel() const int RDConfig::logSqlQueriesLevel() const
{ {
return conf_log_sql_queries_level; return conf_log_sql_queries_level;
@ -696,6 +702,8 @@ bool RDConfig::load()
conf_log_sql_queries_level= conf_log_sql_queries_level=
SyslogPriorityLevel(profile->stringValue("Debugging","LogSqlQueries",""), SyslogPriorityLevel(profile->stringValue("Debugging","LogSqlQueries",""),
&conf_log_sql_queries); &conf_log_sql_queries);
conf_kill_pypad_after_json_error=
profile->boolValue("Debugging","KillPypadAfterJsonError");
conf_meter_base_port= conf_meter_base_port=
profile->intValue("Hacks","MeterPortBaseNumber",RD_DEFAULT_METER_SOCKET_BASE_UDP_PORT); profile->intValue("Hacks","MeterPortBaseNumber",RD_DEFAULT_METER_SOCKET_BASE_UDP_PORT);
conf_meter_port_range= conf_meter_port_range=
@ -838,6 +846,7 @@ void RDConfig::clear()
conf_log_log_refresh_level=LOG_DEBUG; conf_log_log_refresh_level=LOG_DEBUG;
conf_log_sql_queries=false; conf_log_sql_queries=false;
conf_log_sql_queries_level=LOG_DEBUG; conf_log_sql_queries_level=LOG_DEBUG;
conf_kill_pypad_after_json_error=false;
conf_lock_rdairplay_memory=false; conf_lock_rdairplay_memory=false;
conf_meter_base_port=RD_DEFAULT_METER_SOCKET_BASE_UDP_PORT; conf_meter_base_port=RD_DEFAULT_METER_SOCKET_BASE_UDP_PORT;
conf_meter_port_range=RD_METER_SOCKET_PORT_RANGE; conf_meter_port_range=RD_METER_SOCKET_PORT_RANGE;

View File

@ -2,7 +2,7 @@
// //
// A container class for a Rivendell Base Configuration // A container class for a Rivendell Base Configuration
// //
// (C) Copyright 2002-2023 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2024 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as // it under the terms of the GNU General Public License version 2 as
@ -112,6 +112,7 @@ class RDConfig
int logLogRefreshLevel() const; int logLogRefreshLevel() const;
bool logSqlQueries() const; bool logSqlQueries() const;
int logSqlQueriesLevel() const; int logSqlQueriesLevel() const;
bool killPypadAfterJsonError() const;
bool enableMixerLogging() const; bool enableMixerLogging() const;
bool testOutputStreams() const; bool testOutputStreams() const;
uid_t uid() const; uid_t uid() const;
@ -193,6 +194,7 @@ class RDConfig
bool conf_log_log_refresh; bool conf_log_log_refresh;
int conf_log_log_refresh_level; int conf_log_log_refresh_level;
bool conf_log_sql_queries; bool conf_log_sql_queries;
bool conf_kill_pypad_after_json_error;
int conf_log_sql_queries_level; int conf_log_sql_queries_level;
bool conf_lock_rdairplay_memory; bool conf_lock_rdairplay_memory;
QString conf_save_webget_files_directory; QString conf_save_webget_files_directory;