Changeset f124159c7 in mythtv


Ignore:
Timestamp:
Aug 27, 2013, 4:16:29 AM (11 years ago)
Author:
Jean-Yves Avenard <jyavenard@…>
Branches:
devel/2020-player, devel/ffmpeg-resync, fixes/0.27, fixes/0.28, fixes/29, fixes/30, fixes/31, github-templates, master
Children:
3a73d8919
Parents:
a74baed2b
Message:

Add —nologserver option

This will limit all logs to console, disabling file, db and syslog.
If enabled, mythlogserver will never be started; or if built without mythlogserver, two extra threads won’t be created

Ref #11230 and #11784: not a fix, but allow to bypass the issue

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • mythplugins/mytharchive/mytharchive/archiveutil.cpp

    ra74baed2b rf124159c7  
    251251    if (logPropagateQuiet())
    252252        command += " --quiet";
     253    if (logPropagateNoServer())
     254        command += " --nologserver";
    253255
    254256    uint flags = kMSDontBlockInputDevs | kMSDontDisableDrawing;
  • mythplugins/mytharchive/mytharchive/mythburn.cpp

    ra74baed2b rf124159c7  
    12221222    if (logPropagateQuiet())
    12231223        commandline += " --quiet";
     1224    if (logPropagateNoServer())
     1225        commandline += " --nologserver";
    12241226    commandline += " > "  + logDir + "/progress.log 2>&1 &";
    12251227
  • mythtv/libs/libmythbase/logging.cpp

    ra74baed2b rf124159c7  
    8282    bool    dblog;
    8383    QString path;
     84    bool    noserver;
    8485} LogPropagateOpts;
    8586
     
    251252///        set.
    252253LoggerThread::LoggerThread(QString filename, bool progress, bool quiet,
    253                            QString table, int facility) :
     254                           QString table, int facility, bool noserver) :
    254255    MThread("Logger"),
    255256    m_waitNotEmpty(new QWaitCondition()),
     
    260261    m_tablename(table), m_facility(facility), m_pid(getpid()), m_epoch(0),
    261262    m_zmqContext(NULL), m_zmqSocket(NULL), m_initialTimer(NULL),
    262     m_heartbeatTimer(NULL)
     263    m_heartbeatTimer(NULL), m_noserver(noserver)
    263264{
    264265    char *debug = getenv("VERBOSE_THREADS");
     
    272273
    273274#ifdef NOLOGSERVER
    274     if (!logServerStart())
     275    if (!m_noserver && !logServerStart())
    275276    {
    276277        LOG(VB_GENERAL, LOG_ERR,
     
    288289
    289290#ifdef NOLOGSERVER
    290     logServerStop();
     291    if (!m_noserver)
     292    {
     293        logServerStop();
     294    }
    291295#endif
    292296    delete m_waitNotEmpty;
     
    308312    bool dieNow = false;
    309313
     314    if (!m_noserver)
     315    {
    310316#ifndef NOLOGSERVER
    311     try
    312     {
    313         if (m_locallogs)
    314         {
    315             logServerWait();
    316             m_zmqContext = logServerThread->getZMQContext();
    317         }
    318         else
    319         {
    320             m_zmqContext = nzmqt::createDefaultContext(NULL);
    321             m_zmqContext->start();
    322         }
    323 
    324         if (!m_zmqContext)
    325         {
     317        try
     318        {
     319            if (m_locallogs)
     320            {
     321                logServerWait();
     322                m_zmqContext = logServerThread->getZMQContext();
     323            }
     324            else
     325            {
     326                m_zmqContext = nzmqt::createDefaultContext(NULL);
     327                m_zmqContext->start();
     328            }
     329
     330            if (!m_zmqContext)
     331            {
     332                m_aborted = true;
     333                dieNow = true;
     334            }
     335            else
     336            {
     337                qRegisterMetaType<QList<QByteArray> >("QList<QByteArray>");
     338
     339                m_zmqSocket =
     340                    m_zmqContext->createSocket(nzmqt::ZMQSocket::TYP_DEALER, this);
     341                connect(m_zmqSocket,
     342                        SIGNAL(messageReceived(const QList<QByteArray>&)),
     343                        SLOT(messageReceived(const QList<QByteArray>&)),
     344                        Qt::QueuedConnection);
     345
     346                if (m_locallogs)
     347                    m_zmqSocket->connectTo("inproc://mylogs");
     348                else
     349                    m_zmqSocket->connectTo("tcp://127.0.0.1:35327");
     350            }
     351        }
     352        catch (nzmqt::ZMQException &e)
     353        {
     354            cerr << "Exception during logging socket setup: " << e.what() << endl;
    326355            m_aborted = true;
    327356            dieNow = true;
    328357        }
    329         else
    330         {
    331             qRegisterMetaType<QList<QByteArray> >("QList<QByteArray>");
    332 
    333             m_zmqSocket =
    334                 m_zmqContext->createSocket(nzmqt::ZMQSocket::TYP_DEALER, this);
    335             connect(m_zmqSocket,
    336                     SIGNAL(messageReceived(const QList<QByteArray>&)),
    337                     SLOT(messageReceived(const QList<QByteArray>&)),
    338                     Qt::QueuedConnection);
    339 
    340             if (m_locallogs)
    341                 m_zmqSocket->connectTo("inproc://mylogs");
     358
     359        if (!m_aborted)
     360        {
     361            if (!m_locallogs)
     362            {
     363                m_initialWaiting = true;
     364                pingLogServer();
     365
     366                // wait up to 150ms for mythlogserver to respond
     367                m_initialTimer = new MythSignalingTimer(this,
     368                                                        SLOT(initialTimeout()));
     369                m_initialTimer->start(150);
     370            }
    342371            else
    343                 m_zmqSocket->connectTo("tcp://127.0.0.1:35327");
    344         }
    345     }
    346     catch (nzmqt::ZMQException &e)
    347     {
    348         cerr << "Exception during logging socket setup: " << e.what() << endl;
    349         m_aborted = true;
    350         dieNow = true;
    351     }
    352 
    353     if (!m_aborted)
    354     {
    355         if (!m_locallogs)
    356         {
    357             m_initialWaiting = true;
    358             pingLogServer();
    359 
    360             // wait up to 150ms for mythlogserver to respond
    361             m_initialTimer = new MythSignalingTimer(this,
    362                                                     SLOT(initialTimeout()));
    363             m_initialTimer->start(150);
    364         }
    365         else
    366             LOG(VB_GENERAL, LOG_INFO, "Added logging to mythlogserver locally");
    367 
    368         loggingGetTimeStamp(&m_epoch, NULL);
    369        
    370         m_heartbeatTimer = new MythSignalingTimer(this, SLOT(checkHeartBeat()));
    371         m_heartbeatTimer->start(1000);
    372     }
    373 #else
    374     logServerWait();
    375 #endif
     372                LOG(VB_GENERAL, LOG_INFO, "Added logging to mythlogserver locally");
     373
     374            loggingGetTimeStamp(&m_epoch, NULL);
     375           
     376            m_heartbeatTimer = new MythSignalingTimer(this, SLOT(checkHeartBeat()));
     377            m_heartbeatTimer->start(1000);
     378        }
     379    #else
     380        logServerWait();
     381    #endif
     382    }
    376383
    377384    QMutexLocker qLock(&logQueueMutex);
     
    597604            free(threadName);
    598605        }
     606    }
     607
     608    if (m_noserver)
     609    {
     610        return;
    599611    }
    600612
     
    853865    }
    854866#endif
     867
     868    if (logPropagateOpts.noserver)
     869    {
     870        logPropagateArgs += " --nologserver";
     871        logPropagateArgList << "--nologserver";
     872    }
    855873}
    856874
     
    860878{
    861879    return logPropagateOpts.quiet;
     880}
     881
     882/// \brief Check if we are propagating a "--nologserver"
     883/// \return true if --nologserver is being propagated
     884bool logPropagateNoServer(void)
     885{
     886    return logPropagateOpts.noserver;
    862887}
    863888
     
    875900///                     processes.
    876901void logStart(QString logfile, int progress, int quiet, int facility,
    877               LogLevel_t level, bool dblog, bool propagate)
     902              LogLevel_t level, bool dblog, bool propagate, bool noserver)
    878903{
    879904    if (logThread && logThread->isRunning())
     
    888913    logPropagateOpts.facility = facility;
    889914    logPropagateOpts.dblog = dblog;
     915    logPropagateOpts.noserver = noserver;
    890916
    891917    if (propagate)
     
    901927
    902928    if (!logThread)
    903         logThread = new LoggerThread(logfile, progress, quiet, table, facility);
     929        logThread = new LoggerThread(logfile, progress, quiet, table, facility, noserver);
    904930
    905931    logThread->start();
  • mythtv/libs/libmythbase/logging.h

    ra74baed2b rf124159c7  
    173173  public:
    174174    LoggerThread(QString filename, bool progress, bool quiet, QString table,
    175                  int facility);
     175                 int facility, bool noserver);
    176176    ~LoggerThread();
    177177    void run(void);
     
    209209    MythSignalingTimer *m_heartbeatTimer;   ///< Timer for 1s heartbeats
    210210
     211    bool m_noserver;
     212
    211213  protected:
    212214    bool logConsole(LoggingItem *item);
  • mythtv/libs/libmythbase/mythcommandlineparser.cpp

    ra74baed2b rf124159c7  
    23762376
    23772377/** \brief Canned argument definition for all logging options, including
    2378  *  --verbose, --logpath, --quiet, --loglevel, --syslog
    2379  *  and --enable-dblog
     2378 *  --verbose, --logpath, --quiet, --loglevel, --syslog, --enable-dblog
     2379 *  and --nologserver
    23802380 */
    23812381void MythCommandLineParser::addLogging(
     
    24332433            "existing system logging daemon, or --logpath to specify a "
    24342434            "dirctory for MythTV to write its logs to.", "0.25");
     2435    add("--nologserver", "nologserver", false, "Disable all logging but console.", "")
     2436                ->SetGroup("Logging");
    24352437}
    24362438
     
    25822584    int facility = GetSyslogFacility();
    25832585    bool dblog = toBool("enabledblog");
     2586    bool noserver = toBool("nologserver");
    25842587    LogLevel_t level = GetLogLevel();
    25852588    if (level == LOG_UNKNOWN)
     
    26012604        quiet = max(quiet, 1);
    26022605
    2603     logStart(logfile, progress, quiet, facility, level, dblog, propagate);
     2606    logStart(logfile, progress, quiet, facility, level, dblog, propagate, noserver);
    26042607
    26052608    return GENERIC_EXIT_OK;
  • mythtv/libs/libmythbase/mythlogging.h

    ra74baed2b rf124159c7  
    6868MBASE_PUBLIC void logStart(QString logfile, int progress = 0, int quiet = 0,
    6969                           int facility = 0, LogLevel_t level = LOG_INFO,
    70                            bool dblog = true, bool propagate = false);
     70                           bool dblog = true, bool propagate = false,
     71                           bool noserver = false);
    7172MBASE_PUBLIC void logStop(void);
    7273MBASE_PUBLIC void logPropagateCalc(void);
    7374MBASE_PUBLIC bool logPropagateQuiet(void);
     75MBASE_PUBLIC bool logPropagateNoServer(void);
    7476
    7577MBASE_PUBLIC int  syslogGetFacility(QString facility);
  • mythtv/libs/libmythbase/mythsystemlegacy.cpp

    ra74baed2b rf124159c7  
    145145            if (logPropagateQuiet())
    146146                m_command += " --quiet";
     147            if (logPropagateNoServer())
     148                m_command += " --nologserver";
    147149        }
    148150        else
     
    151153            if (logPropagateQuiet())
    152154                m_args << "--quiet";
     155            if (logPropagateNoServer())
     156                m_args << "--nologserver";
    153157        }
    154158    }
Note: See TracChangeset for help on using the changeset viewer.