X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=inline;f=ucw%2Flog-file.c;h=40f1f3964e487e21e7d85834f194d3b3bdd67d39;hb=bc5f818d21b7aceaf2c0e263b00aa4295211d8f9;hp=efa0665f99bde467954390a085f267b6687e502c;hpb=b6acda64c6f8fdb461fc62a03b4030bfc7f1ae07;p=libucw.git diff --git a/ucw/log-file.c b/ucw/log-file.c index efa0665f..40f1f396 100644 --- a/ucw/log-file.c +++ b/ucw/log-file.c @@ -8,12 +8,12 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" -#include "ucw/log.h" -#include "ucw/log-internal.h" -#include "ucw/lfs.h" -#include "ucw/threads.h" -#include "ucw/simple-lists.h" +#include +#include +#include +#include +#include +#include #include #include @@ -25,7 +25,7 @@ struct file_stream { struct log_stream ls; // ls.name is the current name of the log file int fd; - uns flags; // FF_xxx + uint flags; // FF_xxx char *orig_name; // Original name with strftime escapes }; @@ -110,7 +110,7 @@ file_handler(struct log_stream *ls, struct log_msg *m) } struct log_stream * -log_new_fd(int fd, uns flags) +log_new_fd(int fd, uint flags) { struct log_stream *ls = log_new_stream(sizeof(struct file_stream)); struct file_stream *fs = (struct file_stream *) ls; @@ -125,15 +125,15 @@ log_new_fd(int fd, uns flags) } struct log_stream * -log_new_file(const char *path, uns flags) +log_new_file(const char *path, uint flags) { struct log_stream *ls = log_new_stream(sizeof(struct file_stream)); struct file_stream *fs = (struct file_stream *) ls; fs->fd = -1; + fs->flags = FF_CLOSE_FD | flags; fs->orig_name = xstrdup(path); if (strchr(path, '%')) - fs->flags = FF_FORMAT_NAME; - fs->flags |= FF_CLOSE_FD | flags; + fs->flags |= FF_FORMAT_NAME; ls->msgfmt = LSFMT_DEFAULT; ls->handler = file_handler; ls->close = file_close; @@ -178,11 +178,7 @@ log_file(const char *name) if (!name) return; - struct log_stream *ls = log_new_file(name, FF_FD2_FOLLOWS); - struct log_stream *def = log_stream_by_flags(0); - log_rm_substream(def, NULL); - log_add_substream(def, ls); - log_close_stream(ls); + log_set_default_stream(log_new_file(name, FF_FD2_FOLLOWS)); } #ifdef TEST