Ticket #325: mythtv.logging.2.diff

File mythtv.logging.2.diff, 11.3 KB (added by Robert Tsai <rtsai1111>, 20 years ago)

updated diff against r7255

  • libs/libmythtv/jobqueue.h

     
    175175    QString GetJobCommand(int jobType, ProgramInfo *tmpInfo);
    176176
    177177    static void *TranscodeThread(void *param);
     178    static QString PrettyPrint(off_t bytes);
    178179    void DoTranscodeThread(void);
    179180
    180181    static void *FlagCommercialsThread(void *param);
  • libs/libmythtv/jobqueue.cpp

     
    15621562    return NULL;
    15631563}
    15641564
     1565QString JobQueue::PrettyPrint(off_t bytes)
     1566{
     1567    // Pretty print "bytes" as KB, MB, GB, TB, etc., subject to the desired
     1568    // number of units
     1569    static const struct {
     1570        const char      *suffix;
     1571        unsigned int    max;
     1572        int         precision;
     1573    } pptab[] = {
     1574        { "bytes", 9999, 0 },
     1575        { "kB", 999, 0 },
     1576        { "MB", 999, 1 },
     1577        { "GB", 999, 1 },
     1578        { "TB", 999, 1 },
     1579        { "PB", 999, 1 },
     1580        { "EB", 999, 1 },
     1581        { "ZB", 999, 1 },
     1582        { "YB", 0, 0 },
     1583    };
     1584    unsigned int    ii;
     1585    float           fbytes = bytes;
     1586
     1587    ii = 0;
     1588    while (pptab[ii].max && fbytes > pptab[ii].max) {
     1589        fbytes /= 1024;
     1590        ii++;
     1591    }
     1592
     1593    return QString("%1 %2")
     1594        .arg(fbytes, 0, 'f', pptab[ii].precision)
     1595        .arg(pptab[ii].suffix);
     1596}
     1597
    15651598void JobQueue::DoTranscodeThread(void)
    15661599{
    15671600    if (!m_pginfo)
     
    15701603    ProgramInfo *program_info = new ProgramInfo(*m_pginfo);
    15711604    int controlTranscoding = JOB_RUN;
    15721605    QString key;
    1573     QString logDesc = QString("\"%1\" recorded from channel %2 at %3")
    1574                           .arg(program_info->title.local8Bit())
    1575                           .arg(program_info->chanid)
    1576                           .arg(program_info->recstartts.toString());
     1606    QString subtitle = program_info->subtitle.isEmpty() ? "" :
     1607                        QString(" \"%1\"").arg(program_info->subtitle);
    15771608    QString startts = program_info->recstartts.toString("yyyyMMddhhmmss");
    15781609   
    15791610    key = QString("%1_%2")
     
    16371668    int retrylimit = 3;
    16381669    while (retry)
    16391670    {
    1640         QString statusText;
     1671        off_t origfilesize, filesize;
     1672        struct stat st;
    16411673
    16421674        retry = false;
    16431675        ChangeJobStatus(jobID, JOB_STARTING);
    16441676
    1645         statusText = StatusText(GetJobStatus(jobID));
    1646         msg = QString("\"%1\" transcode of %2: %3.")
    1647                       .arg(transcoderName)
    1648                       .arg(logDesc)
    1649                       .arg(statusText);
    1650         VERBOSE(VB_GENERAL, msg);
    1651         gContext->LogEntry("transcode", LP_NOTICE,
    1652                            QString("Transcode %1").arg(statusText), msg);
     1677        QString statusText = StatusText(GetJobStatus(jobID));
     1678        QString fileprefix = gContext->GetFilePrefix();
     1679        QString filename = program_info->GetRecordFilename(fileprefix);
    16531680
     1681        origfilesize = 0;
     1682        filesize = 0;
     1683
     1684        if (stat(filename.ascii(), &st) == 0)
     1685            origfilesize = st.st_size;
     1686
     1687        QString msg = QString("Transcode %1").arg(statusText);
     1688
     1689        QString details = QString("%1%2: %3 (%4)")
     1690                            .arg(program_info->title)
     1691                            .arg(subtitle)
     1692                            .arg(PrettyPrint(origfilesize))
     1693                            .arg(transcoderName);
     1694
     1695        VERBOSE(VB_GENERAL, QString("%1 for %2").arg(msg).arg(details));
     1696        gContext->LogEntry("transcode", LP_NOTICE, msg, details);
     1697
    16541698        VERBOSE(VB_JOBQUEUE, QString("JobQueue running app: '%1'")
    16551699                                     .arg(command));
    16561700
     
    16581702
    16591703        int status = GetJobStatus(jobID);
    16601704
    1661         QString fileprefix = gContext->GetFilePrefix();
    1662         QString filename = program_info->GetRecordFilename(fileprefix);
    16631705        if (status == JOB_STOPPING)
    16641706        {
    16651707            QString tmpfile = filename;
     
    16691711            struct stat st;
    16701712            long long filesize = 0;
    16711713            if (stat(tmpfile.ascii(), &st) == 0)
    1672             filesize = st.st_size;
     1714                filesize = st.st_size;
    16731715            // To save the original file...
    16741716            QString oldfile = filename;
    16751717            oldfile += ".old";
     
    17091751            }
    17101752            if (filesize > 0)
    17111753                program_info->SetFilesize(filesize);
    1712             ChangeJobStatus(jobID, JOB_FINISHED);
     1754            QString comment = QString("%1: %2 => %3")
     1755                                    .arg(transcoderName)
     1756                                    .arg(PrettyPrint(origfilesize))
     1757                                    .arg(PrettyPrint(filesize));
     1758            ChangeJobStatus(jobID, JOB_FINISHED, comment);
    17131759        } else {
    17141760            // transcode didn't finish delete partial transcode
    17151761            filename += ".tmp";
     
    17231769            {
    17241770                retry = true;
    17251771                retrylimit--;
    1726             } else // Unrecoerable error
     1772            } else // Unrecoverable error
    17271773                ChangeJobStatus(jobID, JOB_ERRORED);
    17281774        }
    17291775        statusText = StatusText(GetJobStatus(jobID));
    1730         msg = QString("\"%1\" transcode of %2: %3.")
    1731                       .arg(transcoderName)
    1732                       .arg(logDesc)
    1733                       .arg(statusText);
    1734         VERBOSE(VB_GENERAL, msg);
    1735         gContext->LogEntry("transcode", LP_NOTICE,
    1736                            QString("Transcode %1").arg(statusText), msg);
     1776
     1777        msg = QString("Transcode %1").arg(statusText);
     1778
     1779        if (filesize > 0)
     1780        {
     1781            details = QString("%1%2: %3 (%4)")
     1782                            .arg(program_info->title)
     1783                            .arg(subtitle)
     1784                            .arg(PrettyPrint(filesize))
     1785                            .arg(transcoderName);
     1786        }
     1787        else
     1788        {
     1789            details = QString("%1%2").arg(program_info->title).arg(subtitle);
     1790        }
     1791
     1792        VERBOSE(VB_GENERAL, QString("%1 for %2%3: %4 => %5 (%6)")
     1793                            .arg(msg)
     1794                            .arg(program_info->title)
     1795                            .arg(subtitle)
     1796                            .arg(PrettyPrint(origfilesize))
     1797                            .arg(PrettyPrint(filesize))
     1798                            .arg(transcoderName));
     1799        gContext->LogEntry("transcode", LP_NOTICE, msg, details);
    17371800    }
    17381801    controlFlagsLock.lock();
    17391802    runningJobIDs.erase(key);
     
    17591822    ProgramInfo *program_info = new ProgramInfo(*m_pginfo);
    17601823    int controlFlagging = JOB_RUN;
    17611824    QString key;
    1762     QString logDesc = QString("\"%1\" recorded from channel %2 at %3")
     1825    QString subtitle = program_info->subtitle.isEmpty() ? "" :
     1826                        QString(" \"%1\"").arg(program_info->subtitle);
     1827    QString logDesc = QString("%1%2: channel %3, %4")
    17631828                          .arg(program_info->title.local8Bit())
     1829                          .arg(subtitle)
    17641830                          .arg(program_info->chanid)
    17651831                          .arg(program_info->recstartts.toString());
    17661832   
     
    17931859    jobControlFlags[key] = &controlFlagging;
    17941860    controlFlagsLock.unlock();
    17951861
    1796     QString msg = QString("Starting Commercial Flagging for %1.")
    1797                           .arg(logDesc);
    1798     VERBOSE(VB_GENERAL, msg);
    1799     gContext->LogEntry("commflag", LP_NOTICE, "Commercial Flagging Starting",
    1800                        msg);
     1862    QString msg = "Commercial Flagging Starting";
     1863    VERBOSE(VB_GENERAL, QString("%1 for %2").arg(msg).arg(logDesc));
     1864    gContext->LogEntry("commflag", LP_NOTICE, msg, logDesc);
    18011865
    18021866    int breaksFound = 0;
    18031867    QString cmd =
     
    18631927    }
    18641928    else
    18651929    {
    1866         msg = QString("Finished Commercial Flagging for %1. "
    1867                       "Found %2 commercial break(s).")
    1868                       .arg(logDesc)
    1869                       .arg(breaksFound);
     1930        msg = "Commercial Flagging Finished";
    18701931
    1871         gContext->LogEntry("commflag", LP_NOTICE,
    1872                            "Commercial Flagging Finished", msg);
     1932        QString details = QString("%1: %2 commercial break(s)")
     1933                                .arg(logDesc)
     1934                                .arg(breaksFound);
    18731935
     1936        gContext->LogEntry("commflag", LP_NOTICE, msg, details);
     1937
    18741938        msg = QString("Finished, %1 break(s) found.").arg(breaksFound);
    18751939        ChangeJobStatus(jobID, JOB_FINISHED, msg);
    18761940    }
  • libs/libmythtv/scheduledrecording.cpp

     
    453453{
    454454    proginfo.recstatus = rsRecorded;
    455455
    456     QString msg;
    457  
    458     msg = QString("Finished recording %1 on channel: %2")
    459                   .arg(proginfo.title)
    460                   .arg(proginfo.chanid);
     456    QString msg = "Finished recording";
     457    QString subtitle = proginfo.subtitle.isEmpty() ? "" :
     458                                    QString(" \"%1\"").arg(proginfo.subtitle);
     459    QString details = QString("%1%2: channel %3")
     460                                    .arg(proginfo.title)
     461                                    .arg(subtitle)
     462                                    .arg(proginfo.chanid);
    461463
    462     VERBOSE(VB_GENERAL, msg.local8Bit());
    463     gContext->LogEntry("scheduler", LP_NOTICE, "Finished recording",
    464                        msg);
     464    VERBOSE(VB_GENERAL, QString("%1 %2").arg(msg).arg(details).local8Bit());
     465    gContext->LogEntry("scheduler", LP_NOTICE, msg, details);
    465466
    466467    MythEvent me(QString("UPDATE_RECORDING_STATUS %1 %2 %3 %4")
    467468                 .arg(proginfo.cardid)
  • programs/mythbackend/scheduler.cpp

     
    11091109        RecIter recIter = startIter;
    11101110        for ( ; recIter != reclist.end(); recIter++)
    11111111        {
    1112             QString msg;
     1112            QString msg, details;
    11131113
    11141114            nextRecording = *recIter;
    11151115
     
    12241224                msg = "Canceled recording";
    12251225            statuschanged = true;
    12261226
    1227             msg += QString(" \"%1\" on channel: %2 on cardid: %3, "
    1228                            "sourceid %4").arg(nextRecording->title)
     1227            QString subtitle = nextRecording->subtitle.isEmpty() ? "" :
     1228                QString(" \"%1\"").arg(nextRecording->subtitle);
     1229
     1230            details = QString("%1%2: "
     1231                "channel %3 on cardid %4, sourceid %5")
     1232                .arg(nextRecording->title)
     1233                .arg(subtitle)
    12291234                .arg(nextRecording->chanid)
    12301235                .arg(nextRecording->cardid)
    12311236                .arg(nextRecording->sourceid);
    1232             VERBOSE(VB_GENERAL, msg.local8Bit());
    1233             gContext->LogEntry("scheduler", LP_NOTICE, "Schedule Change",
    1234                                msg);
     1237            VERBOSE(VB_GENERAL,
     1238                QString("%1 %2").arg(msg).arg(details).local8Bit());
     1239            gContext->LogEntry("scheduler", LP_NOTICE, msg, details);
    12351240        }
    12361241
    12371242        if (statuschanged)
     
    22542259    }
    22552260}
    22562261
     2262/* vim: set expandtab tabstop=4 shiftwidth=4: */