2019-06-21 Fred Gleason <fredg@paravelsystems.com>

* Added a 'SyslogFacility=' directive to the '[Identity']
	section of rd.conf(5).
	* Added a 'syslog.openlog()' call to the constructor of the
	'PyPAD.Receiver' class.
	* Removed the 'syslog.openlog()' call from the 'pypad_icecast2.py'
	script.
	* Removed the 'syslog.openlog()' call from the 'pypad_live365.py'
	script.
	* Removed the 'syslog.openlog()' call from the 'pypad_serial.py'
	script.
	* Removed the 'syslog.openlog()' call from the 'pypad_shoutcast1.py'
	script.
	* Removed the 'syslog.openlog()' call from the 'pypad_spinitron.py'
	script.
	* Removed the 'syslog.openlog()' call from the 'pypad_tunein.py'
	script.
	* Removed the 'syslog.openlog()' call from the 'pypad_urlwrite.py'
	script.
	* Removed the 'syslog.openlog()' call from the 'pypad_walltime.py'
	script.
	* Removed the 'syslog.openlog()' call from the 'pypad_xcmd.py'
	script.
	* Removed the 'syslog.openlog()' call from the 'pypad_xmpad.py'
	script.
This commit is contained in:
Fred Gleason 2019-06-21 18:57:33 -04:00
parent f30d684644
commit 52dc14a3b3
20 changed files with 102 additions and 73 deletions

View File

@ -18800,3 +18800,28 @@
saved properly.
2019-06-20 Fred Gleason <fredg@paravelsystems.com>
* Updated 'CODINGSTYLE'.
2019-06-21 Fred Gleason <fredg@paravelsystems.com>
* Added a 'SyslogFacility=' directive to the '[Identity']
section of rd.conf(5).
* Added a 'syslog.openlog()' call to the constructor of the
'PyPAD.Receiver' class.
* Removed the 'syslog.openlog()' call from the 'pypad_icecast2.py'
script.
* Removed the 'syslog.openlog()' call from the 'pypad_live365.py'
script.
* Removed the 'syslog.openlog()' call from the 'pypad_serial.py'
script.
* Removed the 'syslog.openlog()' call from the 'pypad_shoutcast1.py'
script.
* Removed the 'syslog.openlog()' call from the 'pypad_spinitron.py'
script.
* Removed the 'syslog.openlog()' call from the 'pypad_tunein.py'
script.
* Removed the 'syslog.openlog()' call from the 'pypad_urlwrite.py'
script.
* Removed the 'syslog.openlog()' call from the 'pypad_walltime.py'
script.
* Removed the 'syslog.openlog()' call from the 'pypad_xcmd.py'
script.
* Removed the 'syslog.openlog()' call from the 'pypad_xmpad.py'
script.

View File

@ -18,6 +18,7 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
import os.path
import configparser
import datetime
import MySQLdb
@ -25,6 +26,7 @@ import signal
import selectors
import socket
import sys
import syslog
import json
#
@ -831,6 +833,15 @@ class Receiver(object):
# So we exit cleanly when shutdown by rdpadengined(8)
signal.signal(signal.SIGTERM,SigHandler)
# Open the configuration file
config=configparser.ConfigParser(interpolation=None)
config.readfp(open('/etc/rd.conf'))
# Open the syslog
pypad_name=sys.argv[0].split('/')[-1]
syslog.openlog(pypad_name,logoption=syslog.LOG_PID,facility=config.get('Identity','SyslogFacility',fallback=syslog.LOG_USER))
# Connect to the PAD feed
sock=socket.socket(socket.AF_INET)
conn=sock.connect((hostname,port))
timeout=None

View File

@ -4,7 +4,7 @@
#
# Send PAD updates to Icecast2 mountpoint
#
# (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
# (C) Copyright 2018-2019 Fred Gleason <fredg@paravelsystems.com>
#
# 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
@ -20,7 +20,7 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
import os
import os.path
import sys
import socket
import requests
@ -70,13 +70,7 @@ def ProcessPad(update):
#
# Program Name
#
pypad_name=os.path.basename(__file__)
#
# Open Syslog
#
syslog.openlog(pypad_name,logoption=syslog.LOG_PID,facility=syslog.LOG_DAEMON)
pypad_name=sys.argv[0].split('/')[-1]
#
# Create Send Socket

View File

@ -64,8 +64,6 @@ def ProcessPad(update):
#
# 'Main' function
#
syslog.openlog(sys.argv[0].split('/')[-1])
rcvr=pypad.Receiver()
try:
rcvr.setConfigFile(sys.argv[3])

View File

@ -57,8 +57,6 @@ def ProcessPad(update):
#
# 'Main' function
#
syslog.openlog(sys.argv[0].split('/')[-1])
rcvr=pypad.Receiver()
try:
rcvr.setConfigFile(sys.argv[3])

View File

@ -4,7 +4,7 @@
#
# Write PAD updates to a Shoutcast 1 instance
#
# (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
# (C) Copyright 2018-2019 Fred Gleason <fredg@paravelsystems.com>
#
# 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
@ -71,8 +71,6 @@ def ProcessPad(update):
#
# 'Main' function
#
syslog.openlog(sys.argv[0].split('/')[-1])
rcvr=pypad.Receiver()
try:
rcvr.setConfigFile(sys.argv[3])

View File

@ -4,7 +4,7 @@
#
# Write PAD updates to the Spinitron Playlist Service
#
# (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
# (C) Copyright 2018-2019 Fred Gleason <fredg@paravelsystems.com>
#
# 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
@ -116,8 +116,6 @@ def ProcessPad(update):
#
# 'Main' function
#
syslog.openlog(sys.argv[0].split('/')[-1])
rcvr=pypad.Receiver()
try:
rcvr.setConfigFile(sys.argv[3])

View File

@ -4,7 +4,7 @@
#
# Send PAD updates to TuneIn
#
# (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
# (C) Copyright 2018-2019 Fred Gleason <fredg@paravelsystems.com>
#
# 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
@ -76,13 +76,7 @@ def ProcessPad(update):
#
# Program Name
#
pypad_name=os.path.basename(__file__)
#
# Open Syslog
#
syslog.openlog(pypad_name,logoption=syslog.LOG_PID,facility=syslog.LOG_DAEMON)
pypad_name=sys.argv[0].split('/')[-1]
#
# Create Send Socket

View File

@ -4,7 +4,7 @@
#
# Write PAD updates to arbitrary URLs
#
# (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
# (C) Copyright 2018-2019 Fred Gleason <fredg@paravelsystems.com>
#
# 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
@ -57,8 +57,6 @@ def ProcessPad(update):
#
# 'Main' function
#
syslog.openlog(sys.argv[0].split('/')[-1])
rcvr=pypad.Receiver()
try:
rcvr.setConfigFile(sys.argv[3])

View File

@ -4,7 +4,7 @@
#
# Write PAD updates a WallTime text widget.
#
# (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
# (C) Copyright 2018-2019 Fred Gleason <fredg@paravelsystems.com>
#
# 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
@ -57,8 +57,6 @@ def ProcessPad(update):
#
# 'Main' function
#
syslog.openlog(sys.argv[0].split('/')[-1])
rcvr=pypad.Receiver()
try:
rcvr.setConfigFile(sys.argv[3])

View File

@ -191,12 +191,7 @@ def ProcessPad(update):
#
# Program Name
#
pypad_name=os.path.basename(__file__)
#
# Open Syslog
#
syslog.openlog(pypad_name,logoption=syslog.LOG_PID,facility=syslog.LOG_DAEMON)
pypad_name=sys.argv[0].split('/')[-1]
rcvr=pypad.Receiver()
try:

View File

@ -4,7 +4,7 @@
#
# Write PAD updates to a Sirius/XM channel
#
# (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
# (C) Copyright 2018-2019 Fred Gleason <fredg@paravelsystems.com>
#
# 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
@ -171,8 +171,6 @@ def ProcessPad(update):
#
# 'Main' function
#
syslog.openlog(sys.argv[0].split('/')[-1])
rcvr=pypad.Receiver()
try:
rcvr.setConfigFile(sys.argv[3])

View File

@ -21,6 +21,19 @@ PypadGroup=pypad
RnRmlOwner=rivendell
RnRmlGroup=rivendell
; This entry defines what Facility number Rivendell will use when sending
; messages to the syslog system. The following values are recognized:
; 1 - USER (the default)
; 16 - LOCAL0
; 17 - LOCAL1
; 18 - LOCAL2
; 19 - LOCAL3
; 20 - LOCAL4
; 21 - LOCAL5
; 22 - LOCAL6
; 23 - LOCAL7
SyslogFacility=1
; This password is used by the various Rivendell modules to log into
; Rivendell system services [caed(8), ripcd(8), rdcatchd(8)].
Password=letmein

View File

@ -19,6 +19,7 @@
//
#include <stdlib.h>
#include <syslog.h>
#include <qapplication.h>
#include <qobject.h>
@ -135,6 +136,16 @@ bool RDApplication::open(QString *err_msg,RDApplication::ErrorType *err_type,
app_config->load();
app_config->setModuleName(app_module_name);
//
// Initialize Logging
//
if(app_cmd_switch->debugActive()) {
openlog(app_command_name,LOG_PERROR,app_config->syslogFacility());
}
else {
openlog(app_command_name,0,app_config->syslogFacility());
}
//
// Check Rivendell Service Status
//
@ -259,12 +270,6 @@ RDUser *RDApplication::user()
return app_user;
}
/*
void RDApplication::log(RDConfig::LogPriority prio,const QString &msg)
{
app_config->log(app_module_name,prio,msg);
}
*/
bool RDApplication::dropTable(const QString &tbl_name)
{

View File

@ -2,7 +2,7 @@
//
// Process Rivendell Command-Line Switches
//
// (C) Copyright 2002-2005,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -29,7 +29,7 @@
RDCmdSwitch::RDCmdSwitch(int argc,char *argv[],const char *modname,
const char *usage)
{
bool debug=false;
switch_debug=false;
for(int i=1;i<argc;i++) {
QString value=QString::fromUtf8(argv[i]);
@ -42,7 +42,7 @@ RDCmdSwitch::RDCmdSwitch(int argc,char *argv[],const char *modname,
exit(0);
}
if(value=="-d") {
debug=true;
switch_debug=true;
}
QStringList f0=value.split("=");
if(f0.size()>=2) {
@ -59,16 +59,6 @@ RDCmdSwitch::RDCmdSwitch(int argc,char *argv[],const char *modname,
switch_processed.push_back(false);
}
}
//
// Initialize Logging
//
if(debug) {
openlog(modname,LOG_PERROR,LOG_USER);
}
else {
openlog(modname,0,LOG_USER);
}
}
@ -111,3 +101,9 @@ bool RDCmdSwitch::allProcessed() const
}
return true;
}
bool RDCmdSwitch::debugActive() const
{
return switch_debug;
}

View File

@ -2,7 +2,7 @@
//
// Process Rivendell Command-Line Switches
//
// (C) Copyright 2002-2005,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -24,7 +24,6 @@
#include <vector>
#include <qstring.h>
class RDCmdSwitch
{
public:
@ -35,11 +34,13 @@ class RDCmdSwitch
bool processed(unsigned n) const;
void setProcessed(unsigned n,bool state);
bool allProcessed() const;
bool debugActive() const;
private:
std::vector<QString> switch_keys;
std::vector<QString> switch_values;
std::vector<bool> switch_processed;
bool switch_debug;
};

View File

@ -18,14 +18,15 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <sys/types.h>
#include <sys/stat.h>
#include <pwd.h>
#include <grp.h>
#include <pwd.h>
#include <syslog.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <qdatetime.h>
#include <qmessagebox.h>
@ -321,6 +322,12 @@ QString RDConfig::rnRmlGroup() const
}
int RDConfig::syslogFacility() const
{
return conf_syslog_facility;
}
int RDConfig::jackConnections() const
{
return conf_jack_ports[0].size();
@ -563,6 +570,7 @@ bool RDConfig::load()
RD_DEFAULT_RN_RML_GROUP)))!=NULL) {
conf_rn_rml_gid=groups->gr_gid;
}
conf_syslog_facility=profile->intValue("Identity","SyslogFacility",LOG_USER);
conf_enable_mixer_logging=profile->boolValue("Caed","EnableMixerLogging");
conf_use_realtime=profile->boolValue("Tuning","UseRealtime",false);
@ -642,6 +650,7 @@ void RDConfig::clear()
conf_pypad_group="";
conf_rn_rml_owner="";
conf_rn_rml_group="";
conf_syslog_facility=LOG_USER;
conf_audio_root=RD_AUDIO_ROOT;
conf_audio_extension=RD_AUDIO_EXTENSION;
conf_label=RD_DEFAULT_LABEL;

View File

@ -82,6 +82,7 @@ class RDConfig
QString pypadGroup() const;
QString rnRmlOwner() const;
QString rnRmlGroup() const;
int syslogFacility() const;
QString audioRoot() const;
QString audioExtension() const;
QString audioFileName (QString cutname);
@ -149,6 +150,7 @@ class RDConfig
QString conf_pypad_group;
QString conf_rn_rml_owner;
QString conf_rn_rml_group;
int conf_syslog_facility;
QString conf_audio_root;
QString conf_audio_extension;
QString conf_label;

View File

@ -60,11 +60,6 @@ MainObject::MainObject(QObject *parent)
svc_startup_target=MainObject::TargetAll;
//
// Open the syslog
//
openlog("rdservice",LOG_PERROR,LOG_DAEMON);
//
// Check for prior instance
//

View File

@ -2,7 +2,7 @@
//
// A utility for displaying messages on the desktop
//
// (C) Copyright 2009-2018 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2009-2019 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -29,6 +29,7 @@
#include <rd.h>
#include <rdcmd_switch.h>
#include <rdconfig.h>
#include <rdpopup.h>
@ -75,7 +76,9 @@ int main(int argc,char *argv[])
//
// Open the syslog
//
openlog("rdpopup",LOG_ODELAY,LOG_USER);
RDConfig *config=new RDConfig();
config->load();
openlog("rdpopup",LOG_ODELAY,config->syslogFacility());
//
// Get Severity Value