diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-11-23 22:33:43 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-11-23 22:33:43 +0100 |
| commit | b1e857cf1471d1871a9396696b22fa531da98249 (patch) | |
| tree | 3923008a8653057698cb339faf6dcfa92e18364b /project-base/src/logging.h | |
| parent | 106bb7fcadf637cec883648916cc8d19529d6199 (diff) | |
add projbase to repo
Diffstat (limited to 'project-base/src/logging.h')
| -rw-r--r-- | project-base/src/logging.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/project-base/src/logging.h b/project-base/src/logging.h new file mode 100644 index 0000000..a6ae594 --- /dev/null +++ b/project-base/src/logging.h @@ -0,0 +1,38 @@ +/* +* BSD 2-Clause “Simplified” License +* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com +* All rights reserved. +*/ + +#ifndef INCLUDE_LOGGING +#define INCLUDE_LOGGING + +#if defined(MODE_DEBUG) + +#include <string.h> +#define __FILENAME__ (strrchr("/" __FILE__, '/') + 1) + +#ifdef OS_LINUX +#define log_assert(_cond, _message) if (!(_cond)) { printf("ERROR: %s, Assertion failed at %s, line %d. In %s\n", _message, __FILENAME__, __LINE__, __func__); exit(0); } +#define log_info(_message) { printf("INFO: %s, at %s, line %d. In %s\n", _message, __FILENAME__, __LINE__, __func__); } +#endif + +#ifdef OS_WIN +#define log_assert(_cond, _message) if (!(_cond)) \ + { char __buf[500]; \ + sprintf(__buf, "%s, Assertion failed at %s, line %d. In %s\n", _message, __FILENAME__, __LINE__, __func__); \ + printf(__buf); \ + MessageBox(0, __buf, "Error", MB_OK); exit(0); } +#define log_info(_message) { char _____buf[4000]; sprintf(_____buf, "INFO: %s, at %s, line %d. In %s\n", _message, __FILENAME__, __LINE__, __func__); printf(_____buf); OutputDebugStringA(_____buf); } +#endif + +#else + +#define log_assert(_cond, _message) do{}while(0) +#define log_info( _message) do{}while(0) + +#endif + +#define log_assert_m(_cond) log_assert(_cond, "") + +#endif
\ No newline at end of file |
