]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
iostream-rawlog: Timestamp prefix is now optional.
authorTimo Sirainen <tss@iki.fi>
Fri, 22 Nov 2013 20:05:52 +0000 (22:05 +0200)
committerTimo Sirainen <tss@iki.fi>
Fri, 22 Nov 2013 20:05:52 +0000 (22:05 +0200)
src/lib/iostream-rawlog-private.h
src/lib/iostream-rawlog.c

index d73bf5d6d4889f760e55f284f52baa9b4ebb4fb1..12ec9581e71a24c60d2d31a5a8a4c34f3240fbbc 100644 (file)
@@ -5,7 +5,8 @@
 
 enum iostream_rawlog_flags {
        IOSTREAM_RAWLOG_FLAG_AUTOCLOSE  = 0x01,
-       IOSTREAM_RAWLOG_FLAG_BUFFERED   = 0x02
+       IOSTREAM_RAWLOG_FLAG_BUFFERED   = 0x02,
+       IOSTREAM_RAWLOG_FLAG_TIMESTAMP  = 0x04
 };
 
 struct rawlog_iostream {
index ce17df454c1e1f29c05a6d3360af2cffe44f1812..da2ab2dea40954085913a6a0671a3e4e5407d237 100644 (file)
@@ -41,6 +41,9 @@ rawlog_write_timestamp(struct rawlog_iostream *rstream, bool line_ends)
        unsigned char data[MAX_INT_STRLEN + 6 + 1 + 3];
        buffer_t buf;
 
+       if ((rstream->flags & IOSTREAM_RAWLOG_FLAG_TIMESTAMP) == 0)
+               return 0;
+
        buffer_create_from_data(&buf, data, sizeof(data));
        str_printfa(&buf, "%lu.%06u ",
                    (unsigned long)ioloop_timeval.tv_sec,
@@ -187,10 +190,13 @@ int iostream_rawlog_create_prefix(const char *prefix, struct istream **input,
 
        old_input = *input;
        old_output = *output;
+
        *input = i_stream_create_rawlog(old_input, in_path, in_fd,
-                                       IOSTREAM_RAWLOG_FLAG_AUTOCLOSE);
+                                       IOSTREAM_RAWLOG_FLAG_AUTOCLOSE |
+                                       IOSTREAM_RAWLOG_FLAG_TIMESTAMP);
        *output = o_stream_create_rawlog(old_output, out_path, out_fd,
-                                        IOSTREAM_RAWLOG_FLAG_AUTOCLOSE);
+                                        IOSTREAM_RAWLOG_FLAG_AUTOCLOSE |
+                                        IOSTREAM_RAWLOG_FLAG_TIMESTAMP);
        i_stream_unref(&old_input);
        o_stream_unref(&old_output);
        return 0;
@@ -212,10 +218,12 @@ int iostream_rawlog_create_path(const char *path, struct istream **input,
        old_input = *input;
        old_output = *output;
        *input = i_stream_create_rawlog(old_input, path, fd,
-                                       IOSTREAM_RAWLOG_FLAG_BUFFERED);
+                                       IOSTREAM_RAWLOG_FLAG_BUFFERED |
+                                       IOSTREAM_RAWLOG_FLAG_TIMESTAMP);
        *output = o_stream_create_rawlog(old_output, path, fd,
                                         IOSTREAM_RAWLOG_FLAG_AUTOCLOSE |
-                                        IOSTREAM_RAWLOG_FLAG_BUFFERED);
+                                        IOSTREAM_RAWLOG_FLAG_BUFFERED |
+                                        IOSTREAM_RAWLOG_FLAG_TIMESTAMP);
        i_stream_unref(&old_input);
        o_stream_unref(&old_output);
        return 0;