X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Flog.h;h=f2d99a0729d19e5ff79fdd06a26946743654d8d8;hb=c535433982fdbe2e0eae6ae850c3998e461ef5eb;hp=14134111ddf446b73fd498b1aed1d7a1fe81408a;hpb=53e1f544385cb04b518b64facd56a653c286a85b;p=libucw.git diff --git a/ucw/log.h b/ucw/log.h index 14134111..f2d99a07 100644 --- a/ucw/log.h +++ b/ucw/log.h @@ -44,6 +44,7 @@ struct log_stream { 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, return 0 for success, errno on error void (*close)(struct log_stream* ls); // Called upon log_close_stream() + void *user_data; // Not used by the logging system // Private data of the handler follow }; @@ -111,6 +112,8 @@ enum ls_flagmasks { // Bit masks of groups #define LS_SET_TYPE(type) ((type) << LS_TYPE_POS) /** Convert message type to flags **/ #define LS_SET_CTRL(ctrl) ((ctrl) << LS_CTRL_POS) /** Convert control bits to flags **/ +#define LS_NUM_TYPES (1 << LS_TYPE_BITS) + /** Register a new message type and return the corresponding flag set (encoded by `LS_SET_TYPE`). **/ int log_register_type(const char *name); @@ -189,8 +192,14 @@ void log_close_all(void); * even in multi-threaded programs. ***/ -struct log_stream *log_new_file(const char *path); /** Create a stream bound to a log file. **/ -struct log_stream *log_new_fd(int fd); /** Create a stream bound to a file descriptor. **/ +struct log_stream *log_new_file(const char *path, uns flags); /** Create a stream bound to a log file. See `FF_xxx` for @flags. **/ +struct log_stream *log_new_fd(int fd, uns flags); /** Create a stream bound to a file descriptor. See `FF_xxx` for @flags. **/ + +enum log_file_flag { /** Flags used for file-based logging **/ + FF_FORMAT_NAME = 1, // Internal: Name contains strftime escapes + FF_CLOSE_FD = 2, // Close the fd with the stream (use with log_new_fd()) + FF_FD2_FOLLOWS = 4, // Maintain stderr as a clone of this stream +}; /** * When a time-based name of the log file changes, the logger switches to a new