mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
Console errors highlight
This commit is contained in:
2
EU07.cpp
2
EU07.cpp
@@ -27,7 +27,7 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
|
||||
#pragma comment(linker, "/subsystem:console /ENTRY:mainCRTStartup")
|
||||
#endif
|
||||
|
||||
void export_e3d_standalone(std::string in, std::string out, int flags, bool dynamic);
|
||||
|
||||
26
Logs.cpp
26
Logs.cpp
@@ -70,7 +70,7 @@ std::string filename_scenery() {
|
||||
}
|
||||
|
||||
// log service stacks
|
||||
std::deque<std::string> InfoStack;
|
||||
std::deque < std::pair<std::string, bool>> InfoStack;
|
||||
std::deque<std::string> ErrorStack;
|
||||
|
||||
// lock for log stacks
|
||||
@@ -86,10 +86,12 @@ void LogService()
|
||||
while (!InfoStack.empty())
|
||||
{
|
||||
logMutex.lock();
|
||||
std::string msg = InfoStack.front();
|
||||
std::string msg = InfoStack.front().first;
|
||||
bool isError = InfoStack.front().second;
|
||||
InfoStack.pop_front();
|
||||
logMutex.unlock();
|
||||
|
||||
// log to file
|
||||
if (Global.iWriteLogEnabled & 1)
|
||||
{
|
||||
if (!output.is_open())
|
||||
@@ -101,20 +103,18 @@ void LogService()
|
||||
output.flush();
|
||||
}
|
||||
|
||||
// log to scrollback imgui
|
||||
log_scrollback.emplace_back(msg);
|
||||
if (log_scrollback.size() > 200)
|
||||
log_scrollback.pop_front();
|
||||
|
||||
// log to console
|
||||
if (Global.iWriteLogEnabled & 2)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_INTENSITY);
|
||||
DWORD wr = 0;
|
||||
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), msg.c_str(), (DWORD)msg.size(), &wr, NULL);
|
||||
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), endstring, (DWORD)strlen(endstring), &wr, NULL);
|
||||
#else
|
||||
printf("%s\n", msg.c_str());
|
||||
#endif
|
||||
if (isError)
|
||||
printf("\033[1;37;41m%s\033[0m\n", msg.c_str());
|
||||
else
|
||||
printf("\033[32m%s\033[0m\n", msg.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,14 +146,14 @@ void LogService()
|
||||
}
|
||||
|
||||
|
||||
void WriteLog(const char *str, logtype const Type)
|
||||
void WriteLog(const char *str, logtype const Type, bool isError)
|
||||
{
|
||||
if (!str || *str == '\0')
|
||||
return;
|
||||
if (TestFlag(Global.DisabledLogTypes, static_cast<unsigned int>(Type)))
|
||||
return;
|
||||
logMutex.lock();
|
||||
InfoStack.emplace_back(str);
|
||||
InfoStack.emplace_back(str, isError);
|
||||
logMutex.unlock();
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ void Error(const char *&asMessage, bool box)
|
||||
void ErrorLog(const std::string &str, logtype const Type )
|
||||
{
|
||||
ErrorLog( str.c_str(), Type );
|
||||
WriteLog( str.c_str(), Type );
|
||||
WriteLog( str.c_str(), Type, true );
|
||||
}
|
||||
|
||||
void WriteLog(const std::string &str, logtype const Type )
|
||||
|
||||
2
Logs.h
2
Logs.h
@@ -24,7 +24,7 @@ enum class logtype : unsigned int {
|
||||
powergrid = ( 1 << 10 ),
|
||||
};
|
||||
void LogService();
|
||||
void WriteLog( const char *str, logtype const Type = logtype::generic );
|
||||
void WriteLog( const char *str, logtype const Type = logtype::generic, bool isError = false );
|
||||
void Error( const std::string &asMessage, bool box = false );
|
||||
void Error( const char* &asMessage, bool box = false );
|
||||
void ErrorLog( const std::string &str, logtype const Type = logtype::generic );
|
||||
|
||||
@@ -840,12 +840,6 @@ eu07_application::init_settings( int Argc, char *Argv[] ) {
|
||||
Global.asVersion = VERSION_INFO;
|
||||
|
||||
Global.LoadIniFile( "eu07.ini" );
|
||||
#ifdef _WIN32
|
||||
if( ( Global.iWriteLogEnabled & 2 ) != 0 ) {
|
||||
// show output console if requested
|
||||
AllocConsole();
|
||||
}
|
||||
#endif
|
||||
|
||||
// process command line arguments
|
||||
for( int i = 1; i < Argc; ++i ) {
|
||||
|
||||
Reference in New Issue
Block a user