Files
Joachim Wiberg 1e508f9168 libink: trace connections, calls, and authorization decisions
The legacy socket logs a line per command under initctl debug; the bus
logged nothing, so the transport that now carries most of initctl was
the one you could not watch.

libink gets a logger hook rather than a dependency on Finit's: it
passes the emitting function and a formatted message, and dbus.c hands
both to logit() so the two sources read alike.  Trace points cover the
connection lifecycle, every inbound call, and why a call was refused.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2026-08-13 10:15:06 +02:00

41 lines
981 B
C

/* libink — optional debug tracing, routed to whoever embeds us.
*
* libink has no logger of its own by design: it must not depend on the
* host's logging, and PID 1 already has one. The embedder installs a
* callback and gets a line per connection, call, and authorization
* decision. Formatting happens before the callback, so an embedder
* that wants tracing off should uninstall rather than filter.
*
* Copyright (c) 2026 Joachim Wiberg <troglobit@gmail.com>
* SPDX-License-Identifier: MIT
*/
#include <stdarg.h>
#include <stdio.h>
#include "internal.h"
static link_log_cb_t logger;
static void *logger_userdata;
void link_set_logger(link_log_cb_t cb, void *userdata)
{
logger = cb;
logger_userdata = userdata;
}
void __log(const char *func, const char *fmt, ...)
{
char msg[256];
va_list ap;
if (!logger)
return;
va_start(ap, fmt);
vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
logger(logger_userdata, func, msg);
}