bool ChatLog::OpenLogFile()
{
    wxLogMessage( _T( "OpenLogFile( ) server = %s, room = %s" ), m_server.c_str(), m_room.c_str() ) ;
    wxString logFilePath ( GetCurrentLogfilePath() );

    if ( LogEnabled() && CreateCurrentLogFolder() ) {
        m_logfile.Open( logFilePath, wxFile::write_append );

        if ( !m_logfile.IsOpened() ) {
            wxLogWarning( _T( "Can't open log file %s" ), logFilePath.c_str() ) ;
            customMessageBox( SL_MAIN_ICON,
                              _( "Can't open log file \"" ) + logFilePath + _("\".\nBe sure that there isn't a write protection.\n" ),
                              _( "Log Warning" ) ) ;
            m_active = false;
        }
        else {
            FillLastLineArray();

            wxDateTime now = wxDateTime::Now();
            wxString text = _T( "### Session Start at [" ) + now.Format( _T( "%Y-%m-%d %H:%M" ) ) + _T( "]" ) + wxTextBuffer::GetEOL();
            return WriteLine( text );
        }
    }
    return false;
}
示例#2
0
bool ChatLog::OpenLogFile()
{
	wxLogMessage(_T( "OpenLogFile( ) %s" ), m_logname.c_str());
	wxString logFilePath(GetCurrentLogfilePath());

	if (!LogEnabled()) {
		return true;
	}

	if (!CreateCurrentLogFolder()) {
		return false;
	}

	if (!wxFile::Exists(logFilePath)) {
		m_logfile.Create(logFilePath);
	} else {
		m_logfile.Open(logFilePath, wxFile::read_write);
	}

	if (!m_logfile.IsOpened()) {
		wxLogWarning(_T( "Can't open log file %s" ), logFilePath.c_str());
		m_active = false;
		return false;
	}

	FillLastLineArray();
	m_active = true;

	return AddMessage(wxDateTime::Now().Format(_("### Session Start at [%Y-%m-%d %H:%M]")));
}
	ERMsg CWeatherUpdate::Execute(const CFileManager& fileManager, CCallback& callback)
	{
		ERMsg msg;

		string filePath;
		msg = GetFM().WeatherUpdate().GetFilePath(m_fileTitle, filePath);
		if (msg)
		{
			//try to open log
			string logFilePath(filePath);
			SetFileExtension(logFilePath, ".log");

			callback.PushTask("Call WeatherUpdater...", NOT_INIT);
			msg = CallApplication(CRegistry::WEATHER_UPDATER, "\"" + filePath + "\" -e -l \"" + logFilePath + (m_bShowApp ? "\" -Show" : "\""), NULL, m_bShowApp ? SW_SHOW : SW_HIDE, false, true);

			if (msg)
			{
				ifStream log;
				if (log.open(logFilePath))
					callback.AddMessage(log.GetText());
			}

			callback.PopTask();
		}
			

		return msg;
	}
示例#4
0
bool FuzzyTester::runQbs(const QString &buildDir, const QString &command, QString *errorOutput)
{
    if (errorOutput)
        errorOutput->clear();
    QProcess qbs;
    QStringList commandLine = QStringList(command) << "-d" << buildDir;
    if (m_log) {
        commandLine << "-vv";
        const size_t maxLoggedCommits = 2;
        Q_ASSERT(m_commitsWithLogFiles.size() <= maxLoggedCommits + 1);
        if (m_commitsWithLogFiles.size() == maxLoggedCommits + 1) {
            static const QStringList allActivities = QStringList() << resolveIncrementalActivity()
                    << buildIncrementalActivity() << buildFromScratchActivity();
            const QString oldCommit = m_commitsWithLogFiles.front();
            m_commitsWithLogFiles.pop();
            for (const QString &a : allActivities)
                QFile::remove(logFilePath(oldCommit, a));
        }
        qbs.setStandardErrorFile(logFilePath(m_currentCommit, m_currentActivity));
        if (m_commitsWithLogFiles.empty() || m_commitsWithLogFiles.back() != m_currentCommit)
            m_commitsWithLogFiles.push(m_currentCommit);
    } else {
        commandLine << "-qq";
    }
    if (m_jobCount != 0)
        commandLine << "--jobs" << QString::number(m_jobCount);
    commandLine << ("profile:" + m_profile);
    qbs.start("qbs", commandLine);
    if (!qbs.waitForStarted()) {
        throw TestError(QString::fromLatin1("Failed to start qbs. It is expected to be "
                "in the PATH. QProcess error string: '%1'").arg(qbs.errorString()));
    }
    if (!qbs.waitForFinished(-1) || qbs.exitCode() != 0) {
        if (errorOutput)
            *errorOutput = QString::fromLocal8Bit(qbs.readAllStandardError());
        return false;
    }
    return true;
}
示例#5
0
LogFile::LogFile(Error& error, const UTF16& sLogFilePath)
	: m_sLogFilePath(sLogFilePath)
{
	Path logFilePath(error, m_sLogFilePath);

	if (error)
		return;

	m_logFile = NewObject(FileOutputStream, error, logFilePath, FileOutputStream::eAppend);

	if (error)
	{
		m_logFile.setNull();
		return;
	}

	loginfo("Attached log file \"%s\"", m_sLogFilePath.ptr());
}
示例#6
0
void FileLogAppender::createLogFile() {
	namespace FS = std::tr2::sys;

	date::year_month_day now(date::floor<date::days>(date::sys_days::clock::now()));

	std::wostringstream ostr;
	ostr << now;
	auto nowDate = ostr.str();

	// Windows Vista之後支援'/'資料夾路徑, 但是std::tr2::sys都會轉為'\\'
	FS::path logFilePath(logFilePath_ + nowDate);

	if (!FS::exists(logFilePath)) {
		FS::create_directories(logFilePath);
	}

	logFilePath /= logFileName_;
	logging_.open(logFilePath.relative_path(), std::ios::binary | std::ios::app);
}
示例#7
0
Logger& LoggerFacory::GetLogger(const CString &loggerName)
{
	if (loggerName.IsEmpty() && mLoggerMap.GetCount() > 0) {
		POSITION pos = mLoggerMap.GetStartPosition();
		CString key;
		Logger *logger(NULL);
		mLoggerMap.GetNextAssoc(pos, key, logger);
		return *logger;
	}
	MapLogger::CPair *pair = mLoggerMap.PLookup(loggerName);
	if (pair == NULL) {
		mLoggerMap[loggerName] = new Logger;
		pair = mLoggerMap.PLookup(loggerName);
		Path logFilePath(GetLogFolderPath());
		logFilePath = logFilePath.Append(loggerName);
		logFilePath = logFilePath.RenameExtension(_T(".log"));
		LogTargetFile *pFileTarget = new LogTargetFile();
		pFileTarget->SetLogFile(logFilePath);
		pair->value->AddTarget(pFileTarget);
	}
	return *pair->value;
}
示例#8
0
bool LibVLC::init(QList<QByteArray> more_args)
{
    Q_ASSERT_X(!self, "LibVLC", "there should be only one LibVLC object");
    LibVLC::self = new LibVLC;

    QList<QByteArray> args;

    // Ends up as something like $HOME/.config/Phonon/vlc.conf
    const QString configFileName = QSettings("Phonon", "vlc").fileName();
    if (QFile::exists(configFileName)) {
        args << QByteArray("--config=").append(QFile::encodeName(configFileName));
        args << "--no-ignore-config";
    }

    int debugLevel = qgetenv("PHONON_SUBSYSTEM_DEBUG").toInt();
	debugLevel = 21473647;
    if (debugLevel > 0) {
        args << QByteArray("--verbose=").append(QByteArray::number(debugLevel));
        args << QByteArray("--extraintf=logger");
#ifdef Q_WS_WIN
        QDir logFilePath(QString(qgetenv("APPDATA")).append("/vlc"));
#else
        QDir logFilePath(QDir::homePath().append("/.vlc"));
#endif //Q_WS_WIN
        logFilePath.mkdir("log");
        const QString logFile = logFilePath.path()
                .append("/log/vlc-log-")
                .append(QString::number(qApp->applicationPid()))
                .append(".txt");
        args << QByteArray("--logfile=").append(QFile::encodeName(QDir::toNativeSeparators(logFile)));
    }

    args << "--no-media-library";
    args << "--no-osd";
    args << "--no-stats";
#if (LIBVLC_VERSION_INT < LIBVLC_VERSION(2, 1, 0, 0))
    // Replaced by API call, see MediaPlayer::MediaPlayer.
    args << "--no-video-title-show";
#endif
    // By default VLC will put a picture-in-picture when making a snapshot.
    // This is unexpected behaviour for us, so we force it off.
    args << "--no-snapshot-preview";
    // Do not load xlib dependent modules as we cannot ensure proper init
    // order as expected by xlib thus leading to crashes.
    // KDE BUG: 240001
    args << "--no-xlib";
    // Do not preload services discovery modules, we don't use them.
    args << "--services-discovery=''";
    // Allow multiple starts (one gets to wonder whether that makes a difference).
#if !defined(Q_OS_MAC) && (defined(Q_OS_WIN) || !defined(PHONON_NO_DBUS))
    args << "--no-one-instance";
#endif
    args << "--no-audio";
    args << "--no-video";

    args << more_args;

    // 6 seconds disk read buffer (up from vlc 2.1 default of 300ms) when using alsa, prevents most buffer underruns
    // when the disk is very busy. We expect the pulse buffer after decoding to solve the same problem.
    Phonon::PulseSupport *pulse = Phonon::PulseSupport::getInstance();
    if (!pulse || !pulse->isActive()) {
        args << "--file-caching=6000";
    }

    // Build const char* array
    QVarLengthArray<const char *, 64> vlcArgs(args.size());
    for (int i = 0; i < args.size(); ++i) {
        vlcArgs[i] = args.at(i).constData();
    }

    // Create and initialize a libvlc instance (it should be done only once)
    self->m_vlcInstance = libvlc_new(vlcArgs.size(), vlcArgs.constData());
    if (!self->m_vlcInstance) {
        fatal() << "libVLC: could not initialize";
        return false;
    }
    return true;
}