Ticket #325: mythtv.logging.2.diff
File mythtv.logging.2.diff, 11.3 KB (added by , 20 years ago) |
---|
-
libs/libmythtv/jobqueue.h
175 175 QString GetJobCommand(int jobType, ProgramInfo *tmpInfo); 176 176 177 177 static void *TranscodeThread(void *param); 178 static QString PrettyPrint(off_t bytes); 178 179 void DoTranscodeThread(void); 179 180 180 181 static void *FlagCommercialsThread(void *param); -
libs/libmythtv/jobqueue.cpp
1562 1562 return NULL; 1563 1563 } 1564 1564 1565 QString 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 1565 1598 void JobQueue::DoTranscodeThread(void) 1566 1599 { 1567 1600 if (!m_pginfo) … … 1570 1603 ProgramInfo *program_info = new ProgramInfo(*m_pginfo); 1571 1604 int controlTranscoding = JOB_RUN; 1572 1605 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); 1577 1608 QString startts = program_info->recstartts.toString("yyyyMMddhhmmss"); 1578 1609 1579 1610 key = QString("%1_%2") … … 1637 1668 int retrylimit = 3; 1638 1669 while (retry) 1639 1670 { 1640 QString statusText; 1671 off_t origfilesize, filesize; 1672 struct stat st; 1641 1673 1642 1674 retry = false; 1643 1675 ChangeJobStatus(jobID, JOB_STARTING); 1644 1676 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); 1653 1680 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 1654 1698 VERBOSE(VB_JOBQUEUE, QString("JobQueue running app: '%1'") 1655 1699 .arg(command)); 1656 1700 … … 1658 1702 1659 1703 int status = GetJobStatus(jobID); 1660 1704 1661 QString fileprefix = gContext->GetFilePrefix();1662 QString filename = program_info->GetRecordFilename(fileprefix);1663 1705 if (status == JOB_STOPPING) 1664 1706 { 1665 1707 QString tmpfile = filename; … … 1669 1711 struct stat st; 1670 1712 long long filesize = 0; 1671 1713 if (stat(tmpfile.ascii(), &st) == 0) 1672 filesize = st.st_size;1714 filesize = st.st_size; 1673 1715 // To save the original file... 1674 1716 QString oldfile = filename; 1675 1717 oldfile += ".old"; … … 1709 1751 } 1710 1752 if (filesize > 0) 1711 1753 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); 1713 1759 } else { 1714 1760 // transcode didn't finish delete partial transcode 1715 1761 filename += ".tmp"; … … 1723 1769 { 1724 1770 retry = true; 1725 1771 retrylimit--; 1726 } else // Unreco erable error1772 } else // Unrecoverable error 1727 1773 ChangeJobStatus(jobID, JOB_ERRORED); 1728 1774 } 1729 1775 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); 1737 1800 } 1738 1801 controlFlagsLock.lock(); 1739 1802 runningJobIDs.erase(key); … … 1759 1822 ProgramInfo *program_info = new ProgramInfo(*m_pginfo); 1760 1823 int controlFlagging = JOB_RUN; 1761 1824 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") 1763 1828 .arg(program_info->title.local8Bit()) 1829 .arg(subtitle) 1764 1830 .arg(program_info->chanid) 1765 1831 .arg(program_info->recstartts.toString()); 1766 1832 … … 1793 1859 jobControlFlags[key] = &controlFlagging; 1794 1860 controlFlagsLock.unlock(); 1795 1861 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); 1801 1865 1802 1866 int breaksFound = 0; 1803 1867 QString cmd = … … 1863 1927 } 1864 1928 else 1865 1929 { 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"; 1870 1931 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); 1873 1935 1936 gContext->LogEntry("commflag", LP_NOTICE, msg, details); 1937 1874 1938 msg = QString("Finished, %1 break(s) found.").arg(breaksFound); 1875 1939 ChangeJobStatus(jobID, JOB_FINISHED, msg); 1876 1940 } -
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: */