void LogWriter::LoadLogSettings() { DebugLogFile="PGE_Editor_log.txt"; logLevel = QtDebugMsg; QString mainIniFile = ApplicationPath + "/" + "pge_editor.ini"; QSettings logSettings(mainIniFile, QSettings::IniFormat); logSettings.beginGroup("logging"); DebugLogFile = logSettings.value("log-path", ApplicationPath+"/"+DebugLogFile).toString(); enabled = true; switch( logSettings.value("log-level", "3").toInt() ) { case 4: logLevel=QtDebugMsg; break; case 3: logLevel=QtWarningMsg; break; case 2: logLevel=QtCriticalMsg; break; case 1: logLevel=QtFatalMsg; break; case 0: default: enabled=false; logLevel=QtFatalMsg; break; } logSettings.endGroup(); qDebug()<< QString("LogLevel %1, log file %2").arg(logLevel).arg(DebugLogFile); }
static void init(void) { // Initialize Pebble Autoconfig to register App Message handlers and restores settings autoconfig_init(); // Here the restored or defaulted settings are available logSettings("restored"); // Register our custom receive handler which in turn will call Pebble Autoconfigs receive handler app_message_register_inbox_received(in_received_handler); window = window_create(); Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); for (int i = 0; i < SETTING_COUNT; ++i) { layer[i] = text_layer_create(GRect(10, 10 + i*35, bounds.size.w - 10, 28)); layer_add_child(window_layer, text_layer_get_layer(layer[i])); } updateDisplay(); // Attach our desired button functionality window_set_click_config_provider(window, (ClickConfigProvider) click_config_provider); window_stack_push(window, true); }
void dumpLogging() { QString output = "Current Logging Categories:"; output += "\n\t logging: " + QString::number(logLogging().isDebugEnabled()); output += "\n\t keybinds: " + QString::number(logKeybinds().isDebugEnabled()); output += "\n\t settings: " + QString::number(logSettings().isDebugEnabled()); output += "\n\t gui: " + QString::number(logGUI().isDebugEnabled()); output += "\n\t teams: " + QString::number(logTeams().isDebugEnabled()); output += "\n\t db: " + QString::number(logDB().isDebugEnabled()); output += "\n\t input: " + QString::number(logInput().isDebugEnabled()); output += "\n\t position: " + QString::number(logPosition().isDebugEnabled()); output += "\n\t orientation: " + QString::number(logOrientation().isDebugEnabled()); output += "\n\t movement: " + QString::number(logMovement().isDebugEnabled()); output += "\n\t chat: " + QString::number(logChat().isDebugEnabled()); output += "\n\t infomsg: " + QString::number(logInfoMsg().isDebugEnabled()); output += "\n\t emotes: " + QString::number(logEmotes().isDebugEnabled()); output += "\n\t target: " + QString::number(logTarget().isDebugEnabled()); output += "\n\t spawn: " + QString::number(logSpawn().isDebugEnabled()); output += "\n\t mapevents: " + QString::number(logMapEvents().isDebugEnabled()); output += "\n\t slashcommand: " + QString::number(logSlashCommand().isDebugEnabled()); output += "\n\t description: " + QString::number(logDescription().isDebugEnabled()); output += "\n\t friends: " + QString::number(logFriends().isDebugEnabled()); output += "\n\t minimap: " + QString::number(logMiniMap().isDebugEnabled()); output += "\n\t lfg: " + QString::number(logLFG().isDebugEnabled()); output += "\n\t npcs: " + QString::number(logNPCs().isDebugEnabled()); output += "\n\t animations: " + QString::number(logAnimations().isDebugEnabled()); output += "\n\t powers: " + QString::number(logPowers().isDebugEnabled()); output += "\n\t trades: " + QString::number(logTrades().isDebugEnabled()); output += "\n\t scenegraph: " + QString::number(logSceneGraph().isDebugEnabled()); qDebug().noquote() << output; }
static void in_received_handler(DictionaryIterator *iter, void *context) { // Let Pebble Autoconfig handle received settings autoconfig_in_received_handler(iter, context); // Here the updated settings are available logSettings("updated"); // Update display with new values updateDisplay(); // App Messages can be received while using Pebble Autoconfig Tuple *tuple = dict_find(iter, PONG_KEY); if(tuple) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Received pong: %s", tuple->value->cstring); } }
void LogWriter::LoadLogSettings() { QString logFileName = QString("PGE_Engine_log_%1-%2-%3_%4-%5-%6.txt") .arg(QDate().currentDate().year()) .arg(QDate().currentDate().month()) .arg(QDate().currentDate().day()) .arg(QTime().currentTime().hour()) .arg(QTime().currentTime().minute()) .arg(QTime().currentTime().second()); logLevel = QtDebugMsg; QString mainIniFile = AppPathManager::settingsFile(); QSettings logSettings(mainIniFile, QSettings::IniFormat); QDir defLogDir(AppPathManager::userAppDir()+"/logs"); if(!defLogDir.exists()) if(!defLogDir.mkpath(AppPathManager::userAppDir()+"/logs")) defLogDir.setPath(AppPathManager::userAppDir()); logSettings.beginGroup("logging"); DebugLogFile = logSettings.value("log-path", defLogDir.absolutePath()+"/"+logFileName).toString(); if(!QFileInfo(DebugLogFile).absoluteDir().exists()) DebugLogFile = defLogDir.absolutePath()+"/"+logFileName; enabled = true; switch( logSettings.value("log-level", "4").toInt() ) { case 4: logLevel=QtDebugMsg; break; case 3: logLevel=QtWarningMsg; break; case 2: logLevel=QtCriticalMsg; break; case 1: logLevel=QtFatalMsg; break; case 0: default: enabled=false; logLevel=QtFatalMsg; break; } logSettings.endGroup(); qDebug()<< QString("LogLevel %1, log file %2").arg(logLevel).arg(DebugLogFile); qInstallMessageHandler(logMessageHandler); }
void LogWriter::LoadLogSettings() { QString logFileName = QString("PGE_Engine_log_%1-%2-%3_%4-%5-%6.txt") .arg(QDate().currentDate().year()) .arg(QDate().currentDate().month()) .arg(QDate().currentDate().day()) .arg(QTime().currentTime().hour()) .arg(QTime().currentTime().minute()) .arg(QTime().currentTime().second()); logLevel = PGE_LogLevel::Debug; QString mainIniFile = AppPathManager::settingsFile(); QSettings logSettings(mainIniFile, QSettings::IniFormat); QDir defLogDir(AppPathManager::userAppDir()+"/logs"); if(!defLogDir.exists()) if(!defLogDir.mkpath(AppPathManager::userAppDir()+"/logs")) defLogDir.setPath(AppPathManager::userAppDir()); logSettings.beginGroup("logging"); DebugLogFile = logSettings.value("log-path", defLogDir.absolutePath()+"/"+logFileName).toString(); if(!QFileInfo(DebugLogFile).absoluteDir().exists()) DebugLogFile = defLogDir.absolutePath()+"/"+logFileName; logLevel = (PGE_LogLevel)logSettings.value("log-level", (int)PGE_LogLevel::Debug).toInt(); enabled = ((int)logLevel!=0); logSettings.endGroup(); qDebug()<< QString("LogLevel %1, log file %2").arg((int)logLevel).arg(DebugLogFile); _out_file = std::make_shared<QFile>(DebugLogFile); if(_out_file.get()->open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) { _out_stream = std::make_shared<QTextStream>(_out_file.get()); _out_stream.get()->setCodec("UTF-8"); qInstallMessageHandler(logMessageHandler); _file_is_opened=true; } else { qWarning() << "Impossible to open " << DebugLogFile << " for write, all logs are will be printed through QtDebug..."; } }
void toggleLogging(QString &category) { if(category.isEmpty()) return; QLoggingCategory *cat = nullptr; if(category.contains("logging",Qt::CaseInsensitive)) cat = &logLogging(); else if(category.contains("keybinds",Qt::CaseInsensitive)) cat = &logKeybinds(); else if(category.contains("settings",Qt::CaseInsensitive)) cat = &logSettings(); else if(category.contains("gui",Qt::CaseInsensitive)) cat = &logGUI(); else if(category.contains("teams",Qt::CaseInsensitive)) cat = &logTeams(); else if(category.contains("db",Qt::CaseInsensitive)) cat = &logDB(); else if(category.contains("input",Qt::CaseInsensitive)) cat = &logInput(); else if(category.contains("position",Qt::CaseInsensitive)) cat = &logPosition(); else if(category.contains("orientation",Qt::CaseInsensitive)) cat = &logOrientation(); else if(category.contains("movement",Qt::CaseInsensitive)) cat = &logMovement(); else if(category.contains("chat",Qt::CaseInsensitive)) cat = &logChat(); else if(category.contains("infomsg",Qt::CaseInsensitive)) cat = &logInfoMsg(); else if(category.contains("emotes",Qt::CaseInsensitive)) cat = &logEmotes(); else if(category.contains("target",Qt::CaseInsensitive)) cat = &logTarget(); else if(category.contains("spawn",Qt::CaseInsensitive)) cat = &logSpawn(); else if(category.contains("mapevents",Qt::CaseInsensitive)) cat = &logMapEvents(); else if (category.contains("mapxfers",Qt::CaseInsensitive)) cat = &logMapXfers(); else if(category.contains("slashcommand",Qt::CaseInsensitive)) cat = &logSlashCommand(); else if(category.contains("description",Qt::CaseInsensitive)) cat = &logDescription(); else if(category.contains("friends",Qt::CaseInsensitive)) cat = &logFriends(); else if(category.contains("minimap",Qt::CaseInsensitive)) cat = &logMiniMap(); else if(category.contains("lfg",Qt::CaseInsensitive)) cat = &logLFG(); else if(category.contains("npcs",Qt::CaseInsensitive)) cat = &logNPCs(); else if(category.contains("animations",Qt::CaseInsensitive)) cat = &logAnimations(); else if(category.contains("powers",Qt::CaseInsensitive)) cat = &logPowers(); else if(category.contains("trades",Qt::CaseInsensitive)) cat = &logTrades(); else if(category.contains("scripts", Qt::CaseInsensitive)) cat = &logScripts(); else if(category.contains("scenegraph",Qt::CaseInsensitive)) cat = &logSceneGraph(); else return; cat->setEnabled(QtDebugMsg, !cat->isDebugEnabled()); cat->setEnabled(QtInfoMsg, !cat->isInfoEnabled()); cat->setEnabled(QtWarningMsg, !cat->isWarningEnabled()); cat->setEnabled(QtCriticalMsg, !cat->isCriticalEnabled()); dumpLogging(); }