summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-08-05 15:59:27 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-08-05 15:59:27 +0300
commit7ac6f3b717c602175b3a7e8f53983f55ff0e1084 (patch)
tree30ea010fb2c74f03e655fd09fc8b42181342dabd /include
parent2672842e4f7e34b5ba0f0cd4eb149f22a0e56259 (diff)
downloadmailutils-7ac6f3b717c602175b3a7e8f53983f55ff0e1084.tar.gz
mailutils-7ac6f3b717c602175b3a7e8f53983f55ff0e1084.tar.bz2
logstream: introduce optional prefix.
The prefix, if set, is output at the beginning of each line, after the location and before the severity. It can be used to provide additional information about the diagnostics, such as, e.g. the number or UID of the message. The decodemail utility makes use of the new feature. * include/mailutils/log.h (MU_LOGMODE_PREFIX): New define. * include/mailutils/stream.h (MU_IOCTL_LOGSTREAM_SET_LOCUS_RANGE) (MU_IOCTL_LOGSTREAM_SET_PREFIX): New defines. * include/mailutils/sys/logstream.h (_mu_log_stream): New member: prefix. * libmailutils/stream/logstream.c (_log_write): Output the prefix. (_log_done): Dereference the prefix. (_log_ctl): Handle MU_IOCTL_LOGSTREAM_SET_LOCUS_RANGE and MU_IOCTL_LOGSTREAM_SET_PREFIX. * libmailutils/tests/logstr.c: New test: prefix. * libmailutils/tests/logstr.at: Test log prefix functionality. * decodemail/decodemail.c: Remove crd_error. Use logstream prefix to display message part locations.
Diffstat (limited to 'include')
-rw-r--r--include/mailutils/log.h3
-rw-r--r--include/mailutils/stream.h10
-rw-r--r--include/mailutils/sys/logstream.h1
3 files changed, 13 insertions, 1 deletions
diff --git a/include/mailutils/log.h b/include/mailutils/log.h
index d4957e361..0d83be66f 100644
--- a/include/mailutils/log.h
+++ b/include/mailutils/log.h
@@ -34,7 +34,8 @@ extern "C" {
#define MU_LOGMODE_SEVERITY 0x0001
#define MU_LOGMODE_LOCUS 0x0002
-
+#define MU_LOGMODE_PREFIX 0x0004
+
int mu_log_stream_create (mu_stream_t *, mu_stream_t);
int mu_syslog_stream_create (mu_stream_t *, int);
diff --git a/include/mailutils/stream.h b/include/mailutils/stream.h
index d58eef474..4843dc178 100644
--- a/include/mailutils/stream.h
+++ b/include/mailutils/stream.h
@@ -169,6 +169,16 @@ enum mu_buffer_type
Arg: struct mu_locus_range *
*/
#define MU_IOCTL_LOGSTREAM_SET_LOCUS_RANGE 16
+
+ /* Get prefix.
+ Arg: char **
+ */
+#define MU_IOCTL_LOGSTREAM_GET_PREFIX 17
+
+ /* Set prefix.
+ Arg: char *
+ */
+#define MU_IOCTL_LOGSTREAM_SET_PREFIX 18
/* Opcodes for MU_IOCTL_XSCRIPTSTREAM */
/* Swap transcript levels.
diff --git a/include/mailutils/sys/logstream.h b/include/mailutils/sys/logstream.h
index cb5b90101..34c4600a4 100644
--- a/include/mailutils/sys/logstream.h
+++ b/include/mailutils/sys/logstream.h
@@ -32,6 +32,7 @@ struct _mu_log_stream
int sevmask; /* Mask out the output of severity level for
these severities. */
struct mu_locus_range locrange; /* Location in the source file */
+ char const *prefix; /* Optinal prefix */
};
void _mu_log_stream_setup (struct _mu_log_stream *sp, mu_stream_t transport);

Return to:

Send suggestions and report system problems to the System administrator.