diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-03-22 18:21:07 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-03-22 18:21:07 +0200 |
commit | 4bd670e8dbcc9ee806d6bad1455149628fa61be0 (patch) | |
tree | 45d76b942d9234ca2a77cef79f542e7f5fff5743 | |
parent | 72878f64dde82a28fc9a30912fa25ab7bad93d1e (diff) | |
download | mailfromd-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.
-rw-r--r-- | src/main.c | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -108,19 +108,42 @@ pp_define(const char *symbol) add_pp_option("-D", symbol); } /* Logging & debugging */ +static mu_stream_t mf_trace_stream; + +static void +open_trace_stream() +{ + int rc = mu_filter_create(&mf_trace_stream, + mf_strecho, + "C-escape", + MU_FILTER_ENCODE, + MU_STREAM_WRITE); + if (rc) { + mu_error(_("cannot create trace stream, " + "using standard log: %s"), + mu_strerror(rc)); + mf_trace_stream = mf_strecho; + } +} + void trace(const char *fmt, ...) { if (do_trace) { va_list ap; + + if (!mf_trace_stream) + open_trace_stream(); + va_start(ap, fmt); - vlogmsg(MU_LOG_INFO, fmt, ap); + mu_stream_vprintf(mf_trace_stream, fmt, ap); + mu_stream_flush(mf_trace_stream); va_end(ap); } } void log_status(sfsistat status, SMFICTX *ctx) |