Permalink
Browse files

Enable logging facility for mythccextractor (but default to --verbose…

… none & --logLevel err).
  • Loading branch information...
1 parent 79b5e3f commit e2e2d48966082e48066fc103bf2283f08b442e73 @daniel-kristjansson daniel-kristjansson committed Jul 23, 2011
@@ -121,9 +121,6 @@ bool MythCCExtractorPlayer::run(void)
framesPlayed = 0;
using_null_videoout = true;
- if (OpenFile() < 0)
- return false;
-
decoder->SetDecodeAllSubtitles(true);
SetPlaying(true);
@@ -12,7 +12,35 @@ void MythCCExtractorCommandLineParser::LoadArguments(void)
addHelp();
addSettingsOverride();
addVersion();
- addLogging();
+
+ add(QStringList( QStringList() << "-v" << "--verbose" ), "verbose",
+ "none",
+ "Specify log filtering. Use '-v help' for level info.", "");
+ add("-V", "verboseint", 0U, "",
+ "This option is intended for internal use only.\n"
+ "This option takes an unsigned value corresponding "
+ "to the bitwise log verbosity operator.");
+ add(QStringList( QStringList() << "-l" << "--logfile" << "--logpath" ),
+ "logpath", "",
+ "Writes logging messages to a file at logpath.\n"
+ "If a directory is given, a logfile will be created in that "
+ "directory with a filename of applicationName.date.pid.log.\n"
+ "If a full filename is given, that file will be used.\n"
+ "This is typically used in combination with --daemon, and if used "
+ "in combination with --pidfile, this can be used with log "
+ "rotaters, using the HUP call to inform MythTV to reload the "
+ "file (currently disabled).", "");
+ add(QStringList( QStringList() << "-q" << "--quiet"), "quiet", 0,
+ "Don't log to the console (-q). Don't log anywhere (-q -q)", "");
+ add("--loglevel", "loglevel", "err",
+ "Set the logging level. All log messages at lower levels will be "
+ "discarded.\n"
+ "In descending order: emerg, alert, crit, err, warning, notice, "
+ "info, debug\ndefaults to err", "");
+ add("--syslog", "syslog", "none",
+ "Set the syslog logging facility.\nSet to \"none\" to disable, "
+ "defaults to none", "");
+ add("--nodblog", "nodblog", false, "Disable database logging.", "");
add(QStringList( QStringList() << "-i" << "--infile" ), "inputfile", "",
"input file", "");
@@ -252,25 +252,26 @@ static int RunCCExtract(const ProgramInfo &program_info)
{
if (!program_info.IsLocal())
{
- LOG(VB_GENERAL, LOG_ERR,
- QString("Only locally accessible files are supported (%1).")
- .arg(program_info.GetPathname()));
+ QString msg =
+ QString("Only locally accessible files are supported (%1).")
+ .arg(program_info.GetPathname());
+ cerr << qPrintable(msg) << endl;
return GENERIC_EXIT_INVALID_CMDLINE;
}
QString filename = program_info.GetPathname();
if (!QFile::exists(filename))
{
- LOG(VB_GENERAL, LOG_ERR, QString("Could not open input file (%1).")
- .arg(filename));
+ cerr << qPrintable(
+ QString("Could not open input file (%1).").arg(filename)) << endl;
return GENERIC_EXIT_INVALID_CMDLINE;
}
RingBuffer *tmprbuf = RingBuffer::Create(filename, false);
if (!tmprbuf)
{
- LOG(VB_GENERAL, LOG_ERR,
- QString("Unable to create RingBuffer for %1").arg(filename));
+ cerr << qPrintable(QString("Unable to create RingBuffer for %1")
+ .arg(filename)) << endl;
return GENERIC_EXIT_PERMISSIONS_ERROR;
}
@@ -283,7 +284,16 @@ static int RunCCExtract(const ProgramInfo &program_info)
ctx->SetPlayer(ccp);
ccp->SetPlayerInfo(NULL, NULL, true, ctx);
- ccp->run();
+ if (ccp->OpenFile() < 0)
+ {
+ cerr << "Failed to open " << qPrintable(filename) << endl;
+ return GENERIC_EXIT_NOT_OK;
+ }
+ if (!ccp->run())
+ {
+ cerr << "Failed to decode " << qPrintable(filename) << endl;
+ return GENERIC_EXIT_NOT_OK;
+ }
DumpSubtitleInformation(ccp, program_info.GetPathname());
@@ -307,6 +317,10 @@ int main(int argc, char *argv[])
return GENERIC_EXIT_INVALID_CMDLINE;
}
+ int retval = cmdline.ConfigureLogging("none");
+ if (retval != GENERIC_EXIT_OK)
+ return retval;
+
if (cmdline.toBool("showhelp"))
{
cmdline.PrintHelp();
@@ -333,7 +347,7 @@ int main(int argc, char *argv[])
false/*use gui*/, false/*prompt for backend*/,
false/*bypass auto discovery*/, !useDB/*ignoreDB*/))
{
- LOG(VB_GENERAL, LOG_ERR, "Failed to init MythContext, exiting.");
+ cerr << "Failed to init MythContext, exiting." << endl;
return GENERIC_EXIT_NO_MYTHCONTEXT;
}

0 comments on commit e2e2d48

Please sign in to comment.