diff options
Diffstat (limited to '')
-rw-r--r-- | src/log.h | 42 |
1 files changed, 21 insertions, 21 deletions
@@ -34,49 +34,49 @@ static inline void log_prefix(FILE *dest) log_print_timestamp(dest); } -#define log_error_prefix() \ +#define log_err_prefix() \ do { \ log_prefix(stderr); \ fprintf(stderr, "%s(%d): ", basename(__FILE__), __LINE__); \ } while (0) -#define print_errno(s) \ +#define log(...) \ do { \ - log_error_prefix(); \ - perror(s); \ + log_prefix(stdout); \ + printf(__VA_ARGS__); \ } while (0) -#define check_errno(expr, s) \ +#define log_err(...) \ do { \ - int CONCAT(ret, __LINE__) = expr; \ - if (CONCAT(ret, __LINE__) < 0) \ - print_errno(s); \ + log_err_prefix(); \ + fprintf(stderr, __VA_ARGS__); \ } while (0) -#define pthread_print_errno(var, s) \ +#define log_errno(s) \ do { \ - errno = var; \ - print_errno(s); \ - var = -var; \ + log_err_prefix(); \ + perror(s); \ } while (0) -#define pthread_check(expr, s) \ +#define log_errno_if(expr, s) \ do { \ int CONCAT(ret, __LINE__) = expr; \ - if (CONCAT(ret, __LINE__)) \ - pthread_print_errno(CONCAT(ret, __LINE__), s); \ + if (CONCAT(ret, __LINE__) < 0) \ + log_errno(s); \ } while (0) -#define print_error(...) \ +#define pthread_errno(var, s) \ do { \ - log_error_prefix(); \ - fprintf(stderr, __VA_ARGS__); \ + errno = var; \ + log_errno(s); \ + var = -var; \ } while (0) -#define print_log(...) \ +#define pthread_errno_if(expr, s) \ do { \ - log_prefix(stdout); \ - printf(__VA_ARGS__); \ + int CONCAT(ret, __LINE__) = expr; \ + if (CONCAT(ret, __LINE__)) \ + pthread_errno(CONCAT(ret, __LINE__), s); \ } while (0) #endif |