forked from MrBesen/lolautoaccept
debuglog
This commit is contained in:
parent
ee5a0017ea
commit
4e515ae8a0
|
@ -0,0 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
struct Args {
|
||||
int debugLog = 0; // cast to bool later
|
||||
};
|
||||
|
||||
Args parseArgs(int argc, char** argv);
|
|
@ -23,6 +23,7 @@ defineReplace(prependAll) {
|
|||
}
|
||||
|
||||
SOURCES += \
|
||||
src/arg.cpp \
|
||||
src/config.cpp \
|
||||
src/datadragon.cpp \
|
||||
src/datadragonimagecache.cpp \
|
||||
|
@ -46,6 +47,7 @@ SOURCES += \
|
|||
# mainwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
include/arg.h \
|
||||
include/config.h \
|
||||
include/datadragon.h \
|
||||
include/datadragonimagecache.h \
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
#include "arg.h"
|
||||
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
Args parseArgs(int argc, char** argv) {
|
||||
Args a;
|
||||
|
||||
while (1) {
|
||||
static struct option long_options[] = {
|
||||
{"debug-log", no_argument, &a.debugLog, 1},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
/* getopt_long stores the option index here. */
|
||||
int option_index = 0;
|
||||
|
||||
int c = getopt_long (argc, argv, "", long_options, &option_index);
|
||||
|
||||
/* Detect the end of the options. */
|
||||
if (c == -1) break;
|
||||
|
||||
switch (c) {
|
||||
case 0:
|
||||
/* If this option set a flag, do nothing else now. */
|
||||
break;
|
||||
|
||||
case '?':
|
||||
/* getopt_long already printed an error message. */
|
||||
break;
|
||||
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
15
src/main.cpp
15
src/main.cpp
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <Log.h>
|
||||
|
||||
#include "arg.h"
|
||||
#include "mainwindow.h"
|
||||
#include "lolautoaccept.h"
|
||||
|
||||
|
@ -29,19 +30,25 @@ static std::string getBaseString(char** argv) {
|
|||
int main(int argc, char** argv) {
|
||||
Log::init();
|
||||
Log::setConsoleLogLevel(Log::Level::INFO);
|
||||
// Log::addLogfile("log.txt", Log::Level::TRACE);
|
||||
#if __unix__
|
||||
Log::setColoredOutput(true);
|
||||
#endif
|
||||
|
||||
Log::info << "Hello, World!";
|
||||
Log::note << "Using Locale: " << QLocale().name().toStdString();
|
||||
|
||||
if(argc == 0) {
|
||||
Log::fatal << "arg[0] is not set";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Args args = parseArgs(argc, argv);
|
||||
if(args.debugLog) {
|
||||
Log::setConsoleLogLevel(Log::Level::TRACE);
|
||||
Log::addLogfile("log.txt", Log::Level::TRACE);
|
||||
Log::debug << "debug Log enabled";
|
||||
}
|
||||
|
||||
Log::info << "Hello, World!";
|
||||
Log::note << "Using Locale: " << QLocale().name().toStdString();
|
||||
|
||||
std::string base = getBaseString(argv);
|
||||
Log::info << "appbase: " << base;
|
||||
Matcher::setPathBase(base);
|
||||
|
|
Loading…
Reference in New Issue