当前位置: 首页>>代码示例>>C++>>正文


C++ LogFile::open方法代码示例

本文整理汇总了C++中LogFile::open方法的典型用法代码示例。如果您正苦于以下问题:C++ LogFile::open方法的具体用法?C++ LogFile::open怎么用?C++ LogFile::open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LogFile的用法示例。


在下文中一共展示了LogFile::open方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: tr

/** Saves the given list of items to a file.
 * \param items A list of log message items to save.
 */
void
MessageLog::save(const QStringList &messages)
{
  if (!messages.size()) {
    return;
  }

  QString fileName = QFileDialog::getSaveFileName(this,
                          tr("Save Log Messages"),
                          "VidaliaLog-" +
                          QDateTime::currentDateTime().toString("MM.dd.yyyy")
                          + ".txt", tr("Text Files (*.txt)"));

  /* If the choose to save */
  if (!fileName.isEmpty()) {
    LogFile logFile;
    QString errmsg;

    /* If can't write to file, show error message */
    if (!logFile.open(fileName, &errmsg)) {
      VMessageBox::warning(this, tr("Vidalia"),
                           p(tr("Cannot write file %1\n\n%2."))
                                                .arg(fileName)
                                                .arg(errmsg),
                           VMessageBox::Ok);
      return;
    }

    /* Write out the message log to the file */
    QApplication::setOverrideCursor(Qt::WaitCursor);
    foreach (QString msg, messages) {
      logFile << msg << "\n";
    }
    QApplication::restoreOverrideCursor();
  }
开发者ID:Bodyfarm,项目名称:vidalia,代码行数:38,代码来源:MessageLog.cpp

示例2: open_logfiles

void open_logfiles()
{
    script_log.open( "log/script.log" );
    //db_script_log.setbufs( script_log.rdbuf(), cout.rdbuf() );
    //db_script_log.install( &script_log );


}
开发者ID:alucardxlx,项目名称:polserver-zulu,代码行数:8,代码来源:logfiles.cpp

示例3: exportLogs

void FlightLogManager::exportLogs()
{
    if (m_logEntries.isEmpty()) {
        return;
    }

    setDisableControls(true);
    QApplication::setOverrideCursor(Qt::WaitCursor);

    QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save Log"),
                                                    tr("OP-%0.opl").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss")),
                                                    tr("OpenPilot Log (*.opl)"));
    if (!fileName.isEmpty()) {
        // Loop and create a new file for each flight.
        fileName = fileName.replace(QString(".opl"), QString("%1.opl"));
        int currentEntry  = 0;
        int currentFlight = 0;
        quint32 adjustedBaseTime = 0;
        // Continue until all entries are exported
        while (currentEntry < m_logEntries.count()) {
            if (m_adjustExportedTimestamps) {
                adjustedBaseTime = m_logEntries[currentEntry]->getFlightTime();
            }

            // Get current flight
            currentFlight = m_logEntries[currentEntry]->getFlight();

            LogFile logFile;
            logFile.useProvidedTimeStamp(true);

            // Set the file name to contain flight number
            logFile.setFileName(fileName.arg(tr("_flight-%1").arg(currentFlight + 1)));
            logFile.open(QIODevice::WriteOnly);
            UAVTalk uavTalk(&logFile, m_objectManager);

            // Export entries until no more available or flight changes
            while (currentEntry < m_logEntries.count() && m_logEntries[currentEntry]->getFlight() == currentFlight) {
                ExtendedDebugLogEntry *entry = m_logEntries[currentEntry];

                // Only log uavobjects
                if (entry->getType() == ExtendedDebugLogEntry::TYPE_UAVOBJECT) {
                    // Set timestamp that should be logged for this entry
                    logFile.setNextTimeStamp(entry->getFlightTime() - adjustedBaseTime);

                    // Use UAVTalk to log complete message to file
                    uavTalk.sendObject(entry->uavObject(), false, false);
                    qDebug() << entry->getFlightTime() - adjustedBaseTime << "=" << entry->toStringBrief();
                }
                currentEntry++;
            }

            logFile.close();
        }
    }

    QApplication::restoreOverrideCursor();
    setDisableControls(false);
}
开发者ID:Alex-Rongzhen-Huang,项目名称:OpenPilot,代码行数:58,代码来源:flightlogmanager.cpp

示例4: DefFileAppender

		explicit DefFileAppender(const std::string& file, ::log4cpp::LogLevel minLv, ::log4cpp::LogLevel maxLv = ::log4cpp::LG_FATAL, size_t flushOnSize= kDefFlushSize)
			:lvlMin(minLv), lvlMax(maxLv), flushEvery(flushOnSize>0? flushOnSize: kDefFlushSize), hasWriten(0)
		{
			logfile.open(file, "wb");
			
		}
开发者ID:John-Chan,项目名称:logcpp-prebuild,代码行数:6,代码来源:def_appender.hpp


注:本文中的LogFile::open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。