chiark / gitweb /
log: more general error message formatting
[disorder] / lib / log.h
index bacccb386292909daf92b6f73832f728f2f0ac84..31e6f5f0426716eedf31c49350d426954d219ca9 100644 (file)
--- a/lib/log.h
+++ b/lib/log.h
@@ -28,12 +28,31 @@ struct log_output;
 
 void set_progname(char **argv);
 
-void elog(int pri, int errno_value, const char *fmt, va_list ap);
+/** @brief Possible error number spaces */
+enum error_class {
+  /** @brief Invalid number space */
+  ec_none,
+
+  /** @brief @c errno number space */
+  ec_errno,
+
+  /** @brief getaddrinfo() return value */
+  ec_getaddrinfo,
+};
+
+# define ec_native ec_errno
+# define ec_socket ec_errno
+
+void elog(int pri, enum error_class, int errno_value, const char *fmt, va_list ap);
 
 void disorder_fatal(int errno_value, const char *msg, ...) attribute((noreturn))
   attribute((format (printf, 2, 3)));
+void disorder_fatal_ec(enum error_class ec, int errno_value, const char *msg, ...) attribute((noreturn))
+  attribute((format (printf, 3, 4)));
 void disorder_error(int errno_value, const char *msg, ...)
   attribute((format (printf, 2, 3)));
+void disorder_error_ec(enum error_class ec, int errno_value, const char *msg, ...)
+  attribute((format (printf, 3, 4)));
 void disorder_info(const char *msg, ...)
   attribute((format (printf, 1, 2)));
 void disorder_debug(const char *msg, ...)
@@ -41,6 +60,8 @@ void disorder_debug(const char *msg, ...)
 /* report a message of the given class.  @errno_value@ if present an
  * non-zero is included.  @fatal@ terminates the process. */
 
+const char *format_error(enum error_class ec, int err, char buffer[], size_t bufsize);
+
 extern int debugging;
 /* set when debugging enabled */