static void vMessage(uint32_t class, const char *message, va_list args)
{
-#define MESSAGE_BUFLEN 1023
- static char buff[MESSAGE_BUFLEN+1]={0,};
- size_t bp;
- char *nlp;
if (system_log) {
/* Messages go to the system log interface */
- bp=strlen(buff);
- assert(bp < MESSAGE_BUFLEN);
- vsnprintf(buff+bp,MESSAGE_BUFLEN-bp,message,args);
- buff[sizeof(buff)-2] = '\n';
- buff[sizeof(buff)-1] = '\0';
- /* Each line is sent separately */
- while ((nlp=strchr(buff,'\n'))) {
- *nlp=0;
- slilog(system_log,class,"%s",buff);
- memmove(buff,nlp+1,strlen(nlp+1)+1);
- }
+ vslilog_part(system_log, class, message, args);
} else {
vMessageFallback(class,message,args);
}
}
r=safe_malloc(sizeof(*r), "init_log");
r->st=l;
- r->logfn=log_multi;
r->vlogfn=log_vmulti;
+ r->buff[0]=0;
return r;
}
st->cl.apply=NULL;
st->cl.interface=&st->ops;
st->ops.st=st;
- st->ops.logfn=logfile_log;
st->ops.vlogfn=logfile_vlog;
+ st->ops.buff[0]=0;
st->loc=loc;
st->f=NULL;
st->cl.apply=NULL;
st->cl.interface=&st->ops;
st->ops.st=st;
- st->ops.logfn=syslog_log;
st->ops.vlogfn=syslog_vlog;
+ st->ops.buff[0]=0;
item=list_elem(args,0);
if (!item || item->type!=t_dict)
/* LOG interface */
+#define LOG_MESSAGE_BUFLEN 1023
+
typedef void log_msg_fn(void *st, int class, const char *message, ...);
typedef void log_vmsg_fn(void *st, int class, const char *message,
va_list args);
struct log_if {
void *st;
- log_msg_fn *logfn; /* Do not call these directly - you don't get */
log_vmsg_fn *vlogfn; /* printf format checking. Use [v]slilog instead */
+ char buff[LOG_MESSAGE_BUFLEN+1];
};
/* (convenience functions, defined in util.c) */
extern void slilog(struct log_if *lf, int class, const char *message, ...)
extern void vslilog(struct log_if *lf, int class, const char *message, va_list)
FORMAT(printf,3,0);
+/* Versions which take (parts of) (multiple) messages, using \n to
+ * distinguish one message from another. */
+extern void slilog_part(struct log_if *lf, int class, const char *message, ...)
+FORMAT(printf,3,4);
+extern void vslilog_part(struct log_if *lf, int class, const char *message,
+ va_list) FORMAT(printf,3,0);
+
/* SITE interface */
/* Pretty much a placeholder; allows starting and stopping of processing,
transform_max_start_pad +
comm_max_start_pad;
}
+
+void vslilog_part(struct log_if *lf, int priority, const char *message, va_list ap)
+{
+ char *buff=lf->buff;
+ size_t bp;
+ char *nlp;
+
+ bp=strlen(buff);
+ assert(bp < LOG_MESSAGE_BUFLEN);
+ vsnprintf(buff+bp,LOG_MESSAGE_BUFLEN-bp,message,ap);
+ buff[LOG_MESSAGE_BUFLEN-1] = '\n';
+ buff[LOG_MESSAGE_BUFLEN] = '\0';
+ /* Each line is sent separately */
+ while ((nlp=strchr(buff,'\n'))) {
+ *nlp=0;
+ slilog(lf,priority,"%s",buff);
+ memmove(buff,nlp+1,strlen(nlp+1)+1);
+ }
+}
+
+extern void slilog_part(struct log_if *lf, int priority, const char *message, ...)
+{
+ va_list ap;
+ va_start(ap,message);
+ vslilog_part(lf,priority,message,ap);
+ va_end(ap);
+}