diff options
author | Gergely Nagy <algernon@balabit.hu> | 2012-03-24 11:17:03 +0100 |
---|---|---|
committer | Gergely Nagy <algernon@balabit.hu> | 2012-03-24 11:17:03 +0100 |
commit | 21e8d846ed040a1bf55987036578807d5826d958 (patch) | |
tree | 6a80df2b442bb63059ff874fe9dd9f3ff1b7ec8f /lib/umberlog.rst | |
parent | d5dd310da5fdad1690827293ae7f4260ec9ed971 (diff) | |
download | libumberlog-21e8d846ed040a1bf55987036578807d5826d958.tar.gz libumberlog-21e8d846ed040a1bf55987036578807d5826d958.tar.xz libumberlog-21e8d846ed040a1bf55987036578807d5826d958.zip |
Implement proper error handling.
Instead of calling abort() if vasprintf() fails, and ignoring possible
errors from the JSON library, do handle errors reasonably sanely:
check return values, and return an error state from all functions, and
propagate it up to the application level, too.
This means that the legacy overrides will silently fail, but set errno
appropriately in case serializing to JSON fails, and do what the
system libc does with syslog otherwise.
The new functions can return NULL or non-zero on error, which the
application can then handle as it sees fit.
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Diffstat (limited to 'lib/umberlog.rst')
-rw-r--r-- | lib/umberlog.rst | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/umberlog.rst b/lib/umberlog.rst index 515a6cc..26204e2 100644 --- a/lib/umberlog.rst +++ b/lib/umberlog.rst @@ -20,8 +20,8 @@ SYNOPSIS void ul_openlog (const char *ident, int option, int facility); - void ul_syslog (int priority, const char *format, ....); - void ul_vsyslog (int priority, const char *format, va_list ap); + int ul_syslog (int priority, const char *format, ....); + int ul_vsyslog (int priority, const char *format, va_list ap); void ul_legacy_syslog (int priority, const char *format, ...); void ul_legacy_vsyslog (int priority, const char *format, va_list ap); @@ -57,6 +57,15 @@ will be added to the generated message. variants above, except the formatted payload is not sent to syslog, but returned as a newly allocated string. +RETURN VALUE +============ + +When successful, **ul_syslog()** and **ul_vsyslog()** return zero, +while **ul_format()** and **ul_vformat()** return a character string. + +On failure the former two will return non-zero, the latter two +**NULL**, and set *errno* appropriately. + CEE PAYLOAD =========== @@ -122,11 +131,11 @@ EXAMPLES :: - ul_syslog(LOG_NOTICE, "Logged in user: %s", username, - "service", "%s", service, - "auth-method", "%s", auth_method, - "sessionid", "%d", session_id, - NULL); + status = ul_syslog(LOG_NOTICE, "Logged in user: %s", username, + "service", "%s", service, + "auth-method", "%s", auth_method, + "sessionid", "%d", session_id, + NULL); SEE ALSO ======== |