| 93 | } |
| 94 | |
| 95 | static void logreport(int priority, const char *err, va_list params) |
| 96 | { |
| 97 | switch (log_destination) { |
| 98 | case LOG_DESTINATION_SYSLOG: { |
| 99 | char buf[1024]; |
| 100 | vsnprintf(buf, sizeof(buf), err, params); |
| 101 | syslog(priority, "%s", buf); |
| 102 | break; |
| 103 | } |
| 104 | case LOG_DESTINATION_STDERR: |
| 105 | /* |
| 106 | * Since stderr is set to buffered mode, the |
| 107 | * logging of different processes will not overlap |
| 108 | * unless they overflow the (rather big) buffers. |
| 109 | */ |
| 110 | fprintf(stderr, "[%"PRIuMAX"] ", (uintmax_t)getpid()); |
| 111 | vfprintf(stderr, err, params); |
| 112 | fputc('\n', stderr); |
| 113 | fflush(stderr); |
| 114 | break; |
| 115 | case LOG_DESTINATION_NONE: |
| 116 | break; |
| 117 | case LOG_DESTINATION_UNSET: |
| 118 | BUG("log destination not initialized correctly"); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | __attribute__((format (printf, 1, 2))) |
| 123 | static void logerror(const char *err, ...) |
no test coverage detected