1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Refactor logging

- Add warning log level
- Change debug_log_level setting to enumeration string
- Map Irrlicht log events to MT log events
- Encapsulate log_* functions and global variables into a class, Logger
- Unify dstream with standard logging mechanism
- Unify core.debug() with standard core.log() script API
This commit is contained in:
ShadowNinja 2015-10-13 03:57:44 -04:00 committed by kwolekr
parent e0b57c1140
commit 2139d7d45f
25 changed files with 599 additions and 652 deletions

View file

@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <exception>
#include <assert.h>
#include "gettime.h"
#include "log.h"
#if (defined(WIN32) || defined(_WIN32_WCE))
#define WIN32_LEAN_AND_MEAN
@ -36,9 +37,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#endif
#define __NORETURN __declspec(noreturn)
#define __FUNCTION_NAME __FUNCTION__
#define NORETURN __declspec(noreturn)
#define FUNCTION_NAME __FUNCTION__
#else
#define __NORETURN __attribute__ ((__noreturn__))
#define __FUNCTION_NAME __PRETTY_FUNCTION__
#define NORETURN __attribute__ ((__noreturn__))
#define FUNCTION_NAME __PRETTY_FUNCTION__
#endif
// Whether to catch all std::exceptions.
@ -50,30 +55,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define CATCH_UNHANDLED_EXCEPTIONS 0
#endif
/*
Debug output
*/
#define DTIME (getTimestamp()+": ")
extern void debugstreams_init(bool disable_stderr, const char *filename);
extern void debugstreams_deinit();
// This is used to redirect output to /dev/null
class Nullstream : public std::ostream {
public:
Nullstream():
std::ostream(0)
{
}
private:
};
extern std::ostream dstream;
extern std::ostream dstream_no_stderr;
extern Nullstream dummyout;
/* Abort program execution immediately
*/
__NORETURN extern void fatal_error_fn(
@ -108,6 +89,8 @@ __NORETURN extern void sanity_check_fn(
void debug_set_exception_handler();
#define DTIME ""
/*
DebugStack
*/