Skip to content

Commit

Permalink
Have the --logpath propagate to subcalls
Browse files Browse the repository at this point in the history
With this update, if you give --logpath (with a directory only), it will
propagate that --logpath to calls to mythpreviewgen, mythcommflag,
mythfilldatabase and mythtranscode.  Others could potentially be added if there
is the desire in calls to others as well.
  • Loading branch information
Beirdo committed Jun 22, 2011
1 parent ad8ced5 commit 1edcab8
Show file tree
Hide file tree
Showing 23 changed files with 79 additions and 27 deletions.
3 changes: 2 additions & 1 deletion mythplugins/mytharchive/mytharchivehelper/main.cpp
Expand Up @@ -2639,7 +2639,8 @@ int main(int argc, char **argv)
.arg(MYTH_SOURCE_VERSION));

QString logfile = cmdline.GetLogFilePath();
logStart(logfile, quiet, facility, dblog);
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, dblog, propagate);

gContext = new MythContext(MYTH_BINARY_VERSION);
if (!gContext->Init(false))
Expand Down
3 changes: 2 additions & 1 deletion mythplugins/mythnetvision/mythfillnetvision/main.cpp
Expand Up @@ -108,7 +108,8 @@ int main(int argc, char *argv[])
.arg(MYTH_SOURCE_VERSION));

QString logfile = cmdline.GetLogFilePath();
logStart(logfile, quiet, facility, dblog);
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, dblog, propagate);

gContext = new MythContext(MYTH_BINARY_VERSION);
if (!gContext->Init(false))
Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmyth/mythcommandlineparser.cpp
Expand Up @@ -1587,12 +1587,14 @@ QString MythCommandLineParser::GetLogFilePath(void)
QFileInfo finfo(logfile);
if (finfo.isDir())
{
m_parsed.insert("islogpath", true);
logdir = finfo.filePath();
logfile = QCoreApplication::applicationName() +
QString(".%1").arg(pid) + ".log";
}
else
{
m_parsed.insert("islogpath", false);
logdir = finfo.path();
logfile = finfo.fileName();
}
Expand Down
24 changes: 23 additions & 1 deletion mythtv/libs/libmythbase/mythlogging.cpp
Expand Up @@ -5,6 +5,7 @@
#include <QThread>
#include <QHash>
#include <QCoreApplication>
#include <QFileInfo>

#define _LogLevelNames_
#include "mythlogging.h"
Expand Down Expand Up @@ -55,6 +56,9 @@ LoggerThread logThread;
bool logThreadFinished = false;
bool debugRegistration = false;

bool logPropagateFlag = false;
QString logPropagatePath;

#define TIMESTAMP_MAX 30
#define MAX_STRING_LENGTH 2048

Expand Down Expand Up @@ -718,15 +722,33 @@ void logSighup( int signum, siginfo_t *info, void *secret )
}
}

bool logPropagate(void)
{
return logPropagateFlag;
}

void logStart(QString logfile, int quiet, int facility, bool dblog)
QString &logPropPath(void)
{
return logPropagatePath;
}

void logStart(QString logfile, int quiet, int facility, bool dblog,
bool propagate)
{
LoggerBase *logger;
struct sigaction sa;

if (logThread.isRunning())
return;

logPropagateFlag = propagate;
if (propagate)
{
QFileInfo finfo(logfile);
logPropagatePath = finfo.path();
logPropagatePath.detach();
}

/* log to the console */
if( !quiet )
logger = new FileLogger((char *)"-");
Expand Down
4 changes: 3 additions & 1 deletion mythtv/libs/libmythbase/mythlogging.h
Expand Up @@ -103,8 +103,10 @@ MBASE_PUBLIC void LogPrintLine( uint32_t mask, LogLevel_t level,
}

MBASE_PUBLIC void logStart(QString logfile, int quiet = 0, int facility = 0,
bool dblog = true);
bool dblog = true, bool propagate = false);
MBASE_PUBLIC void logStop(void);
MBASE_PUBLIC bool logPropagate(void);
MBASE_PUBLIC QString &logPropPath(void);
MBASE_PUBLIC void threadRegister(QString name);
MBASE_PUBLIC void threadDeregister(void);
MBASE_PUBLIC int syslogGetFacility(QString facility);
Expand Down
6 changes: 5 additions & 1 deletion mythtv/libs/libmythtv/jobqueue.cpp
Expand Up @@ -1886,7 +1886,9 @@ void JobQueue::DoTranscodeThread(int jobID)
QByteArray parg = profilearg.toAscii();
command = QString("%1 -j %2 -V %3 -p %4 %5")
.arg(path).arg(jobID).arg(print_verbose_messages)
.arg(parg.constData()).arg(useCutlist ? "-l" : "");
.arg(parg.constData()).arg(useCutlist ? "--honorcutlist" : "");
if (logPropagate())
command += QString(" --logpath %1").arg(logPropPath());
}
else
{
Expand Down Expand Up @@ -2125,6 +2127,8 @@ void JobQueue::DoFlagCommercialsThread(int jobID)
path = GetInstallPrefix() + "/bin/mythcommflag";
command = QString("%1 -j %2 -V %3 --noprogress")
.arg(path).arg(jobID).arg(print_verbose_messages);
if (logPropagate())
command += QString(" --logpath %1").arg(logPropPath());
}
else
{
Expand Down
10 changes: 6 additions & 4 deletions mythtv/libs/libmythtv/previewgenerator.cpp
Expand Up @@ -233,16 +233,18 @@ bool PreviewGenerator::Run(void)
else
command += QString(" --frame %1").arg(captureTime);
}
command += " ";
command += QString("--chanid %1 ").arg(programInfo.GetChanID());
command += QString("--starttime %1 ")
command += QString(" --chanid %1").arg(programInfo.GetChanID());
command += QString(" --starttime %1")
.arg(programInfo.GetRecordingStartTime(MythDate));

if (!outFileName.isEmpty())
command += QString("--outfile \"%1\" ").arg(outFileName);
command += QString(" --outfile \"%1\"").arg(outFileName);

command += " --quiet";

if (logPropagate())
command += QString(" --logpath %1").arg(logPropPath());

// Timeout in 30s
uint ret = myth_system(command, kMSDontBlockInputDevs |
kMSDontDisableDrawing |
Expand Down
8 changes: 5 additions & 3 deletions mythtv/libs/libmythtv/sourceutil.cpp
Expand Up @@ -344,11 +344,13 @@ bool SourceUtil::IsAnySourceScanable(void)

bool SourceUtil::UpdateChannelsFromListings(uint sourceid, QString cardtype)
{
QString cmd = "mythfilldatabase --only-update-channels ";
QString cmd = "mythfilldatabase --only-update-channels";
if (sourceid)
cmd += QString("--sourceid %1 ").arg(sourceid);
cmd += QString(" --sourceid %1").arg(sourceid);
if (!cardtype.isEmpty())
cmd += QString("--cardtype %1 ").arg(cardtype);
cmd += QString(" --cardtype %1").arg(cardtype);
if (logPropagate())
cmd += QString(" --logpath %1").arg(logPropPath());

myth_system(cmd);

Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/videosource.cpp
Expand Up @@ -450,7 +450,7 @@ XMLTV_generic_config::XMLTV_generic_config(const VideoSource& _parent,
void XMLTV_generic_config::Save()
{
VerticalConfigurationGroup::Save();
/*
#if 0
QString err_msg = QObject::tr(
"You MUST run 'mythfilldatabase --manual the first time,\n "
"instead of just 'mythfilldatabase'.\nYour grabber does not provide "
Expand All @@ -462,7 +462,7 @@ void XMLTV_generic_config::Save()
MythPopupBox::showOkPopup(
GetMythMainWindow(), QObject::tr("Warning."), err_msg);
}
*/
#endif
}

void XMLTV_generic_config::RunConfig(void)
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythavtest/main.cpp
Expand Up @@ -74,7 +74,8 @@ int main(int argc, char *argv[])
bool dblog = !cmdline.toBool("nodblog");

QString logfile = cmdline.GetLogFilePath();
logStart(logfile, quiet, facility, dblog);
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, dblog, propagate);

if (!cmdline.toString("display").isEmpty())
{
Expand Down
3 changes: 3 additions & 0 deletions mythtv/programs/mythbackend/housekeeper.cpp
Expand Up @@ -422,6 +422,9 @@ void HouseKeeper::RunMFD(void)

QString command = QString("%1 %2").arg(mfpath).arg(mfarg);

if (logPropagate())
command += QString(" --logpath %1").arg(logPropPath());

if (mflog.length())
{
bool dir_writable = false;
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythbackend/main.cpp
Expand Up @@ -134,7 +134,8 @@ int main(int argc, char **argv)
gContext = new MythContext(MYTH_BINARY_VERSION);

logfile = cmdline.GetLogFilePath();
logStart(logfile, quiet, facility, dblog);
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, dblog, propagate);

if (cmdline.toBool("event") || cmdline.toBool("systemevent") ||
cmdline.toBool("setverbose") || cmdline.toBool("printsched") ||
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythcommflag/main.cpp
Expand Up @@ -1108,7 +1108,8 @@ int main(int argc, char *argv[])
CleanupGuard callCleanup(cleanup);

QString logfile = cmdline.GetLogFilePath();
logStart(logfile, quiet, facility, dblog);
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, dblog, propagate);

gContext = new MythContext(MYTH_BINARY_VERSION);
if (!gContext->Init(
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythfilldatabase/main.cpp
Expand Up @@ -283,7 +283,8 @@ int main(int argc, char *argv[])
CleanupGuard callCleanup(cleanup);

QString logfile = cmdline.GetLogFilePath();
logStart(logfile, quiet, facility, dblog);
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, dblog, propagate);

gContext = new MythContext(MYTH_BINARY_VERSION);
if (!gContext->Init(false))
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythfrontend/main.cpp
Expand Up @@ -1463,7 +1463,8 @@ int main(int argc, char **argv)
gContext = new MythContext(MYTH_BINARY_VERSION);

logfile = cmdline.GetLogFilePath();
logStart(logfile, quiet, facility, dblog);
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, dblog, propagate);

if (!cmdline.toBool("noupnp"))
{
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythjobqueue/main.cpp
Expand Up @@ -130,7 +130,8 @@ int main(int argc, char *argv[])
CleanupGuard callCleanup(cleanup);

logfile = cmdline.GetLogFilePath();
logStart(logfile, quiet, facility, dblog);
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, dblog, propagate);

ofstream pidfs;
if (pidfile.size())
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythlcdserver/main.cpp
Expand Up @@ -81,7 +81,8 @@ int main(int argc, char **argv)
bool dblog = !cmdline.toBool("nodblog");

logfile = cmdline.GetLogFilePath();
logStart(logfile, quiet, facility, dblog);
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, dblog, propagate);


if (cmdline.toBool("port"))
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythmediaserver/main.cpp
Expand Up @@ -131,7 +131,8 @@ int main(int argc, char *argv[])
CleanupGuard callCleanup(cleanup);

QString logfile = cmdline.GetLogFilePath();
logStart(logfile, quiet, facility, dblog);
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, dblog, propagate);

ofstream pidfs;
if (pidfile.size())
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythpreviewgen/main.cpp
Expand Up @@ -217,7 +217,8 @@ int main(int argc, char **argv)
CleanupGuard callCleanup(cleanup);

QString logfile = cmdline.GetLogFilePath();
logStart(logfile, quiet, facility, dblog);
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, dblog, propagate);

if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
VERBOSE(VB_IMPORTANT, LOC_WARN + "Unable to ignore SIGPIPE");
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythshutdown/main.cpp
Expand Up @@ -818,7 +818,8 @@ int main(int argc, char **argv)
}

QString logfile = cmdline.GetLogFilePath();
logStart(logfile, quiet, facility, dblog);
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, dblog, propagate);

gContext = new MythContext(MYTH_BINARY_VERSION);
if (!gContext->Init(false))
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythtranscode/main.cpp
Expand Up @@ -299,7 +299,8 @@ int main(int argc, char *argv[])
bool dblog = !cmdline.toBool("nodblog");

QString logfile = cmdline.GetLogFilePath();
logStart(logfile, quiet, facility, dblog);
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, dblog, propagate);

// Load the context
MythContext context(MYTH_BINARY_VERSION);
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythtv-setup/main.cpp
Expand Up @@ -311,7 +311,8 @@ int main(int argc, char *argv[])
scanInputName = cmdline.toString("inputname");

logfile = cmdline.GetLogFilePath();
logStart(logfile, quiet, facility, dblog);
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, dblog, propagate);

if (!display.isEmpty())
{
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythwelcome/main.cpp
Expand Up @@ -93,7 +93,8 @@ int main(int argc, char **argv)
bool dblog = !cmdline.toBool("nodblog");

logfile = cmdline.GetLogFilePath();
logStart(logfile, quiet, facility, dblog);
bool propagate = cmdline.toBool("islogpath");
logStart(logfile, quiet, facility, dblog, propagate);

gContext = new MythContext(MYTH_BINARY_VERSION);
if (!gContext->Init())
Expand Down

0 comments on commit 1edcab8

Please sign in to comment.