Ticket #325: mythtv.logging.diff
File mythtv.logging.diff, 11.4 KB (added by , 19 years ago) |
---|
-
libs/libmythtv/jobqueue.h
174 174 QString GetJobCommand(int jobType, ProgramInfo *tmpInfo); 175 175 176 176 static void *TranscodeThread(void *param); 177 static QString PrettyPrint(off_t bytes); 177 178 void DoTranscodeThread(void); 178 179 179 180 static void *FlagCommercialsThread(void *param); -
libs/libmythtv/jobqueue.cpp
1491 1491 return NULL; 1492 1492 } 1493 1493 1494 QString 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 1494 1527 void JobQueue::DoTranscodeThread(void) 1495 1528 { 1496 1529 if (!m_pginfo) … … 1499 1532 ProgramInfo *program_info = new ProgramInfo(*m_pginfo); 1500 1533 int controlTranscoding = JOB_RUN; 1501 1534 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); 1506 1537 QString startts = program_info->startts.toString("yyyyMMddhhmm00"); 1507 1538 1508 1539 key = QString("%1_%2") … … 1566 1597 int retrylimit = 3; 1567 1598 while (retry) 1568 1599 { 1569 QString statusText; 1600 off_t origfilesize, filesize; 1601 struct stat st; 1570 1602 1571 1603 retry = false; 1604 1572 1605 ChangeJobStatus(jobID, JOB_STARTING); 1573 1606 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); 1582 1610 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 1583 1628 VERBOSE(VB_JOBQUEUE, QString("JobQueue running app: '%1'") 1584 1629 .arg(command)); 1585 1630 … … 1587 1632 1588 1633 int status = GetJobStatus(jobID); 1589 1634 1590 QString fileprefix = gContext->GetFilePrefix();1591 QString filename = program_info->GetRecordFilename(fileprefix);1592 1635 if (status == JOB_STOPPING) 1593 1636 { 1594 1637 QString tmpfile = filename; 1595 1638 QString query; 1596 1639 tmpfile += ".tmp"; 1597 // Get new filesize 1598 struct stat st; 1599 long long filesize = 0; 1640 // Get filesizes 1600 1641 if (stat(tmpfile.ascii(), &st) == 0) 1601 filesize = st.st_size;1642 filesize = st.st_size; 1602 1643 // To save the original file... 1603 1644 QString oldfile = filename; 1604 1645 oldfile += ".old"; … … 1638 1679 } 1639 1680 if (filesize > 0) 1640 1681 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); 1642 1687 } else { 1643 1688 // transcode didn't finish delete partial transcode 1644 1689 filename += ".tmp"; … … 1652 1697 { 1653 1698 retry = true; 1654 1699 retrylimit--; 1655 } else // Unreco erable error1700 } else // Unrecoverable error 1656 1701 ChangeJobStatus(jobID, JOB_ERRORED); 1657 1702 } 1703 1658 1704 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); 1666 1729 } 1667 1730 controlFlagsLock.lock(); 1668 1731 runningJobIDs.erase(key); … … 1688 1751 ProgramInfo *program_info = new ProgramInfo(*m_pginfo); 1689 1752 int controlFlagging = JOB_RUN; 1690 1753 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") 1692 1757 .arg(program_info->title.local8Bit()) 1758 .arg(subtitle) 1693 1759 .arg(program_info->chanid) 1694 1760 .arg(program_info->startts.toString()); 1695 1761 … … 1722 1788 jobControlFlags[key] = &controlFlagging; 1723 1789 controlFlagsLock.unlock(); 1724 1790 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); 1730 1794 1731 1795 int breaksFound = 0; 1732 1796 QString cmd = … … 1792 1856 } 1793 1857 else 1794 1858 { 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"; 1799 1860 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); 1802 1864 1865 gContext->LogEntry("commflag", LP_NOTICE, msg, details); 1866 1803 1867 msg = QString("Finished, %1 break(s) found.").arg(breaksFound); 1804 1868 ChangeJobStatus(jobID, JOB_FINISHED, msg); 1805 1869 } -
libs/libmythtv/scheduledrecording.cpp
453 453 { 454 454 proginfo.recstatus = rsRecorded; 455 455 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); 461 463 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); 465 466 466 467 MythEvent me(QString("UPDATE_RECORDING_STATUS %1 %2 %3 %4") 467 468 .arg(proginfo.cardid) -
programs/mythbackend/scheduler.cpp
1109 1109 RecIter recIter = startIter; 1110 1110 for ( ; recIter != reclist.end(); recIter++) 1111 1111 { 1112 QString msg ;1112 QString msg, details; 1113 1113 1114 1114 nextRecording = *recIter; 1115 1115 … … 1224 1224 msg = "Canceled recording"; 1225 1225 statuschanged = true; 1226 1226 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) 1229 1234 .arg(nextRecording->chanid) 1230 1235 .arg(nextRecording->cardid) 1231 1236 .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); 1235 1240 } 1236 1241 1237 1242 if (statuschanged) … … 2254 2259 } 2255 2260 } 2256 2261 2262 /* vim: set expandtab tabstop=4 shiftwidth=4: */