Guest User

Untitled

a guest
Sep 10th, 2010
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. it can be improved. Here's my version:
  2.  
  3. log_error = 1;
  4. log_debug = 0;
  5.  
  6. #define LOG_PRINT(_log_level, _type, _fmt, _args...) do {
  7. if ((_log_level))
  8. warnx("%lld " _type _fmt,
  9. tick_diff_secs(rel_time, rdtsc()), ##_args);
  10. } while(0)
  11.  
  12. #define ERR_PRINT(fmt, args...)
  13. LOG_PRINT(log_error,"ERROR: ", fmt, ##args)
  14.  
  15. #define DBG_PRINT(fmt, args...)
  16. LOG_PRINT(log_debug, "DEBUG: ", fmt, ##args)
  17.  
  18. /* */
  19. ERR_PRINT("%d", some_int_var);
  20. DBG_PRINT("%d", some_int_var); // goes silent bcz log_debug = 0
Advertisement
Add Comment
Please, Sign In to add comment