Skip to content
Flecs v4.2
log.h
Go to the documentation of this file.
1/**
2 * @file addons/log.h
3 * @brief Logging addon.
4 *
5 * The logging addon provides an API for (debug) tracing and reporting errors
6 * at various levels. When enabled, the logging addon can provide more detailed
7 * information about the state of the ECS and any errors that may occur.
8 *
9 * The logging addon can be disabled to reduce the footprint of the library, but
10 * limits information logged to only file, line, and error code.
11 *
12 * When enabled, the logging addon can be configured to exclude levels of tracing
13 * from the build to reduce the impact on performance. By default, all debug
14 * tracing is enabled for debug builds, tracing is enabled for release builds.
15 *
16 * Applications can change the logging level at runtime with ecs_log_set_level(),
17 * but what is actually logged depends on what is compiled (when compiled
18 * without debug tracing, setting the runtime level to debug won't have an
19 * effect).
20 *
21 * The logging addon uses the OS API log_() function for all tracing.
22 *
23 * Note that even when the logging addon is not enabled, its header and source must
24 * be included in a build. To prevent unused variable warnings in the code, some
25 * API functions are included when the addon is disabled, but have empty bodies.
26 */
27
28#ifndef FLECS_LOG_H
29#define FLECS_LOG_H
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35#ifdef FLECS_LOG
36
37/**
38 * @defgroup c_addons_log Log
39 * @ingroup c_addons
40 * Logging functions.
41 *
42 * @{
43 */
44
45////////////////////////////////////////////////////////////////////////////////
46//// Tracing
47////////////////////////////////////////////////////////////////////////////////
48
49/** Log message indicating an operation is deprecated.
50 *
51 * @param file The source file.
52 * @param line The source line.
53 * @param msg The deprecation message.
54 */
55FLECS_API
57 const char *file,
58 int32_t line,
59 const char *msg);
60
61/** Increase log stack.
62 * This operation increases the indent_ value of the OS API and can be useful to
63 * make nested behavior more visible.
64 *
65 * @param level The log level.
66 */
67FLECS_API
68void ecs_log_push_(int32_t level);
69
70/** Decrease log stack.
71 * This operation decreases the indent_ value of the OS API and can be useful to
72 * make nested behavior more visible.
73 *
74 * @param level The log level.
75 */
76FLECS_API
77void ecs_log_pop_(int32_t level);
78
79/** Should current level be logged.
80 * This operation returns true when the specified log level should be logged
81 * with the current log level.
82 *
83 * @param level The log level to check for.
84 * @return Whether logging is enabled for the current level.
85 */
86FLECS_API
87bool ecs_should_log(int32_t level);
88
89////////////////////////////////////////////////////////////////////////////////
90//// Error reporting
91////////////////////////////////////////////////////////////////////////////////
92
93/** Get description for error code.
94 *
95 * @param error_code The error code.
96 * @return String describing the error code.
97 */
98FLECS_API
99const char* ecs_strerror(
100 int32_t error_code);
101
102#else // FLECS_LOG
103
104////////////////////////////////////////////////////////////////////////////////
105//// Dummy macros for when logging is disabled
106////////////////////////////////////////////////////////////////////////////////
107
108#define ecs_deprecated_(file, line, msg)\
109 (void)file;\
110 (void)line;\
111 (void)msg
112
113#define ecs_log_push_(level)
114#define ecs_log_pop_(level)
115#define ecs_should_log(level) false
116
117#define ecs_strerror(error_code)\
118 (void)error_code
119
120#endif // FLECS_LOG
121
122
123////////////////////////////////////////////////////////////////////////////////
124//// Logging functions (do nothing when logging is disabled)
125////////////////////////////////////////////////////////////////////////////////
126
127/** Print at the provided log level.
128 *
129 * @param level The log level.
130 * @param file The source file.
131 * @param line The source line.
132 * @param fmt The format string.
133 */
134FLECS_API
136 int32_t level,
137 const char *file,
138 int32_t line,
139 const char *fmt,
140 ...)
141 ECS_FORMAT(4, 5);
142
143/** Print at the provided log level (va_list).
144 *
145 * @param level The log level.
146 * @param file The source file.
147 * @param line The source line.
148 * @param fmt The format string.
149 * @param args The format argument list.
150 */
151FLECS_API
153 int32_t level,
154 const char *file,
155 int32_t line,
156 const char *fmt,
157 va_list args);
158
159/** Log at the provided level.
160 *
161 * @param level The log level.
162 * @param file The source file.
163 * @param line The source line.
164 * @param fmt The format string.
165 */
166FLECS_API
168 int32_t level,
169 const char *file,
170 int32_t line,
171 const char *fmt,
172 ...)
173 ECS_FORMAT(4, 5);
174
175/** Log at the provided level (va_list).
176 *
177 * @param level The log level.
178 * @param file The source file.
179 * @param line The source line.
180 * @param fmt The format string.
181 * @param args The format argument list.
182 */
183FLECS_API
185 int32_t level,
186 const char *file,
187 int32_t line,
188 const char *fmt,
189 va_list args);
190
191/** Abort with error code.
192 *
193 * @param error_code The error code.
194 * @param file The source file.
195 * @param line The source line.
196 * @param fmt The format string.
197 */
198FLECS_API
200 int32_t error_code,
201 const char *file,
202 int32_t line,
203 const char *fmt,
204 ...)
205 ECS_FORMAT(4, 5);
206
207/** Log an assertion failure.
208 *
209 * @param error_code The error code.
210 * @param condition_str The condition that was not met.
211 * @param file The source file.
212 * @param line The source line.
213 * @param fmt The format string.
214 */
215FLECS_API
217 int32_t error_code,
218 const char *condition_str,
219 const char *file,
220 int32_t line,
221 const char *fmt,
222 ...)
223 ECS_FORMAT(5, 6);
224
225/** Log a parser error.
226 *
227 * @param name The name of the expression.
228 * @param expr The expression string.
229 * @param column The column at which the error occurred.
230 * @param fmt The format string.
231 */
232FLECS_API
234 const char *name,
235 const char *expr,
236 int64_t column,
237 const char *fmt,
238 ...)
239 ECS_FORMAT(4, 5);
240
241/** Log a parser error (va_list).
242 *
243 * @param name The name of the expression.
244 * @param expr The expression string.
245 * @param column The column at which the error occurred.
246 * @param fmt The format string.
247 * @param args The format argument list.
248 */
249FLECS_API
251 const char *name,
252 const char *expr,
253 int64_t column,
254 const char *fmt,
255 va_list args);
256
257/** Log a parser warning.
258 *
259 * @param name The name of the expression.
260 * @param expr The expression string.
261 * @param column The column at which the error occurred.
262 * @param fmt The format string.
263 */
264FLECS_API
266 const char *name,
267 const char *expr,
268 int64_t column,
269 const char *fmt,
270 ...)
271 ECS_FORMAT(4, 5);
272
273/** Log a parser warning (va_list).
274 *
275 * @param name The name of the expression.
276 * @param expr The expression string.
277 * @param column The column at which the error occurred.
278 * @param fmt The format string.
279 * @param args The format argument list.
280 */
281FLECS_API
283 const char *name,
284 const char *expr,
285 int64_t column,
286 const char *fmt,
287 va_list args);
288
289
290////////////////////////////////////////////////////////////////////////////////
291//// Logging macros
292////////////////////////////////////////////////////////////////////////////////
293
294#ifndef FLECS_LEGACY /* C89 doesn't support variadic macros */
295
296/** Base logging function. Accepts a custom level. */
297#define ecs_print(level, ...)\
298 ecs_print_(level, __FILE__, __LINE__, __VA_ARGS__)
299
300/** Base logging function with va_list. */
301#define ecs_printv(level, fmt, args)\
302 ecs_printv_(level, __FILE__, __LINE__, fmt, args)
303
304/** Log at the provided level. */
305#define ecs_log(level, ...)\
306 ecs_log_(level, __FILE__, __LINE__, __VA_ARGS__)
307
308/** Log at the provided level with va_list. */
309#define ecs_logv(level, fmt, args)\
310 ecs_logv_(level, __FILE__, __LINE__, fmt, args)
311
312/** Tracing. Used for logging of infrequent events. */
313#define ecs_trace_(file, line, ...) ecs_log_(0, file, line, __VA_ARGS__)
314/** Tracing macro. */
315#define ecs_trace(...) ecs_trace_(__FILE__, __LINE__, __VA_ARGS__)
316
317/** Warning. Used when an issue occurs, but operation is successful. */
318#define ecs_warn_(file, line, ...) ecs_log_(-2, file, line, __VA_ARGS__)
319/** Warning macro. */
320#define ecs_warn(...) ecs_warn_(__FILE__, __LINE__, __VA_ARGS__)
321
322/** Error. Used when an issue occurs, and operation failed. */
323#define ecs_err_(file, line, ...) ecs_log_(-3, file, line, __VA_ARGS__)
324/** Error macro. */
325#define ecs_err(...) ecs_err_(__FILE__, __LINE__, __VA_ARGS__)
326
327/** Fatal. Used when an issue occurs, and the application cannot continue. */
328#define ecs_fatal_(file, line, ...) ecs_log_(-4, file, line, __VA_ARGS__)
329/** Fatal macro. */
330#define ecs_fatal(...) ecs_fatal_(__FILE__, __LINE__, __VA_ARGS__)
331
332/** Optionally include warnings about using deprecated features. */
333#ifndef FLECS_NO_DEPRECATED_WARNINGS
334/** Emit deprecation warning. */
335#define ecs_deprecated(...)\
336 ecs_deprecated_(__FILE__, __LINE__, __VA_ARGS__)
337#else
338#define ecs_deprecated(...)
339#endif // FLECS_NO_DEPRECATED_WARNINGS
340
341/* If no tracing verbosity is defined, pick default based on build config */
342#if !(defined(FLECS_LOG_0) || defined(FLECS_LOG_1) || defined(FLECS_LOG_2) || defined(FLECS_LOG_3))
343#if !defined(FLECS_NDEBUG)
344#define FLECS_LOG_3 /* Enable all tracing in debug mode. May slow things down */
345#else
346#define FLECS_LOG_0 /* Only enable infrequent tracing in release mode */
347#endif // !defined(FLECS_NDEBUG)
348#endif // !(defined(FLECS_LOG_0) || defined(FLECS_LOG_1) || defined(FLECS_LOG_2) || defined(FLECS_LOG_3))
349
350
351/* Define/undefine macros based on compiled-in tracing level. This can optimize
352 * out tracing statements from a build, which improves performance. */
353
354#if defined(FLECS_LOG_3) /* All debug tracing enabled */
355/** Debug trace at level 1. */
356#define ecs_dbg_1(...) ecs_log(1, __VA_ARGS__);
357/** Debug trace at level 2. */
358#define ecs_dbg_2(...) ecs_log(2, __VA_ARGS__);
359/** Debug trace at level 3. */
360#define ecs_dbg_3(...) ecs_log(3, __VA_ARGS__);
361
362/** Push log indentation at level 1. */
363#define ecs_log_push_1() ecs_log_push_(1);
364/** Push log indentation at level 2. */
365#define ecs_log_push_2() ecs_log_push_(2);
366/** Push log indentation at level 3. */
367#define ecs_log_push_3() ecs_log_push_(3);
368
369/** Pop log indentation at level 1. */
370#define ecs_log_pop_1() ecs_log_pop_(1);
371/** Pop log indentation at level 2. */
372#define ecs_log_pop_2() ecs_log_pop_(2);
373/** Pop log indentation at level 3. */
374#define ecs_log_pop_3() ecs_log_pop_(3);
375
376/** Test if level 1 logging is enabled. */
377#define ecs_should_log_1() ecs_should_log(1)
378/** Test if level 2 logging is enabled. */
379#define ecs_should_log_2() ecs_should_log(2)
380/** Test if level 3 logging is enabled. */
381#define ecs_should_log_3() ecs_should_log(3)
382
383#define FLECS_LOG_2
384#define FLECS_LOG_1
385#define FLECS_LOG_0
386
387#elif defined(FLECS_LOG_2) /* Level 2 and below debug tracing enabled */
388#define ecs_dbg_1(...) ecs_log(1, __VA_ARGS__);
389#define ecs_dbg_2(...) ecs_log(2, __VA_ARGS__);
390#define ecs_dbg_3(...)
391
392#define ecs_log_push_1() ecs_log_push_(1);
393#define ecs_log_push_2() ecs_log_push_(2);
394#define ecs_log_push_3()
395
396#define ecs_log_pop_1() ecs_log_pop_(1);
397#define ecs_log_pop_2() ecs_log_pop_(2);
398#define ecs_log_pop_3()
399
400#define ecs_should_log_1() ecs_should_log(1)
401#define ecs_should_log_2() ecs_should_log(2)
402#define ecs_should_log_3() false
403
404#define FLECS_LOG_1
405#define FLECS_LOG_0
406
407#elif defined(FLECS_LOG_1) /* Level 1 debug tracing enabled */
408#define ecs_dbg_1(...) ecs_log(1, __VA_ARGS__);
409#define ecs_dbg_2(...)
410#define ecs_dbg_3(...)
411
412#define ecs_log_push_1() ecs_log_push_(1);
413#define ecs_log_push_2()
414#define ecs_log_push_3()
415
416#define ecs_log_pop_1() ecs_log_pop_(1);
417#define ecs_log_pop_2()
418#define ecs_log_pop_3()
419
420#define ecs_should_log_1() ecs_should_log(1)
421#define ecs_should_log_2() false
422#define ecs_should_log_3() false
423
424#define FLECS_LOG_0
425
426#elif defined(FLECS_LOG_0) /* No debug tracing enabled */
427#define ecs_dbg_1(...)
428#define ecs_dbg_2(...)
429#define ecs_dbg_3(...)
430
431#define ecs_log_push_1()
432#define ecs_log_push_2()
433#define ecs_log_push_3()
434
435#define ecs_log_pop_1()
436#define ecs_log_pop_2()
437#define ecs_log_pop_3()
438
439#define ecs_should_log_1() false
440#define ecs_should_log_2() false
441#define ecs_should_log_3() false
442
443#else /* No tracing enabled */
444#undef ecs_trace
445#define ecs_trace(...)
446#define ecs_dbg_1(...)
447#define ecs_dbg_2(...)
448#define ecs_dbg_3(...)
449
450#define ecs_log_push_1()
451#define ecs_log_push_2()
452#define ecs_log_push_3()
453
454#define ecs_log_pop_1()
455#define ecs_log_pop_2()
456#define ecs_log_pop_3()
457
458#endif // defined(FLECS_LOG_3)
459
460/** Default debug tracing is at level 1. */
461#define ecs_dbg ecs_dbg_1
462
463/** Push log indentation at the default level. */
464#define ecs_log_push() ecs_log_push_(0)
465/** Pop log indentation at the default level. */
466#define ecs_log_pop() ecs_log_pop_(0)
467
468/** Abort.
469 * Unconditionally aborts the process. */
470#define ecs_abort(error_code, ...)\
471 ecs_abort_(error_code, __FILE__, __LINE__, __VA_ARGS__);\
472 ecs_os_abort(); abort(); /* satisfy compiler/static analyzers */
473
474/** Assert.
475 * Aborts if condition is false, disabled in release mode. */
476#if defined(FLECS_NDEBUG) && !defined(FLECS_KEEP_ASSERT)
477#define ecs_assert(condition, error_code, ...)
478#else
479#define ecs_assert(condition, error_code, ...)\
480 if (!(condition)) {\
481 ecs_assert_log_(error_code, #condition, __FILE__, __LINE__, __VA_ARGS__);\
482 ecs_os_abort();\
483 }\
484 assert(condition) /* satisfy compiler/static analyzers */
485#endif // FLECS_NDEBUG
486
487/** Debug assert.
488 * Assert that is only valid in debug mode (ignores FLECS_KEEP_ASSERT). */
489#ifndef FLECS_NDEBUG
490#define ecs_dbg_assert(condition, error_code, ...) ecs_assert(condition, error_code, __VA_ARGS__)
491#else
492#define ecs_dbg_assert(condition, error_code, ...)
493#endif
494
495/** Always assert.
496 * Assert that is always active, even in release builds. Always aborts on
497 * failure (does not support FLECS_SOFT_ASSERT). */
498#define ecs_always_assert(condition, error_code, ...)\
499 if (!(condition)) {\
500 ecs_assert_log_(error_code, #condition, __FILE__, __LINE__, __VA_ARGS__);\
501 ecs_os_abort();\
502 }\
503 assert(condition) /* satisfy compiler/static analyzers */
504
505/** Sanitize assert.
506 * Assert that is only valid in sanitized mode (ignores FLECS_KEEP_ASSERT). */
507#ifdef FLECS_SANITIZE
508#define ecs_san_assert(condition, error_code, ...) ecs_assert(condition, error_code, __VA_ARGS__)
509#else
510#define ecs_san_assert(condition, error_code, ...)
511#endif
512
513
514/** Silence dead code/unused label warnings when compiling without checks. */
515#define ecs_dummy_check\
516 if ((false)) {\
517 goto error;\
518 }
519
520/** Check.
521 * Go to error if condition is false. */
522#if defined(FLECS_NDEBUG) && !defined(FLECS_KEEP_ASSERT)
523#define ecs_check(condition, error_code, ...) ecs_dummy_check
524#else
525#ifdef FLECS_SOFT_ASSERT
526#define ecs_check(condition, error_code, ...)\
527 if (!(condition)) {\
528 ecs_assert_log_(error_code, #condition, __FILE__, __LINE__, __VA_ARGS__);\
529 goto error;\
530 }\
531 ecs_dummy_check
532#else // FLECS_SOFT_ASSERT
533#define ecs_check(condition, error_code, ...)\
534 if (!(condition)) {\
535 ecs_assert_log_(error_code, #condition, __FILE__, __LINE__, __VA_ARGS__);\
536 ecs_os_abort();\
537 }\
538 assert(condition); /* satisfy compiler/static analyzers */ \
539 ecs_dummy_check
540#endif
541#endif // FLECS_NDEBUG
542
543/** Panic.
544 * Go to error when FLECS_SOFT_ASSERT is defined, otherwise abort. */
545#if defined(FLECS_NDEBUG) && !defined(FLECS_KEEP_ASSERT)
546#define ecs_throw(error_code, ...) ecs_dummy_check
547#else
548#ifdef FLECS_SOFT_ASSERT
549#define ecs_throw(error_code, ...)\
550 ecs_abort_(error_code, __FILE__, __LINE__, __VA_ARGS__);\
551 goto error;
552#else
553#define ecs_throw(error_code, ...)\
554 ecs_abort(error_code, __VA_ARGS__);\
555 ecs_dummy_check
556#endif
557#endif // FLECS_NDEBUG
558
559/** Parser error. */
560#define ecs_parser_error(name, expr, column, ...)\
561 ecs_parser_error_(name, expr, column, __VA_ARGS__)
562
563/** Parser error with va_list. */
564#define ecs_parser_errorv(name, expr, column, fmt, args)\
565 ecs_parser_errorv_(name, expr, column, fmt, args)
566
567/** Parser warning. */
568#define ecs_parser_warning(name, expr, column, ...)\
569 ecs_parser_warning_(name, expr, column, __VA_ARGS__)
570
571/** Parser warning with va_list. */
572#define ecs_parser_warningv(name, expr, column, fmt, args)\
573 ecs_parser_warningv_(name, expr, column, fmt, args)
574
575#endif // FLECS_LEGACY
576
577////////////////////////////////////////////////////////////////////////////////
578//// Functions that are always available
579////////////////////////////////////////////////////////////////////////////////
580
581/** Enable or disable log.
582 * This will enable the built-in log. For log to work, it will have to be
583 * compiled in, which requires defining one of the following macros:
584 *
585 * FLECS_LOG_0 - All log is disabled
586 * FLECS_LOG_1 - Enable log level 1
587 * FLECS_LOG_2 - Enable log level 2 and below
588 * FLECS_LOG_3 - Enable log level 3 and below
589 *
590 * If no log level is defined and this is a debug build, FLECS_LOG_3 will
591 * have been automatically defined.
592 *
593 * The provided level corresponds with the log level. If -1 is provided as
594 * value, warnings are disabled. If -2 is provided, errors are disabled as well.
595 *
596 * @param level Desired tracing level.
597 * @return Previous log level.
598 */
599FLECS_API
601 int level);
602
603/** Get current log level.
604 *
605 * @return Current log level.
606 */
607FLECS_API
609
610/** Enable/disable tracing with colors.
611 * By default, colors are enabled.
612 *
613 * @param enabled Whether to enable tracing with colors.
614 * @return Previous color setting.
615 */
616FLECS_API
618 bool enabled);
619
620/** Enable/disable logging timestamp.
621 * By default, timestamps are disabled. Note that enabling timestamps introduces
622 * overhead as the logging code will need to obtain the current time.
623 *
624 * @param enabled Whether to enable tracing with timestamps.
625 * @return Previous timestamp setting.
626 */
627FLECS_API
629 bool enabled);
630
631/** Enable/disable logging time since last log.
632 * By default, deltatime is disabled. Note that enabling timestamps introduces
633 * overhead as the logging code will need to obtain the current time.
634 *
635 * When enabled, this logs the amount of time in seconds passed since the last
636 * log, when this amount is non-zero. The format is a '+' character followed by
637 * the number of seconds:
638 *
639 * +1 trace: log message
640 *
641 * @param enabled Whether to enable tracing with timestamps.
642 * @return Previous timestamp setting.
643 */
644FLECS_API
646 bool enabled);
647
648/** Get last logged error code.
649 * Calling this operation resets the error code.
650 *
651 * @return Last error, 0 if none was logged since last call to last_error.
652 */
653FLECS_API
655
656/** Start capturing log output.
657 *
658 * @param capture_try If true, also capture messages from ecs_log_try blocks.
659 */
660FLECS_API
661void ecs_log_start_capture(bool capture_try);
662
663/** Stop capturing log output.
664 *
665 * @return The captured log output, or NULL if no output was captured.
666 */
667FLECS_API
669
670/** Start collecting errors.
671 * Errors that are logged after this call are appended to the provided vector
672 * as separate strings, instead of being written to the log. Warnings and other
673 * messages are forwarded to the log. Errors that are captured by a nested call
674 * to ecs_log_start_capture() are not collected, as the code that started the
675 * nested capture handles them.
676 *
677 * Calls to ecs_log_start_collect_errors() can be nested, where errors are
678 * collected by the innermost call. Each call must be matched with a call to
679 * ecs_log_stop_collect_errors().
680 *
681 * The strings in the vector must be freed by the application with
682 * ecs_os_free().
683 *
684 * @param errors An initialized vector (vec<char*>) that receives the errors.
685 */
686FLECS_API
688 ecs_vec_t *errors);
689
690/** Stop collecting errors.
691 * Stops collecting errors started by the last call to
692 * ecs_log_start_collect_errors().
693 */
694FLECS_API
696
697////////////////////////////////////////////////////////////////////////////////
698//// Error codes
699////////////////////////////////////////////////////////////////////////////////
700
701/** Invalid operation error code. */
702#define ECS_INVALID_OPERATION (1)
703/** Invalid parameter error code. */
704#define ECS_INVALID_PARAMETER (2)
705/** Constraint violated error code. */
706#define ECS_CONSTRAINT_VIOLATED (3)
707/** Out of memory error code. */
708#define ECS_OUT_OF_MEMORY (4)
709/** Out of range error code. */
710#define ECS_OUT_OF_RANGE (5)
711/** Unsupported error code. */
712#define ECS_UNSUPPORTED (6)
713/** Internal error code. */
714#define ECS_INTERNAL_ERROR (7)
715/** Already defined error code. */
716#define ECS_ALREADY_DEFINED (8)
717/** Missing OS API error code. */
718#define ECS_MISSING_OS_API (9)
719/** Operation failed error code. */
720#define ECS_OPERATION_FAILED (10)
721/** Invalid conversion error code. */
722#define ECS_INVALID_CONVERSION (11)
723/** Cycle detected error code. */
724#define ECS_CYCLE_DETECTED (13)
725/** Leak detected error code. */
726#define ECS_LEAK_DETECTED (14)
727/** Double free error code. */
728#define ECS_DOUBLE_FREE (15)
729
730/** Inconsistent name error code. */
731#define ECS_INCONSISTENT_NAME (20)
732/** Name in use error code. */
733#define ECS_NAME_IN_USE (21)
734/** Invalid component size error code. */
735#define ECS_INVALID_COMPONENT_SIZE (23)
736/** Invalid component alignment error code. */
737#define ECS_INVALID_COMPONENT_ALIGNMENT (24)
738/** Component not registered error code. */
739#define ECS_COMPONENT_NOT_REGISTERED (25)
740/** Inconsistent component id error code. */
741#define ECS_INCONSISTENT_COMPONENT_ID (26)
742/** Inconsistent component action error code. */
743#define ECS_INCONSISTENT_COMPONENT_ACTION (27)
744/** Module undefined error code. */
745#define ECS_MODULE_UNDEFINED (28)
746/** Missing symbol error code. */
747#define ECS_MISSING_SYMBOL (29)
748/** Already in use error code. */
749#define ECS_ALREADY_IN_USE (30)
750
751/** Access violation error code. */
752#define ECS_ACCESS_VIOLATION (40)
753/** Column index out of range error code. */
754#define ECS_COLUMN_INDEX_OUT_OF_RANGE (41)
755/** Column is not shared error code. */
756#define ECS_COLUMN_IS_NOT_SHARED (42)
757/** Column is shared error code. */
758#define ECS_COLUMN_IS_SHARED (43)
759/** Column type mismatch error code. */
760#define ECS_COLUMN_TYPE_MISMATCH (45)
761
762/** Invalid while readonly error code. */
763#define ECS_INVALID_WHILE_READONLY (70)
764/** Locked storage error code. */
765#define ECS_LOCKED_STORAGE (71)
766/** Invalid from worker error code. */
767#define ECS_INVALID_FROM_WORKER (72)
768
769
770////////////////////////////////////////////////////////////////////////////////
771//// Used when logging with colors is enabled
772////////////////////////////////////////////////////////////////////////////////
773
774/** Black ANSI color escape code. */
775#define ECS_BLACK "\033[1;30m"
776/** Red ANSI color escape code. */
777#define ECS_RED "\033[0;31m"
778/** Green ANSI color escape code. */
779#define ECS_GREEN "\033[0;32m"
780/** Yellow ANSI color escape code. */
781#define ECS_YELLOW "\033[0;33m"
782/** Blue ANSI color escape code. */
783#define ECS_BLUE "\033[0;34m"
784/** Magenta ANSI color escape code. */
785#define ECS_MAGENTA "\033[0;35m"
786/** Cyan ANSI color escape code. */
787#define ECS_CYAN "\033[0;36m"
788/** White ANSI color escape code. */
789#define ECS_WHITE "\033[1;37m"
790/** Grey ANSI color escape code. */
791#define ECS_GREY "\033[0;37m"
792/** Normal ANSI color escape code. */
793#define ECS_NORMAL "\033[0;49m"
794/** Bold ANSI escape code. */
795#define ECS_BOLD "\033[1;49m"
796
797#ifdef __cplusplus
798}
799#endif
800
801/** @} */
802
803#endif // FLECS_LOG_H
FLECS_API void ecs_parser_warning_(const char *name, const char *expr, int64_t column, const char *fmt,...) ECS_FORMAT(4
Log a parser warning.
FLECS_API void FLECS_API void ecs_logv_(int32_t level, const char *file, int32_t line, const char *fmt, va_list args)
Log at the provided level (va_list).
FLECS_API char * ecs_log_stop_capture(void)
Stop capturing log output.
FLECS_API void FLECS_API void FLECS_API void ecs_parser_error_(const char *name, const char *expr, int64_t column, const char *fmt,...) ECS_FORMAT(4
Log a parser error.
FLECS_API void ecs_log_stop_collect_errors(void)
Stop collecting errors.
FLECS_API int ecs_log_last_error(void)
Get last logged error code.
FLECS_API void ecs_log_pop_(int32_t level)
Decrease log stack.
FLECS_API void 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 void ecs_log_start_collect_errors(ecs_vec_t *errors)
Start collecting errors.
FLECS_API void ecs_abort_(int32_t error_code, const char *file, int32_t line, const char *fmt,...) ECS_FORMAT(4
Abort with error code.
FLECS_API void ecs_print_(int32_t level, const char *file, int32_t line, const char *fmt,...) ECS_FORMAT(4
Print at the provided log level.
FLECS_API void FLECS_API void ecs_printv_(int32_t 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_start_capture(bool capture_try)
Start capturing log output.
FLECS_API bool ecs_should_log(int32_t level)
Should current level be logged.
FLECS_API void ecs_log_(int32_t level, const char *file, int32_t line, const char *fmt,...) ECS_FORMAT(4
Log at the provided level.
FLECS_API void FLECS_API void FLECS_API void 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 const char * ecs_strerror(int32_t error_code)
Get description for error code.
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 FLECS_API void ecs_assert_log_(int32_t error_code, const char *condition_str, const char *file, int32_t line, const char *fmt,...) ECS_FORMAT(5
Log an assertion failure.
FLECS_API bool ecs_log_enable_colors(bool enabled)
Enable/disable tracing with colors.
FLECS_API int ecs_log_get_level(void)
Get current log level.
FLECS_API int ecs_log_set_level(int level)
Enable or disable log.
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.