Improve debug logging
This commit is contained in:
parent
3d33abf1cd
commit
4b4946ca1e
@ -220,7 +220,7 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
|
|||||||
LL_NONE, // ELL_NONE
|
LL_NONE, // ELL_NONE
|
||||||
};
|
};
|
||||||
assert(event.LogEvent.Level < ARRLEN(irr_loglev_conv));
|
assert(event.LogEvent.Level < ARRLEN(irr_loglev_conv));
|
||||||
#if !defined(__ANDROID__) && !defined(__IOS__)
|
#ifndef NDEBUG
|
||||||
g_logger.log(irr_loglev_conv[event.LogEvent.Level],
|
g_logger.log(irr_loglev_conv[event.LogEvent.Level],
|
||||||
std::string("Irrlicht: ") + event.LogEvent.Text);
|
std::string("Irrlicht: ") + event.LogEvent.Text);
|
||||||
#endif
|
#endif
|
||||||
|
57
src/log.cpp
57
src/log.cpp
@ -35,10 +35,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#ifdef __IOS__
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const int BUFFER_LENGTH = 256;
|
const int BUFFER_LENGTH = 256;
|
||||||
|
|
||||||
class StringBuffer : public std::streambuf {
|
class StringBuffer : public std::streambuf {
|
||||||
@ -147,31 +143,6 @@ AndroidSystemLogOutput g_android_log_output;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// iOS
|
|
||||||
#ifdef __IOS__
|
|
||||||
|
|
||||||
class IosSystemLogOutput : public ICombinedLogOutput {
|
|
||||||
public:
|
|
||||||
IosSystemLogOutput()
|
|
||||||
{
|
|
||||||
g_logger.addOutput(this);
|
|
||||||
}
|
|
||||||
~IosSystemLogOutput()
|
|
||||||
{
|
|
||||||
g_logger.removeOutput(this);
|
|
||||||
}
|
|
||||||
void logRaw(LogLevel lev, const std::string &line)
|
|
||||||
{
|
|
||||||
#if !NDEBUG
|
|
||||||
NSLog(@"%s", line.c_str());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
IosSystemLogOutput g_ios_log_output;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
@ -363,6 +334,33 @@ void StreamLogOutput::logRaw(LogLevel lev, const std::string &line)
|
|||||||
{
|
{
|
||||||
bool colored_message = (Logger::color_mode == LOG_COLOR_ALWAYS) ||
|
bool colored_message = (Logger::color_mode == LOG_COLOR_ALWAYS) ||
|
||||||
(Logger::color_mode == LOG_COLOR_AUTO && is_tty);
|
(Logger::color_mode == LOG_COLOR_AUTO && is_tty);
|
||||||
|
#if defined(__MACH__) && defined(__APPLE__)
|
||||||
|
if (colored_message) {
|
||||||
|
switch (lev) {
|
||||||
|
case LL_ERROR:
|
||||||
|
// error is red
|
||||||
|
m_stream << "📕 ";
|
||||||
|
break;
|
||||||
|
case LL_WARNING:
|
||||||
|
// warning is yellow
|
||||||
|
m_stream << "📙 ";
|
||||||
|
break;
|
||||||
|
case LL_INFO:
|
||||||
|
// info is a green
|
||||||
|
m_stream << "📗 ";
|
||||||
|
break;
|
||||||
|
case LL_VERBOSE:
|
||||||
|
// verbose is blue
|
||||||
|
m_stream << "📘 ";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// action is white
|
||||||
|
m_stream << "📔 ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_stream << line << std::endl;
|
||||||
|
#else
|
||||||
if (colored_message) {
|
if (colored_message) {
|
||||||
switch (lev) {
|
switch (lev) {
|
||||||
case LL_ERROR:
|
case LL_ERROR:
|
||||||
@ -393,6 +391,7 @@ void StreamLogOutput::logRaw(LogLevel lev, const std::string &line)
|
|||||||
// reset to white color
|
// reset to white color
|
||||||
m_stream << "\033[0m";
|
m_stream << "\033[0m";
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogOutputBuffer::updateLogLevel()
|
void LogOutputBuffer::updateLogLevel()
|
||||||
|
@ -129,7 +129,11 @@ int main(int argc, char *argv[])
|
|||||||
debug_set_exception_handler();
|
debug_set_exception_handler();
|
||||||
|
|
||||||
g_logger.registerThread("Main");
|
g_logger.registerThread("Main");
|
||||||
|
#ifdef NDEBUG
|
||||||
g_logger.addOutputMaxLevel(&stderr_output, LL_ACTION);
|
g_logger.addOutputMaxLevel(&stderr_output, LL_ACTION);
|
||||||
|
#else
|
||||||
|
g_logger.addOutputMaxLevel(&stderr_output, LL_INFO);
|
||||||
|
#endif
|
||||||
|
|
||||||
Settings cmd_args;
|
Settings cmd_args;
|
||||||
bool cmd_args_ok = get_cmdline_opts(argc, argv, &cmd_args);
|
bool cmd_args_ok = get_cmdline_opts(argc, argv, &cmd_args);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user