log-stderr.c 549 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include <stdio.h>
  2. #include <stdarg.h>
  3. #include <stdlib.h>
  4. #include "log.h"
  5. void
  6. rpcapd_log_init(void)
  7. {
  8. }
  9. void
  10. rpcapd_log(log_priority priority, const char *message, ...)
  11. {
  12. const char *tag;
  13. va_list ap;
  14. switch (priority) {
  15. case LOGPRIO_INFO:
  16. tag = "";
  17. break;
  18. case LOGPRIO_WARNING:
  19. tag = "warning: ";
  20. break;
  21. case LOGPRIO_ERROR:
  22. tag = "error: ";
  23. break;
  24. default:
  25. abort();
  26. /* NOTREACHED */
  27. }
  28. fprintf(stderr, "rpcapd: %s", tag);
  29. va_start(ap, message);
  30. vfprintf(stderr, message, ap);
  31. va_end(ap);
  32. putc('\n', stderr);
  33. }