forked from CoatiSoftware/Sourcetrail
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
107 lines (83 loc) · 2.47 KB
/
Copy pathmain.cpp
File metadata and controls
107 lines (83 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "includes.h"
#include "language_packages.h"
#include "LanguagePackageManager.h"
#include "InterprocessIndexer.h"
#include "ApplicationSettings.h"
#include "AppPath.h"
#include "ConsoleLogger.h"
#include "FileLogger.h"
#include "logging.h"
#include "LogManager.h"
#if BUILD_CXX_LANGUAGE_PACKAGE
#include "LanguagePackageCxx.h"
#endif // BUILD_CXX_LANGUAGE_PACKAGE
#if BUILD_JAVA_LANGUAGE_PACKAGE
#include "LanguagePackageJava.h"
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
void setupLogging(const FilePath& logFilePath)
{
LogManager* logManager = LogManager::getInstance().get();
// std::shared_ptr<ConsoleLogger> consoleLogger = std::make_shared<ConsoleLogger>();
// // consoleLogger->setLogLevel(Logger::LOG_WARNINGS | Logger::LOG_ERRORS);
// consoleLogger->setLogLevel(Logger::LOG_ALL);
// logManager->addLogger(consoleLogger);
std::shared_ptr<FileLogger> fileLogger = std::make_shared<FileLogger>();
fileLogger->setLogFilePath(logFilePath);
fileLogger->setLogLevel(Logger::LOG_ALL);
logManager->addLogger(fileLogger);
}
void suppressCrashMessage()
{
#ifdef _WIN32
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
#endif // _WIN32
}
int main(int argc, char *argv[])
{
int processId = -1;
std::string instanceUuid;
std::string appPath;
std::string userDataPath;
std::string logFilePath;
if (argc >= 2)
{
processId = std::stoi(argv[1]);
}
if (argc >= 3)
{
instanceUuid = argv[2];
}
if (argc >= 4)
{
appPath = argv[3];
}
if (argc >= 5)
{
userDataPath = argv[4];
}
if (argc >= 6)
{
logFilePath = argv[5];
}
AppPath::setAppPath(FilePath(appPath));
UserPaths::setUserDataPath(FilePath(userDataPath));
if (!logFilePath.empty())
{
setupLogging(FilePath(logFilePath));
}
suppressCrashMessage();
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
appSettings->load(FilePath(UserPaths::getAppSettingsPath()));
LogManager::getInstance()->setLoggingEnabled(appSettings->getLoggingEnabled());
LOG_INFO(L"appPath: " + AppPath::getAppPath().wstr());
LOG_INFO(L"userDataPath: " + UserPaths::getUserDataPath().wstr());
#if BUILD_CXX_LANGUAGE_PACKAGE
LanguagePackageManager::getInstance()->addPackage(std::make_shared<LanguagePackageCxx>());
#endif // BUILD_CXX_LANGUAGE_PACKAGE
#if BUILD_JAVA_LANGUAGE_PACKAGE
LanguagePackageManager::getInstance()->addPackage(std::make_shared<LanguagePackageJava>());
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
InterprocessIndexer indexer(instanceUuid, processId);
indexer.work();
return 0;
}