1 #include <stdio.h> 2 #include <stdarg.h> 3 #include "../minmax.h" 4 5 int log_err(const char *format, ...) 6 { 7 char buffer[1024]; 8 va_list args; 9 size_t len; 10 11 va_start(args, format); 12 len = vsnprintf(buffer, sizeof(buffer), format, args); 13 va_end(args); 14 len = min(len, sizeof(buffer) - 1); 15 16 return fwrite(buffer, len, 1, stderr); 17 } 18 19 int log_info(const char *format, ...) 20 { 21 char buffer[1024]; 22 va_list args; 23 size_t len; 24 25 va_start(args, format); 26 len = vsnprintf(buffer, sizeof(buffer), format, args); 27 va_end(args); 28 len = min(len, sizeof(buffer) - 1); 29 30 return fwrite(buffer, len, 1, stdout); 31 } 32