40#define MY_NAME "librsync"
42static void rs_log_va(
int level,
char const *fn,
char const *fmt, va_list va);
45static const char *rs_severities[] = {
46 "EMERGENCY! ",
"ALERT! ",
"CRITICAL! ",
"ERROR: ",
"Warning: ",
59 rs_trace_impl = new_impl;
64 rs_trace_level = level;
67static void rs_log_va(
int flags,
char const *fn,
char const *fmt, va_list va)
71 if (rs_trace_impl && level <= rs_trace_level) {
75 vsnprintf(buf,
sizeof(buf), fmt, va);
77 snprintf(full_buf,
sizeof(full_buf),
"%s: %s%s\n", MY_NAME,
78 rs_severities[level], buf);
80 snprintf(full_buf,
sizeof(full_buf),
"%s: %s(%s) %s\n", MY_NAME,
81 rs_severities[level], fn, buf);
83 rs_trace_impl(level, full_buf);
88void rs_log0(
int level,
char const *fn,
char const *fmt, ...)
93 rs_log_va(level, fn, fmt, va);
Public header for librsync.
LIBRSYNC_EXPORT void rs_trace_to(rs_trace_fn_t *)
Set trace callback.
LIBRSYNC_EXPORT int rs_supports_trace(void)
Check whether the library was compiled with debugging trace.
LIBRSYNC_EXPORT void rs_trace_stderr(rs_loglevel level, char const *msg)
Default trace callback that writes to stderr.
void rs_trace_fn_t(rs_loglevel level, char const *msg)
Callback to write out log messages.
rs_loglevel
Log severity levels.
@ RS_LOG_INFO
Informational.
LIBRSYNC_EXPORT void rs_trace_set_level(rs_loglevel level)
Set the least important message severity that will be output.
@ RS_LOG_PRIMASK
Mask to extract priority part.
@ RS_LOG_NONAME
Don't show function name in message.
Misc utility functions used by librsync.