failures.h revision 7cecac4162776ac996a7cf3f4604bb5327d923d6
#ifndef FAILURES_H
#define FAILURES_H
struct ip_addr;
/* Default exit status codes that we could use. */
enum fatal_exit_status {
FATAL_DEFAULT = 89
};
enum log_type {
};
struct failure_line {
const char *text;
};
struct failure_context {
int exit_status; /* for LOG_TYPE_FATAL */
};
#define DEFAULT_FAILURE_STAMP_FORMAT "%b %d %H:%M:%S "
extern const char *failure_log_type_prefixes[];
extern const char *failure_log_type_names[];
/* Change failure handlers. */
#ifndef __cplusplus
#else
/* Older g++ doesn't like attributes in parameters */
#endif
/* Send failures to file. */
ATTR_FORMAT(2, 0);
/* Send failures to syslog() */
ATTR_FORMAT(2, 0);
/* Send failures to specified log file instead of stderr. */
/* Send errors to stderr using internal error protocol. */
void i_set_failure_internal(void);
/* If writing to log fails, ignore it instead of existing with
FATAL_LOGWRITE or FATAL_LOGERROR. */
void i_set_failure_ignore_errors(bool ignore);
/* Send informational messages to specified log file. i_set_failure_*()
functions modify the info file too, so call this function after them. */
void i_set_info_file(const char *path);
/* Send debug-level message to the given log file. The i_set_info_file()
function modifies also the debug log file, so call this function after it. */
void i_set_debug_file(const char *path);
/* Set the failure prefix. */
void i_set_failure_prefix(const char *prefix);
/* Prefix failures with a timestamp. fmt is in strftime() format. */
void i_set_failure_timestamp_format(const char *fmt);
/* When logging with internal error protocol, update the process's current
IP address / log prefix by sending it to log process. This is mainly used to
improve the error message if the process crashes. */
void i_set_failure_send_prefix(const char *prefix);
/* Call the callback before exit()ing. The callback may update the status. */
/* Call the exit callback and exit() */
/* Parse a line logged using internal failure handler */
void failures_deinit(void);
#endif