![]() |
Flecs v4.1
A fast entity component system (ECS) for C & C++
|
Logging functions. More...
Macros | |
| #define | ecs_print(level, ...) ecs_print_(level, __FILE__, __LINE__, __VA_ARGS__) |
| Base logging function. | |
| #define | ecs_printv(level, fmt, args) ecs_printv_(level, __FILE__, __LINE__, fmt, args) |
| Base logging function with va_list. | |
| #define | ecs_log(level, ...) ecs_log_(level, __FILE__, __LINE__, __VA_ARGS__) |
| Log at the provided level. | |
| #define | ecs_logv(level, fmt, args) ecs_logv_(level, __FILE__, __LINE__, fmt, args) |
| Log at the provided level with va_list. | |
| #define | ecs_trace_(file, line, ...) ecs_log_(0, file, line, __VA_ARGS__) |
| Tracing. | |
| #define | ecs_trace(...) ecs_trace_(__FILE__, __LINE__, __VA_ARGS__) |
| Tracing macro. | |
| #define | ecs_warn_(file, line, ...) ecs_log_(-2, file, line, __VA_ARGS__) |
| Warning. | |
| #define | ecs_warn(...) ecs_warn_(__FILE__, __LINE__, __VA_ARGS__) |
| Warning macro. | |
| #define | ecs_err_(file, line, ...) ecs_log_(-3, file, line, __VA_ARGS__) |
| Error. | |
| #define | ecs_err(...) ecs_err_(__FILE__, __LINE__, __VA_ARGS__) |
| Error macro. | |
| #define | ecs_fatal_(file, line, ...) ecs_log_(-4, file, line, __VA_ARGS__) |
| Fatal. | |
| #define | ecs_fatal(...) ecs_fatal_(__FILE__, __LINE__, __VA_ARGS__) |
| Fatal macro. | |
| #define | ecs_deprecated(...) ecs_deprecated_(__FILE__, __LINE__, __VA_ARGS__) |
| Optionally include warnings about using deprecated features. | |
| #define | FLECS_LOG_3 /* Enable all tracing in debug mode. May slow things down */ |
| #define | ecs_dbg_1(...) ecs_log(1, __VA_ARGS__); |
| Debug trace at level 1. | |
| #define | ecs_dbg_2(...) ecs_log(2, __VA_ARGS__); |
| Debug trace at level 2. | |
| #define | ecs_dbg_3(...) ecs_log(3, __VA_ARGS__); |
| Debug trace at level 3. | |
| #define | ecs_log_push_1() ecs_log_push_(1); |
| Push log indentation at level 1. | |
| #define | ecs_log_push_2() ecs_log_push_(2); |
| Push log indentation at level 2. | |
| #define | ecs_log_push_3() ecs_log_push_(3); |
| Push log indentation at level 3. | |
| #define | ecs_log_pop_1() ecs_log_pop_(1); |
| Pop log indentation at level 1. | |
| #define | ecs_log_pop_2() ecs_log_pop_(2); |
| Pop log indentation at level 2. | |
| #define | ecs_log_pop_3() ecs_log_pop_(3); |
| Pop log indentation at level 3. | |
| #define | ecs_should_log_1() ecs_should_log(1) |
| Test if level 1 logging is enabled. | |
| #define | ecs_should_log_2() ecs_should_log(2) |
| Test if level 2 logging is enabled. | |
| #define | ecs_should_log_3() ecs_should_log(3) |
| Test if level 3 logging is enabled. | |
| #define | FLECS_LOG_2 |
| #define | FLECS_LOG_1 |
| #define | FLECS_LOG_0 |
| #define | ecs_dbg ecs_dbg_1 |
| Default debug tracing is at level 1. | |
| #define | ecs_log_push() ecs_log_push_(0) |
| Push log indentation at the default level. | |
| #define | ecs_log_pop() ecs_log_pop_(0) |
| Pop log indentation at the default level. | |
| #define | ecs_abort(error_code, ...) |
| Abort. | |
| #define | ecs_assert(condition, error_code, ...) |
| Assert. | |
| #define | ecs_dbg_assert(condition, error_code, ...) ecs_assert(condition, error_code, __VA_ARGS__) |
| Debug assert. | |
| #define | ecs_always_assert(condition, error_code, ...) |
| Always assert. | |
| #define | ecs_san_assert(condition, error_code, ...) |
| Sanitize assert. | |
| #define | ecs_dummy_check |
| Silence dead code/unused label warnings when compiling without checks. | |
| #define | ecs_check(condition, error_code, ...) |
| Check. | |
| #define | ecs_throw(error_code, ...) |
| Panic. | |
| #define | ecs_parser_error(name, expr, column, ...) ecs_parser_error_(name, expr, column, __VA_ARGS__) |
| Parser error. | |
| #define | ecs_parser_errorv(name, expr, column, fmt, args) ecs_parser_errorv_(name, expr, column, fmt, args) |
| Parser error with va_list. | |
| #define | ecs_parser_warning(name, expr, column, ...) ecs_parser_warning_(name, expr, column, __VA_ARGS__) |
| Parser warning. | |
| #define | ecs_parser_warningv(name, expr, column, fmt, args) ecs_parser_warningv_(name, expr, column, fmt, args) |
| Parser warning with va_list. | |
| #define | ECS_INVALID_OPERATION (1) |
| Invalid operation error code. | |
| #define | ECS_INVALID_PARAMETER (2) |
| Invalid parameter error code. | |
| #define | ECS_CONSTRAINT_VIOLATED (3) |
| Constraint violated error code. | |
| #define | ECS_OUT_OF_MEMORY (4) |
| Out of memory error code. | |
| #define | ECS_OUT_OF_RANGE (5) |
| Out of range error code. | |
| #define | ECS_UNSUPPORTED (6) |
| Unsupported error code. | |
| #define | ECS_INTERNAL_ERROR (7) |
| Internal error code. | |
| #define | ECS_ALREADY_DEFINED (8) |
| Already defined error code. | |
| #define | ECS_MISSING_OS_API (9) |
| Missing OS API error code. | |
| #define | ECS_OPERATION_FAILED (10) |
| Operation failed error code. | |
| #define | ECS_INVALID_CONVERSION (11) |
| Invalid conversion error code. | |
| #define | ECS_CYCLE_DETECTED (13) |
| Cycle detected error code. | |
| #define | ECS_LEAK_DETECTED (14) |
| Leak detected error code. | |
| #define | ECS_DOUBLE_FREE (15) |
| Double free error code. | |
| #define | ECS_INCONSISTENT_NAME (20) |
| Inconsistent name error code. | |
| #define | ECS_NAME_IN_USE (21) |
| Name in use error code. | |
| #define | ECS_INVALID_COMPONENT_SIZE (23) |
| Invalid component size error code. | |
| #define | ECS_INVALID_COMPONENT_ALIGNMENT (24) |
| Invalid component alignment error code. | |
| #define | ECS_COMPONENT_NOT_REGISTERED (25) |
| Component not registered error code. | |
| #define | ECS_INCONSISTENT_COMPONENT_ID (26) |
| Inconsistent component id error code. | |
| #define | ECS_INCONSISTENT_COMPONENT_ACTION (27) |
| Inconsistent component action error code. | |
| #define | ECS_MODULE_UNDEFINED (28) |
| Module undefined error code. | |
| #define | ECS_MISSING_SYMBOL (29) |
| Missing symbol error code. | |
| #define | ECS_ALREADY_IN_USE (30) |
| Already in use error code. | |
| #define | ECS_ACCESS_VIOLATION (40) |
| Access violation error code. | |
| #define | ECS_COLUMN_INDEX_OUT_OF_RANGE (41) |
| Column index out of range error code. | |
| #define | ECS_COLUMN_IS_NOT_SHARED (42) |
| Column is not shared error code. | |
| #define | ECS_COLUMN_IS_SHARED (43) |
| Column is shared error code. | |
| #define | ECS_COLUMN_TYPE_MISMATCH (45) |
| Column type mismatch error code. | |
| #define | ECS_INVALID_WHILE_READONLY (70) |
| Invalid while readonly error code. | |
| #define | ECS_LOCKED_STORAGE (71) |
| Locked storage error code. | |
| #define | ECS_INVALID_FROM_WORKER (72) |
| Invalid from worker error code. | |
| #define | ECS_BLACK "\033[1;30m" |
| Black ANSI color escape code. | |
| #define | ECS_RED "\033[0;31m" |
| Red ANSI color escape code. | |
| #define | ECS_GREEN "\033[0;32m" |
| Green ANSI color escape code. | |
| #define | ECS_YELLOW "\033[0;33m" |
| Yellow ANSI color escape code. | |
| #define | ECS_BLUE "\033[0;34m" |
| Blue ANSI color escape code. | |
| #define | ECS_MAGENTA "\033[0;35m" |
| Magenta ANSI color escape code. | |
| #define | ECS_CYAN "\033[0;36m" |
| Cyan ANSI color escape code. | |
| #define | ECS_WHITE "\033[1;37m" |
| White ANSI color escape code. | |
| #define | ECS_GREY "\033[0;37m" |
| Grey ANSI color escape code. | |
| #define | ECS_NORMAL "\033[0;49m" |
| Normal ANSI color escape code. | |
| #define | ECS_BOLD "\033[1;49m" |
| Bold ANSI escape code. | |
Functions | |
| FLECS_API void | ecs_deprecated_ (const char *file, int32_t line, const char *msg) |
| Log message indicating an operation is deprecated. | |
| FLECS_API void | ecs_log_push_ (int32_t level) |
| Increase log stack. | |
| FLECS_API void | ecs_log_pop_ (int32_t level) |
| Decrease log stack. | |
| FLECS_API bool | ecs_should_log (int32_t level) |
| Should current level be logged. | |
| FLECS_API const char * | ecs_strerror (int32_t error_code) |
| Get description for error code. | |
| FLECS_API void | ecs_print_ (int32_t level, const char *file, int32_t line, const char *fmt,...) |
| Print at the provided log level. | |
| FLECS_API void | ecs_printv_ (int level, const char *file, int32_t line, const char *fmt, va_list args) |
| Print at the provided log level (va_list). | |
| FLECS_API void | ecs_log_ (int32_t level, const char *file, int32_t line, const char *fmt,...) |
| Log at the provided level. | |
| FLECS_API void | ecs_logv_ (int level, const char *file, int32_t line, const char *fmt, va_list args) |
| Log at the provided level (va_list). | |
| FLECS_API void | ecs_abort_ (int32_t error_code, const char *file, int32_t line, const char *fmt,...) |
| Abort with error code. | |
| FLECS_API void | ecs_assert_log_ (int32_t error_code, const char *condition_str, const char *file, int32_t line, const char *fmt,...) |
| Log an assertion failure. | |
| FLECS_API void | ecs_parser_error_ (const char *name, const char *expr, int64_t column, const char *fmt,...) |
| Log a parser error. | |
| FLECS_API void | ecs_parser_errorv_ (const char *name, const char *expr, int64_t column, const char *fmt, va_list args) |
| Log a parser error (va_list). | |
| FLECS_API void | ecs_parser_warning_ (const char *name, const char *expr, int64_t column, const char *fmt,...) |
| Log a parser warning. | |
| FLECS_API void | ecs_parser_warningv_ (const char *name, const char *expr, int64_t column, const char *fmt, va_list args) |
| Log a parser warning (va_list). | |
| FLECS_API int | ecs_log_set_level (int level) |
| Enable or disable log. | |
| FLECS_API int | ecs_log_get_level (void) |
| Get current log level. | |
| FLECS_API bool | ecs_log_enable_colors (bool enabled) |
| Enable/disable tracing with colors. | |
| FLECS_API bool | ecs_log_enable_timestamp (bool enabled) |
| Enable/disable logging timestamp. | |
| FLECS_API bool | ecs_log_enable_timedelta (bool enabled) |
| Enable/disable logging time since last log. | |
| FLECS_API int | ecs_log_last_error (void) |
| Get last logged error code. | |
| FLECS_API void | ecs_log_start_capture (bool capture_try) |
| Start capturing log output. | |
| FLECS_API char * | ecs_log_stop_capture (void) |
| Stop capturing log output. | |
Logging functions.
| #define ecs_abort | ( | error_code, | |
| ... ) |
Abort.
Unconditionally aborts the process.
| #define ECS_ACCESS_VIOLATION (40) |
| #define ecs_always_assert | ( | condition, | |
| error_code, | |||
| ... ) |
Always assert.
Assert that is always active, even in release builds. Always aborts on failure (does not support FLECS_SOFT_ASSERT).
| #define ecs_assert | ( | condition, | |
| error_code, | |||
| ... ) |
| #define ecs_check | ( | condition, | |
| error_code, | |||
| ... ) |
Check.
Go to error if condition is false.
| #define ECS_COLUMN_INDEX_OUT_OF_RANGE (41) |
| #define ECS_COLUMN_IS_NOT_SHARED (42) |
| #define ECS_COLUMN_IS_SHARED (43) |
| #define ECS_COLUMN_TYPE_MISMATCH (45) |
| #define ECS_COMPONENT_NOT_REGISTERED (25) |
| #define ECS_CONSTRAINT_VIOLATED (3) |
| #define ecs_dbg ecs_dbg_1 |
| #define ecs_dbg_1 | ( | ... | ) | ecs_log(1, __VA_ARGS__); |
| #define ecs_dbg_2 | ( | ... | ) | ecs_log(2, __VA_ARGS__); |
| #define ecs_dbg_3 | ( | ... | ) | ecs_log(3, __VA_ARGS__); |
| #define ecs_dbg_assert | ( | condition, | |
| error_code, | |||
| ... ) ecs_assert(condition, error_code, __VA_ARGS__) |
| #define ecs_deprecated | ( | ... | ) | ecs_deprecated_(__FILE__, __LINE__, __VA_ARGS__) |
| #define ecs_dummy_check |
| #define ecs_err | ( | ... | ) | ecs_err_(__FILE__, __LINE__, __VA_ARGS__) |
| #define ecs_err_ | ( | file, | |
| line, | |||
| ... ) ecs_log_(-3, file, line, __VA_ARGS__) |
| #define ecs_fatal | ( | ... | ) | ecs_fatal_(__FILE__, __LINE__, __VA_ARGS__) |
| #define ecs_fatal_ | ( | file, | |
| line, | |||
| ... ) ecs_log_(-4, file, line, __VA_ARGS__) |
| #define ECS_INCONSISTENT_COMPONENT_ACTION (27) |
| #define ECS_INCONSISTENT_COMPONENT_ID (26) |
| #define ECS_INCONSISTENT_NAME (20) |
| #define ECS_INVALID_COMPONENT_ALIGNMENT (24) |
| #define ECS_INVALID_COMPONENT_SIZE (23) |
| #define ECS_INVALID_CONVERSION (11) |
| #define ECS_INVALID_FROM_WORKER (72) |
| #define ECS_INVALID_OPERATION (1) |
| #define ECS_INVALID_PARAMETER (2) |
| #define ECS_INVALID_WHILE_READONLY (70) |
| #define ecs_log | ( | level, | |
| ... ) ecs_log_(level, __FILE__, __LINE__, __VA_ARGS__) |
| #define ecs_log_pop | ( | ) | ecs_log_pop_(0) |
| #define ecs_log_pop_1 | ( | ) | ecs_log_pop_(1); |
| #define ecs_log_pop_2 | ( | ) | ecs_log_pop_(2); |
| #define ecs_log_pop_3 | ( | ) | ecs_log_pop_(3); |
| #define ecs_log_push | ( | ) | ecs_log_push_(0) |
| #define ecs_log_push_1 | ( | ) | ecs_log_push_(1); |
| #define ecs_log_push_2 | ( | ) | ecs_log_push_(2); |
| #define ecs_log_push_3 | ( | ) | ecs_log_push_(3); |
| #define ecs_logv | ( | level, | |
| fmt, | |||
| args ) ecs_logv_(level, __FILE__, __LINE__, fmt, args) |
| #define ECS_MAGENTA "\033[0;35m" |
| #define ECS_MODULE_UNDEFINED (28) |
| #define ECS_NORMAL "\033[0;49m" |
| #define ECS_OPERATION_FAILED (10) |
| #define ecs_parser_error | ( | name, | |
| expr, | |||
| column, | |||
| ... ) ecs_parser_error_(name, expr, column, __VA_ARGS__) |
| #define ecs_parser_errorv | ( | name, | |
| expr, | |||
| column, | |||
| fmt, | |||
| args ) ecs_parser_errorv_(name, expr, column, fmt, args) |
| #define ecs_parser_warning | ( | name, | |
| expr, | |||
| column, | |||
| ... ) ecs_parser_warning_(name, expr, column, __VA_ARGS__) |
| #define ecs_parser_warningv | ( | name, | |
| expr, | |||
| column, | |||
| fmt, | |||
| args ) ecs_parser_warningv_(name, expr, column, fmt, args) |
| #define ecs_print | ( | level, | |
| ... ) ecs_print_(level, __FILE__, __LINE__, __VA_ARGS__) |
| #define ecs_printv | ( | level, | |
| fmt, | |||
| args ) ecs_printv_(level, __FILE__, __LINE__, fmt, args) |
| #define ecs_san_assert | ( | condition, | |
| error_code, | |||
| ... ) |
| #define ecs_should_log_1 | ( | ) | ecs_should_log(1) |
| #define ecs_should_log_2 | ( | ) | ecs_should_log(2) |
| #define ecs_should_log_3 | ( | ) | ecs_should_log(3) |
| #define ecs_throw | ( | error_code, | |
| ... ) |
| #define ecs_trace | ( | ... | ) | ecs_trace_(__FILE__, __LINE__, __VA_ARGS__) |
| #define ecs_trace_ | ( | file, | |
| line, | |||
| ... ) ecs_log_(0, file, line, __VA_ARGS__) |
| #define ecs_warn | ( | ... | ) | ecs_warn_(__FILE__, __LINE__, __VA_ARGS__) |
| #define ecs_warn_ | ( | file, | |
| line, | |||
| ... ) ecs_log_(-2, file, line, __VA_ARGS__) |
| #define ECS_YELLOW "\033[0;33m" |
| #define FLECS_LOG_3 /* Enable all tracing in debug mode. May slow things down */ |
| FLECS_API void ecs_abort_ | ( | int32_t | error_code, |
| const char * | file, | ||
| int32_t | line, | ||
| const char * | fmt, | ||
| ... ) |
Abort with error code.
| error_code | The error code. |
| file | The source file. |
| line | The source line. |
| fmt | The format string. |
| FLECS_API void ecs_assert_log_ | ( | int32_t | error_code, |
| const char * | condition_str, | ||
| const char * | file, | ||
| int32_t | line, | ||
| const char * | fmt, | ||
| ... ) |
Log an assertion failure.
| error_code | The error code. |
| condition_str | The condition that was not met. |
| file | The source file. |
| line | The source line. |
| fmt | The format string. |
| FLECS_API void ecs_deprecated_ | ( | const char * | file, |
| int32_t | line, | ||
| const char * | msg ) |
Log message indicating an operation is deprecated.
| file | The source file. |
| line | The source line. |
| msg | The deprecation message. |
| FLECS_API void ecs_log_ | ( | int32_t | level, |
| const char * | file, | ||
| int32_t | line, | ||
| const char * | fmt, | ||
| ... ) |
Log at the provided level.
| level | The log level. |
| file | The source file. |
| line | The source line. |
| fmt | The format string. |
| FLECS_API bool ecs_log_enable_colors | ( | bool | enabled | ) |
Enable/disable tracing with colors.
By default, colors are enabled.
| enabled | Whether to enable tracing with colors. |
| FLECS_API bool ecs_log_enable_timedelta | ( | bool | enabled | ) |
Enable/disable logging time since last log.
By default, deltatime is disabled. Note that enabling timestamps introduces overhead as the logging code will need to obtain the current time.
When enabled, this logs the amount of time in seconds passed since the last log, when this amount is non-zero. The format is a '+' character followed by the number of seconds:
+1 trace: log message
| enabled | Whether to enable tracing with timestamps. |
| FLECS_API bool ecs_log_enable_timestamp | ( | bool | enabled | ) |
Enable/disable logging timestamp.
By default, timestamps are disabled. Note that enabling timestamps introduces overhead as the logging code will need to obtain the current time.
| enabled | Whether to enable tracing with timestamps. |
| FLECS_API int ecs_log_get_level | ( | void | ) |
Get current log level.
| FLECS_API int ecs_log_last_error | ( | void | ) |
Get last logged error code.
Calling this operation resets the error code.
| FLECS_API void ecs_log_pop_ | ( | int32_t | level | ) |
Decrease log stack.
This operation decreases the indent_ value of the OS API and can be useful to make nested behavior more visible.
| level | The log level. |
| FLECS_API void ecs_log_push_ | ( | int32_t | level | ) |
Increase log stack.
This operation increases the indent_ value of the OS API and can be useful to make nested behavior more visible.
| level | The log level. |
| FLECS_API int ecs_log_set_level | ( | int | level | ) |
Enable or disable log.
This will enable the built-in log. For log to work, it will have to be compiled in, which requires defining one of the following macros:
FLECS_LOG_0 - All log is disabled FLECS_LOG_1 - Enable log level 1 FLECS_LOG_2 - Enable log level 2 and below FLECS_LOG_3 - Enable log level 3 and below
If no log level is defined and this is a debug build, FLECS_LOG_3 will have been automatically defined.
The provided level corresponds with the log level. If -1 is provided as value, warnings are disabled. If -2 is provided, errors are disabled as well.
| level | Desired tracing level. |
| FLECS_API void ecs_log_start_capture | ( | bool | capture_try | ) |
Start capturing log output.
| capture_try | If true, also capture messages from ecs_log_try blocks. |
| FLECS_API char * ecs_log_stop_capture | ( | void | ) |
Stop capturing log output.
| FLECS_API void ecs_logv_ | ( | int | level, |
| const char * | file, | ||
| int32_t | line, | ||
| const char * | fmt, | ||
| va_list | args ) |
Log at the provided level (va_list).
| level | The log level. |
| file | The source file. |
| line | The source line. |
| fmt | The format string. |
| args | The format argument list. |
| FLECS_API void ecs_parser_error_ | ( | const char * | name, |
| const char * | expr, | ||
| int64_t | column, | ||
| const char * | fmt, | ||
| ... ) |
Log a parser error.
| name | The name of the expression. |
| expr | The expression string. |
| column | The column at which the error occurred. |
| fmt | The format string. |
| FLECS_API void ecs_parser_errorv_ | ( | const char * | name, |
| const char * | expr, | ||
| int64_t | column, | ||
| const char * | fmt, | ||
| va_list | args ) |
Log a parser error (va_list).
| name | The name of the expression. |
| expr | The expression string. |
| column | The column at which the error occurred. |
| fmt | The format string. |
| args | The format argument list. |
| FLECS_API void ecs_parser_warning_ | ( | const char * | name, |
| const char * | expr, | ||
| int64_t | column, | ||
| const char * | fmt, | ||
| ... ) |
Log a parser warning.
| name | The name of the expression. |
| expr | The expression string. |
| column | The column at which the error occurred. |
| fmt | The format string. |
| FLECS_API void ecs_parser_warningv_ | ( | const char * | name, |
| const char * | expr, | ||
| int64_t | column, | ||
| const char * | fmt, | ||
| va_list | args ) |
Log a parser warning (va_list).
| name | The name of the expression. |
| expr | The expression string. |
| column | The column at which the error occurred. |
| fmt | The format string. |
| args | The format argument list. |
| FLECS_API void ecs_print_ | ( | int32_t | level, |
| const char * | file, | ||
| int32_t | line, | ||
| const char * | fmt, | ||
| ... ) |
Print at the provided log level.
| level | The log level. |
| file | The source file. |
| line | The source line. |
| fmt | The format string. |
| FLECS_API void ecs_printv_ | ( | int | level, |
| const char * | file, | ||
| int32_t | line, | ||
| const char * | fmt, | ||
| va_list | args ) |
Print at the provided log level (va_list).
| level | The log level. |
| file | The source file. |
| line | The source line. |
| fmt | The format string. |
| args | The format argument list. |
| FLECS_API bool ecs_should_log | ( | int32_t | level | ) |
Should current level be logged.
This operation returns true when the specified log level should be logged with the current log level.
| level | The log level to check for. |
| FLECS_API const char * ecs_strerror | ( | int32_t | error_code | ) |
Get description for error code.
| error_code | The error code. |