Esempio n. 1
0
Logger::Logger(const QString &logPath, const QString &logLevel) :
    m_logfile(NULL),
    m_outputLevel(QtDebugMsg),
    m_gconfLogPath("/meegotouch/theme/logpath"),
    m_gconfLogLevel("/meegotouch/theme/loglevel")
{
    if (!logPath.isEmpty()) {
        setLogPath(logPath);
    } else if (!m_gconfLogPath.value().isNull()) {
        // use GConf for default log path
        setLogPath(m_gconfLogPath.value().toString());
    }

    if (!logLevel.isEmpty()) {
        setLogLevel(logLevel);
    } else if (!m_gconfLogLevel.value().isNull()) {
        // use GConf for default log path
        setLogLevel(m_gconfLogLevel.value().toString());
    }

    // reopen log file if re-configured
    connect(&m_gconfLogPath,
            SIGNAL(valueChanged()),
            this,
            SLOT(logPathChanged()));
    connect(&m_gconfLogLevel,
            SIGNAL(valueChanged()),
            this,
            SLOT(logLevelChanged()));
}
Esempio n. 2
0
void Logger::logPathChanged()
{
    if (m_gconfLogPath.value().isNull()) {
        setLogPath(QString());
    } else {
        setLogPath(m_gconfLogPath.value().toString());
    }
}
Esempio n. 3
0
winLog::winLog(bool resetLog, const char* path, const char* name) {

    setLogPath(path);
    setLogName(name);

    // MUST use a wchar_t* logDir to manage correctly international chars.
    // If using char* logDir and UTF-8, fopen() is not working correctly and
    // will fail to open the log file. (with UTF-8... why?)
    // So we use _wfopen() and a wchar_t* logDir.
    StringBuffer logDir;
    logDir.sprintf("%s\\%s", logPath.c_str(), logName.c_str());
    WCHAR* tmp = toWideChar(logDir.c_str());
    wlogDir = tmp;
    delete [] tmp;

    //
    // Test to ensure the log file is writable (only if path is set)
    //
    if (path) {
        logFile = _wfopen(wlogDir.c_str(), TEXT("a+"));
        if (logFile == NULL) {
            WCHAR tmp[512];
            wsprintf(tmp, TEXT("Unable to write log file: \"%s\".\nPlease check your user's permissions."), wlogDir.c_str());
            MessageBox(NULL, tmp, TEXT("Funambol"), MB_SETFOREGROUND | MB_OK);
        }
        else {
            fclose(logFile);

            if (resetLog) {
                reset(FUNAMBOL_HEADER);
            }
        }
    }
}
void CMyLogger::setLogLevel(int level)
{
	_logLevel = level;
	_isLogLevelSet = true;

	//turn on log
	if (!_rfApp && _logLevel != OFF_LOG_LEVEL && _logFileName.size() != 0){
		setLogPath(_logFileName.c_str());
	}
	if (_rfApp && _logLevel == OFF_LOG_LEVEL)
	{
		_rfApp = NULL;
	}
}