X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Flog.h;h=f6088bcb202401610f37bce3a66e446750186f43;hb=2a97a3c705846855ca3b12f408426314c72d37bd;hp=94dfa9c0fb902c8fb2cfaeabc1acb03bc10c5031;hpb=11686cd372e7306c8cba09bfa11d6e843ff9f9c1;p=libucw.git diff --git a/ucw/log.h b/ucw/log.h index 94dfa9c0..f6088bcb 100644 --- a/ucw/log.h +++ b/ucw/log.h @@ -11,7 +11,7 @@ #ifndef _UCW_LOG_H_ #define _UCW_LOG_H_ -#include "ucw/clists.h" +#include /*** === Messages and streams ***/ @@ -179,6 +179,17 @@ static inline struct log_stream *log_default_stream(void) return log_stream_by_flags(0); } +/** + * Make the specified stream the default destination. + * + * In fact, it takes the fixed default stream and attaches @ls as its only + * substream. If there were any other substreams, they are removed. + * + * Log streams created by log_file() or log_configured() are made default + * by calling this function. + **/ +void log_set_default_stream(struct log_stream *ls); + /** * Close all open streams, un-initialize the module, free all memory and * reset the logging mechanism to use stderr only. @@ -192,8 +203,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