1 #ifndef _LOG_H_ 2 #define _LOG_H_ 3 #include "first.h" 4 5 #include "base_decls.h" 6 #include "buffer.h" 7 8 struct timespec; /* declaration */ 9 int log_clock_gettime_realtime (struct timespec *ts); 10 11 ssize_t write_all(int fd, const void* buf, size_t count); 12 13 __attribute_cold__ 14 int log_error_write(server *srv, const char *filename, unsigned int line, const char *fmt, ...); 15 16 __attribute_cold__ 17 int log_error_write_multiline_buffer(server *srv, const char *filename, unsigned int line, buffer *multiline, const char *fmt, ...); 18 19 struct log_error_st { 20 enum { ERRORLOG_FILE, ERRORLOG_FD, ERRORLOG_SYSLOG, ERRORLOG_PIPE } errorlog_mode; 21 int errorlog_fd; 22 buffer *b; 23 buffer *tb; 24 time_t *cur_ts; 25 time_t *last_ts; 26 }; 27 28 __attribute_cold__ 29 log_error_st * log_error_st_init (time_t *cur_ts_ptr, time_t *last_ts_ptr); 30 31 __attribute_cold__ 32 void log_error_st_free (log_error_st *errh); 33 34 __attribute_cold__ 35 __attribute_format__((__printf__, 4, 5)) 36 void log_error(const log_error_st *errh, const char *filename, unsigned int line, const char *fmt, ...); 37 38 __attribute_cold__ 39 __attribute_format__((__printf__, 4, 5)) 40 void log_perror(const log_error_st *errh, const char *filename, unsigned int line, const char *fmt, ...); 41 42 #endif 43