|
1 | | -/* nob - v3.4.0 - Public Domain - https://github.com/tsoding/nob.h |
| 1 | +/* nob - v3.5.0 - Public Domain - https://github.com/tsoding/nob.h |
2 | 2 |
|
3 | 3 | This library is the next generation of the [NoBuild](https://github.com/tsoding/nobuild) idea. |
4 | 4 |
|
@@ -219,13 +219,16 @@ typedef enum { |
219 | 219 | // Any messages with the level below nob_minimal_log_level are going to be suppressed. |
220 | 220 | extern Nob_Log_Level nob_minimal_log_level; |
221 | 221 |
|
222 | | -typedef void (nob_log_handler)(Nob_Log_Level level, const char *fmt, va_list args); |
| 222 | +typedef void (Nob_Log_Handler)(Nob_Log_Level level, const char *fmt, va_list args); |
| 223 | +NOB_DEPRECATED("Uncapitalized nob_log_handler type is deprecated. Use Nob_Log_Handler instead. It's just when we were releasing the log handler feature we forgot that we had a convention that all the types must be capitalized like that. Sorry about it!") |
| 224 | +typedef Nob_Log_Handler nob_log_handler; |
223 | 225 |
|
224 | | -NOBDEF void nob_set_log_handler(nob_log_handler *handler); |
225 | | -NOBDEF nob_log_handler *nob_get_log_handler(void); |
| 226 | +NOBDEF void nob_set_log_handler(Nob_Log_Handler *handler); |
| 227 | +NOBDEF Nob_Log_Handler *nob_get_log_handler(void); |
226 | 228 |
|
227 | | -NOBDEF nob_log_handler nob_default_log_handler; |
228 | | -NOBDEF nob_log_handler nob_cancer_log_handler; |
| 229 | +NOBDEF Nob_Log_Handler nob_default_log_handler; |
| 230 | +NOBDEF Nob_Log_Handler nob_cancer_log_handler; |
| 231 | +NOBDEF Nob_Log_Handler nob_null_log_handler; |
229 | 232 |
|
230 | 233 | NOBDEF void nob_log(Nob_Log_Level level, const char *fmt, ...) NOB_PRINTF_FORMAT(2, 3); |
231 | 234 |
|
@@ -1849,14 +1852,14 @@ NOBDEF bool nob_cmd_run_sync_redirect_and_reset(Nob_Cmd *cmd, Nob_Cmd_Redirect r |
1849 | 1852 | return nob_proc_wait(p); |
1850 | 1853 | } |
1851 | 1854 |
|
1852 | | -static nob_log_handler *nob__log_handler = &nob_default_log_handler; |
| 1855 | +static Nob_Log_Handler *nob__log_handler = &nob_default_log_handler; |
1853 | 1856 |
|
1854 | | -NOBDEF void nob_set_log_handler(nob_log_handler *handler) |
| 1857 | +NOBDEF void nob_set_log_handler(Nob_Log_Handler *handler) |
1855 | 1858 | { |
1856 | 1859 | nob__log_handler = handler; |
1857 | 1860 | } |
1858 | 1861 |
|
1859 | | -NOBDEF nob_log_handler *nob_get_log_handler(void) |
| 1862 | +NOBDEF Nob_Log_Handler *nob_get_log_handler(void) |
1860 | 1863 | { |
1861 | 1864 | return nob__log_handler; |
1862 | 1865 | } |
@@ -1884,6 +1887,13 @@ NOBDEF void nob_default_log_handler(Nob_Log_Level level, const char *fmt, va_lis |
1884 | 1887 | fprintf(stderr, "\n"); |
1885 | 1888 | } |
1886 | 1889 |
|
| 1890 | +NOBDEF void nob_null_log_handler(Nob_Log_Level level, const char *fmt, va_list args) |
| 1891 | +{ |
| 1892 | + NOB_UNUSED(level); |
| 1893 | + NOB_UNUSED(fmt); |
| 1894 | + NOB_UNUSED(args); |
| 1895 | +} |
| 1896 | + |
1887 | 1897 | NOBDEF void nob_cancer_log_handler(Nob_Log_Level level, const char *fmt, va_list args) |
1888 | 1898 | { |
1889 | 1899 | switch (level) { |
@@ -2801,8 +2811,10 @@ NOBDEF char *nob_temp_running_executable_path(void) |
2801 | 2811 | #define Log_Level Nob_Log_Level |
2802 | 2812 | #define minimal_log_level nob_minimal_log_level |
2803 | 2813 | #define log_handler nob_log_handler |
| 2814 | + #define Log_Handler Nob_Log_Handler |
2804 | 2815 | #define set_log_handler nob_set_log_handler |
2805 | 2816 | #define get_log_handler nob_get_log_handler |
| 2817 | + #define null_log_handler nob_null_log_handler |
2806 | 2818 | #define default_log_handler nob_default_log_handler |
2807 | 2819 | #define cancer_log_handler nob_cancer_log_handler |
2808 | 2820 | // NOTE: Name log is already defined in math.h and historically always was the natural logarithmic function. |
@@ -2947,6 +2959,8 @@ NOBDEF char *nob_temp_running_executable_path(void) |
2947 | 2959 | /* |
2948 | 2960 | Revision history: |
2949 | 2961 |
|
| 2962 | + 3.5.0 (2026-03-13) Add nob_null_log_handler (by @rexim) |
| 2963 | + Rename nob_log_handler to Nob_Log_Handler (by @rexim) |
2950 | 2964 | 3.4.0 (2026-03-12) Add nob_da_first() (by @rexim) |
2951 | 2965 | Add nob_da_pop() (by @rexim) |
2952 | 2966 | Add nob_sv_chop_while() (by @rexim) |
|
0 commit comments