Просмотр исходного кода

Add --terminal option for logging to stderr

This is so much nicer for debugging than having to grab a log file.
Vincent Lang 8 лет назад
Родитель
Сommit
c70df14414
3 измененных файлов с 11 добавлено и 1 удалено
  1. 4 1
      src/main.cpp
  2. 6 0
      src/utils/Log.cpp
  3. 1 0
      src/utils/Log.h

+ 4 - 1
src/main.cpp

@@ -102,7 +102,8 @@ int main(int argc, char *argv[])
                        {"desktop",                 "Start in desktop mode"},
                        {"tv",                      "Start in TV mode"},
                        {"windowed",                "Start in windowed mode"},
-                       {"fullscreen",              "Start in fullscreen"}});
+                       {"fullscreen",              "Start in fullscreen"},
+                       {"terminal",                "Log to terminal"}});
 
     char **newArgv = appendCommandLineArguments(argc, argv, g_qtFlags);
     argc += g_qtFlags.size();
@@ -162,6 +163,8 @@ int main(int argc, char *argv[])
 #endif
 
     Log::Init();
+    if (parser.isSet("terminal"))
+      Log::EnableTerminalOutput();
 
     // Quit app and apply update if we find one.
     if (UpdateManager::CheckForUpdates())

+ 6 - 0
src/utils/Log.cpp

@@ -117,6 +117,12 @@ void Log::Init()
   QLOG_INFO() << "  Qt Version:" << QT_VERSION_STR << qPrintable(QString("[%1]").arg(QSysInfo::buildAbi()));
 }
 
+/////////////////////////////////////////////////////////////////////////////////////////
+void Log::EnableTerminalOutput()
+{
+  Logger::instance().addDestination(DestinationFactory::MakeDebugOutputDestination());
+}
+
 /////////////////////////////////////////////////////////////////////////////////////////
 void Log::Uninit()
 {

+ 1 - 0
src/utils/Log.h

@@ -13,6 +13,7 @@ namespace Log
   void Uninit();
   void UpdateLogLevel();
   void CensorAuthTokens(QString& msg);
+  void EnableTerminalOutput();
 }
 
 #endif //PLEXMEDIAPLAYER_LOG_H