|
81 | 81 | it works on Windows, so it's experimental for now. |
82 | 82 | - NOB_STRIP_PREFIX - string the `nob_` prefixes from non-redefinable names. |
83 | 83 | - NOB_NO_ECHO - do not echo the actions various nob functions are doing (like nob_cmd_run(), nob_mkdir_if_not_exists(), etc). |
| 84 | + - NOB_LOG_CUSTOM_IMPLEMENTATION - Declares nob_log_default as a separate function with the same signature as nob_log |
| 85 | + and renames the definition of nob_log to nob_log_default. The user must define and implement nob_log themselves. |
84 | 86 |
|
85 | 87 | ## Redefinable Macros |
86 | 88 |
|
@@ -207,7 +209,12 @@ typedef enum { |
207 | 209 | // Any messages with the level below nob_minimal_log_level are going to be suppressed. |
208 | 210 | extern Nob_Log_Level nob_minimal_log_level; |
209 | 211 |
|
210 | | -NOBDEF void nob_log(Nob_Log_Level level, const char *fmt, ...) NOB_PRINTF_FORMAT(2, 3); |
| 212 | +#define NOB_LOG_DECLARATION(nob_log_name) NOBDEF void nob_log_name(Nob_Log_Level level, const char *fmt, ...) NOB_PRINTF_FORMAT(2, 3) |
| 213 | +NOB_LOG_DECLARATION(nob_log); |
| 214 | +#ifdef NOB_LOG_CUSTOM_IMPLEMENTATION |
| 215 | +NOB_LOG_DECLARATION(nob_log_default); |
| 216 | +#endif |
| 217 | +#undef NOB_LOG_DECLARATION |
211 | 218 |
|
212 | 219 | // It is an equivalent of shift command from bash (do `help shift` in bash). It basically |
213 | 220 | // pops an element from the beginning of a sized array. |
@@ -1535,7 +1542,13 @@ NOBDEF bool nob_cmd_run_sync_redirect_and_reset(Nob_Cmd *cmd, Nob_Cmd_Redirect r |
1535 | 1542 | return nob_proc_wait(p); |
1536 | 1543 | } |
1537 | 1544 |
|
1538 | | -NOBDEF void nob_log(Nob_Log_Level level, const char *fmt, ...) |
| 1545 | +NOBDEF void |
| 1546 | +#ifdef NOB_LOG_CUSTOM_IMPLEMENTATION |
| 1547 | +nob_log_default |
| 1548 | +#else |
| 1549 | +nob_log |
| 1550 | +#endif |
| 1551 | +(Nob_Log_Level level, const char *fmt, ...) |
1539 | 1552 | { |
1540 | 1553 | if (level < nob_minimal_log_level) return; |
1541 | 1554 |
|
@@ -2344,6 +2357,9 @@ NOBDEF int closedir(DIR *dirp) |
2344 | 2357 | // NOTE: Name log is already defined in math.h and historically always was the natural logarithmic function. |
2345 | 2358 | // So there should be no reason to strip the `nob_` prefix in this specific case. |
2346 | 2359 | // #define log nob_log |
| 2360 | + #ifdef NOB_LOG_CUSTOM_IMPLEMENTATION |
| 2361 | + #define log_default nob_log_default |
| 2362 | + #endif // NOB_LOG_CUSTOM_IMPLEMENTATION |
2347 | 2363 | #define shift nob_shift |
2348 | 2364 | #define shift_args nob_shift_args |
2349 | 2365 | #define File_Paths Nob_File_Paths |
|
0 commit comments