Ticket #325: mythtv.logging.diff

File mythtv.logging.diff, 11.4 KB (added by Robert Tsai <rtsai1111>, 20 years ago)
  • libs/libmythtv/jobqueue.h

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

     
    14911491    return NULL;
    14921492}
    14931493
     1494QString JobQueue::PrettyPrint(off_t bytes)
     1495{
     1496    // Pretty print "bytes" as KB, MB, GB, TB, etc., subject to the desired
     1497    // number of units
     1498    static const struct {
     1499        const char      *suffix;
     1500        unsigned int    max;
     1501        int         precision;
     1502    } pptab[] = {
     1503        { "bytes", 9999, 0 },
     1504        { "kB", 999, 0 },
     1505        { "MB", 999, 1 },
     1506        { "GB", 999, 1 },
     1507        { "TB", 999, 1 },
     1508        { "PB", 999, 1 },
     1509        { "EB", 999, 1 },
     1510        { "ZB", 999, 1 },
     1511        { "YB", 0, 0 },
     1512    };
     1513    unsigned int    ii;
     1514    float           fbytes = bytes;
     1515
     1516    ii = 0;
     1517    while (pptab[ii].max && fbytes > pptab[ii].max) {
     1518        fbytes /= 1024;
     1519        ii++;
     1520    }
     1521
     1522    return QString("%1 %2")
     1523        .arg(fbytes, 0, 'f', pptab[ii].precision)
     1524        .arg(pptab[ii].suffix);
     1525}
     1526
    14941527void JobQueue::DoTranscodeThread(void)
    14951528{
    14961529    if (!m_pginfo)
     
    14991532    ProgramInfo *program_info = new ProgramInfo(*m_pginfo);
    15001533    int controlTranscoding = JOB_RUN;
    15011534    QString key;
    1502     QString logDesc = QString("\"%1\" recorded from channel %2 at %3")
    1503                           .arg(program_info->title.local8Bit())
    1504                           .arg(program_info->chanid)
    1505                           .arg(program_info->startts.toString());
     1535    QString subtitle = program_info->subtitle.isEmpty() ? "" :
     1536                        QString(" \"%1\"").arg(program_info->subtitle);
    15061537    QString startts = program_info->startts.toString("yyyyMMddhhmm00");
    15071538   
    15081539    key = QString("%1_%2")
     
    15661597    int retrylimit = 3;
    15671598    while (retry)
    15681599    {
    1569         QString statusText;
     1600        off_t origfilesize, filesize;
     1601        struct stat st;
    15701602
    15711603        retry = false;
     1604
    15721605        ChangeJobStatus(jobID, JOB_STARTING);
    15731606
    1574         statusText = StatusText(GetJobStatus(jobID));
    1575         msg = QString("\"%1\" transcode of %2: %3.")
    1576                       .arg(transcoderName)
    1577                       .arg(logDesc)
    1578                       .arg(statusText);
    1579         VERBOSE(VB_GENERAL, msg);
    1580         gContext->LogEntry("transcode", LP_NOTICE,
    1581                            QString("Transcode %1").arg(statusText), msg);
     1607        QString statusText = StatusText(GetJobStatus(jobID));
     1608        QString fileprefix = gContext->GetFilePrefix();
     1609        QString filename = program_info->GetRecordFilename(fileprefix);
    15821610
     1611        origfilesize = 0;
     1612        filesize = 0;
     1613
     1614        if (stat(filename.ascii(), &st) == 0)
     1615            origfilesize = st.st_size;
     1616
     1617        QString msg = QString("Transcode %1").arg(statusText);
     1618
     1619        QString details = QString("%1%2: %3 (%4)")
     1620                            .arg(program_info->title)
     1621                            .arg(subtitle)
     1622                            .arg(PrettyPrint(origfilesize))
     1623                            .arg(transcoderName);
     1624
     1625        VERBOSE(VB_GENERAL, QString("%1 for %2").arg(msg).arg(details));
     1626        gContext->LogEntry("transcode", LP_NOTICE, msg, details);
     1627
    15831628        VERBOSE(VB_JOBQUEUE, QString("JobQueue running app: '%1'")
    15841629                                     .arg(command));
    15851630
     
    15871632
    15881633        int status = GetJobStatus(jobID);
    15891634
    1590         QString fileprefix = gContext->GetFilePrefix();
    1591         QString filename = program_info->GetRecordFilename(fileprefix);
    15921635        if (status == JOB_STOPPING)
    15931636        {
    15941637            QString tmpfile = filename;
    15951638            QString query;
    15961639            tmpfile += ".tmp";
    1597             // Get new filesize
    1598             struct stat st;
    1599             long long filesize = 0;
     1640            // Get filesizes
    16001641            if (stat(tmpfile.ascii(), &st) == 0)
    1601             filesize = st.st_size;
     1642                filesize = st.st_size;
    16021643            // To save the original file...
    16031644            QString oldfile = filename;
    16041645            oldfile += ".old";
     
    16381679            }
    16391680            if (filesize > 0)
    16401681                program_info->SetFilesize(filesize);
    1641             ChangeJobStatus(jobID, JOB_FINISHED);
     1682            QString comment = QString("%1: %2 => %3")
     1683                                    .arg(transcoderName)
     1684                                    .arg(PrettyPrint(origfilesize))
     1685                                    .arg(PrettyPrint(filesize));
     1686            ChangeJobStatus(jobID, JOB_FINISHED, comment);
    16421687        } else {
    16431688            // transcode didn't finish delete partial transcode
    16441689            filename += ".tmp";
     
    16521697            {
    16531698                retry = true;
    16541699                retrylimit--;
    1655             } else // Unrecoerable error
     1700            } else // Unrecoverable error
    16561701                ChangeJobStatus(jobID, JOB_ERRORED);
    16571702        }
     1703
    16581704        statusText = StatusText(GetJobStatus(jobID));
    1659         msg = QString("\"%1\" transcode of %2: %3.")
    1660                       .arg(transcoderName)
    1661                       .arg(logDesc)
    1662                       .arg(statusText);
    1663         VERBOSE(VB_GENERAL, msg);
    1664         gContext->LogEntry("transcode", LP_NOTICE,
    1665                            QString("Transcode %1").arg(statusText), msg);
     1705
     1706        msg = QString("Transcode %1").arg(statusText);
     1707
     1708        if (filesize > 0)
     1709        {
     1710            details = QString("%1%2: %3 (%4)")
     1711                            .arg(program_info->title)
     1712                            .arg(subtitle)
     1713                            .arg(PrettyPrint(filesize))
     1714                            .arg(transcoderName);
     1715        }
     1716        else
     1717        {
     1718            details = QString("%1%2").arg(program_info->title).arg(subtitle);
     1719        }
     1720
     1721        VERBOSE(VB_GENERAL, QString("%1 for %2%3: %4 => %5 (%6)")
     1722                            .arg(msg)
     1723                            .arg(program_info->title)
     1724                            .arg(subtitle)
     1725                            .arg(PrettyPrint(origfilesize))
     1726                            .arg(PrettyPrint(filesize))
     1727                            .arg(transcoderName));
     1728        gContext->LogEntry("transcode", LP_NOTICE, msg, details);
    16661729    }
    16671730    controlFlagsLock.lock();
    16681731    runningJobIDs.erase(key);
     
    16881751    ProgramInfo *program_info = new ProgramInfo(*m_pginfo);
    16891752    int controlFlagging = JOB_RUN;
    16901753    QString key;
    1691     QString logDesc = QString("\"%1\" recorded from channel %2 at %3")
     1754    QString subtitle = program_info->subtitle.isEmpty() ? "" :
     1755                        QString(" \"%1\"").arg(program_info->subtitle);
     1756    QString logDesc = QString("%1%2: channel %3, %4")
    16921757                          .arg(program_info->title.local8Bit())
     1758                          .arg(subtitle)
    16931759                          .arg(program_info->chanid)
    16941760                          .arg(program_info->startts.toString());
    16951761   
     
    17221788    jobControlFlags[key] = &controlFlagging;
    17231789    controlFlagsLock.unlock();
    17241790
    1725     QString msg = QString("Starting Commercial Flagging for %1.")
    1726                           .arg(logDesc);
    1727     VERBOSE(VB_GENERAL, msg);
    1728     gContext->LogEntry("commflag", LP_NOTICE, "Commercial Flagging Starting",
    1729                        msg);
     1791    QString msg = "Commercial Flagging Starting";
     1792    VERBOSE(VB_GENERAL, QString("%1 for %2").arg(msg).arg(logDesc));
     1793    gContext->LogEntry("commflag", LP_NOTICE, msg, logDesc);
    17301794
    17311795    int breaksFound = 0;
    17321796    QString cmd =
     
    17921856    }
    17931857    else
    17941858    {
    1795         msg = QString("Finished Commercial Flagging for %1. "
    1796                       "Found %2 commercial break(s).")
    1797                       .arg(logDesc)
    1798                       .arg(breaksFound);
     1859        msg = "Commercial Flagging Finished";
    17991860
    1800         gContext->LogEntry("commflag", LP_NOTICE,
    1801                            "Commercial Flagging Finished", msg);
     1861        QString details = QString("%1: %2 commercial break(s)")
     1862                                .arg(logDesc)
     1863                                .arg(breaksFound);
    18021864
     1865        gContext->LogEntry("commflag", LP_NOTICE, msg, details);
     1866
    18031867        msg = QString("Finished, %1 break(s) found.").arg(breaksFound);
    18041868        ChangeJobStatus(jobID, JOB_FINISHED, msg);
    18051869    }
  • 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: */