# HG changeset patch # User Olaf Wintermann # Date 1689791949 -7200 # Node ID a0e02b70dad18d19f62c572644708a43bf30f567 # Parent bf53db813cc9967ad1825270591958cc035c89e4 add log_printf function diff -r bf53db813cc9 -r a0e02b70dad1 dav/sync.c --- a/dav/sync.c Wed Jul 19 20:31:01 2023 +0200 +++ b/dav/sync.c Wed Jul 19 20:39:09 2023 +0200 @@ -70,6 +70,8 @@ static int sync_shutdown = 0; +static FILE *synclog; + static void xmlerrorfnc(void * c, const char * msg, ... ) { va_list ap; va_start(ap, msg); @@ -89,6 +91,24 @@ }; static size_t numdefprops = 8 ; +void log_printf(const char *loglevel, const char *fmt, ...) { + const char *sp = " "; + if(!loglevel) { + loglevel = ""; + sp = ""; + } + + va_list ap; + va_start(ap, fmt); + cxmutstr str = cx_vasprintf(fmt, ap); + va_end(ap); + + printf("%s\n", str.ptr); + if(synclog) { + fprintf(synclog, "%s%s%s\n", loglevel, sp, str.ptr); + } +} + /* * strcmp version that works with NULL pointers */ diff -r bf53db813cc9 -r a0e02b70dad1 dav/sync.h --- a/dav/sync.h Wed Jul 19 20:31:01 2023 +0200 +++ b/dav/sync.h Wed Jul 19 20:39:09 2023 +0200 @@ -105,6 +105,8 @@ int cmd_push(CmdArgs *args, DavBool outgoing, DavBool archive); int cmd_restore(CmdArgs *args); +void log_printf(const char *loglevel, const char *fmt, ...); + void print_outgoing( CmdArgs *args, CxList *ls_new,