aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-03-22 18:21:07 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2011-03-22 18:21:07 +0200
commit4bd670e8dbcc9ee806d6bad1455149628fa61be0 (patch)
tree45d76b942d9234ca2a77cef79f542e7f5fff5743 /src/main.c
parent72878f64dde82a28fc9a30912fa25ab7bad93d1e (diff)
downloadmailfromd-4bd670e8dbcc9ee806d6bad1455149628fa61be0.tar.gz
mailfromd-4bd670e8dbcc9ee806d6bad1455149628fa61be0.tar.bz2
Use C-escape filter (MU b5c66e41) to format trace output.
* src/main.c (mf_trace_stream): New static var. (open_trace_stream): New static function. (trace): Print to mf_trace_stream.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 9b7a6b8c..d99183a9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -111,13 +111,36 @@ pp_define(const char *symbol)
111 111
112/* Logging & debugging */ 112/* Logging & debugging */
113 113
114static mu_stream_t mf_trace_stream;
115
116static void
117open_trace_stream()
118{
119 int rc = mu_filter_create(&mf_trace_stream,
120 mf_strecho,
121 "C-escape",
122 MU_FILTER_ENCODE,
123 MU_STREAM_WRITE);
124 if (rc) {
125 mu_error(_("cannot create trace stream, "
126 "using standard log: %s"),
127 mu_strerror(rc));
128 mf_trace_stream = mf_strecho;
129 }
130}
131
114void 132void
115trace(const char *fmt, ...) 133trace(const char *fmt, ...)
116{ 134{
117 if (do_trace) { 135 if (do_trace) {
118 va_list ap; 136 va_list ap;
137
138 if (!mf_trace_stream)
139 open_trace_stream();
140
119 va_start(ap, fmt); 141 va_start(ap, fmt);
120 vlogmsg(MU_LOG_INFO, fmt, ap); 142 mu_stream_vprintf(mf_trace_stream, fmt, ap);
143 mu_stream_flush(mf_trace_stream);
121 va_end(ap); 144 va_end(ap);
122 } 145 }
123} 146}

Return to:

Send suggestions and report system problems to the System administrator.