]> mj.ucw.cz Git - libucw.git/commitdiff
Logging: Let log handlers return errno upon error.
authorMartin Mares <mj@ucw.cz>
Thu, 19 Feb 2009 16:57:03 +0000 (17:57 +0100)
committerMartin Mares <mj@ucw.cz>
Thu, 19 Feb 2009 16:57:03 +0000 (17:57 +0100)
ucw/log-file.c
ucw/log.h

index f04e68dc2aab4d03e3bd65d866c9fb638c07669a..645280819c660c54ae1e0ab4665fba17f9ce89f2 100644 (file)
@@ -20,6 +20,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <time.h>
+#include <errno.h>
 
 struct file_stream {
   struct log_stream ls;                // ls.name is the current name of the log file
@@ -111,8 +112,7 @@ file_handler(struct log_stream *ls, struct log_msg *m)
     do_log_switch(fs, m->tm);
 
   int r = write(fs->fd, m->m, m->m_len);
-  /* FIXME: check for errors here? */
-  return 0;
+  return ((r < 0) ? errno : 0);
 }
 
 struct log_stream *
index e08609b55332be8aa0ec3d5c181a7bfaf0b6169f..0b1edd9a6a6482ed0a35e99809c909cd59e5db2f 100644 (file)
--- a/ucw/log.h
+++ b/ucw/log.h
@@ -39,7 +39,7 @@ struct log_stream {
   uns use_count;                       // Number of references to the stream
   int (*filter)(struct log_stream* ls, struct log_msg *m);     // Filter function, return non-zero to discard the message
   clist substreams;                    // Pass the message to these streams (simple_list of pointers)
-  int (*handler)(struct log_stream *ls, struct log_msg *m);    // Called to commit the message
+  int (*handler)(struct log_stream *ls, struct log_msg *m);    // Called to commit the message, return 0 for success, errno on error
   void (*close)(struct log_stream* ls);        // Called upon log_close_stream()
   // Private data of the handler follow
 };