3 * @author David Llewellyn-Jones
11 * @section DESCRIPTION
24 #include "contrac/log.h"
30 // Function prototypes
33 * Log a string to syslog.
35 * In generl, the LOG macro should be used instead.
37 * Constructs a message using the supplied format and parameters and records it
38 * in the system log. The format is the same as for printf.
40 * The logging levels are the standard syslog levels:
42 * LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERR, etc.
44 * @param priority The log level priority.
45 * @param format The format for the message, the same as for printf.
46 * @param ... parameters to combine with the format to create the message.
48 void log_priority(int priority
, const char *format
, ...) {
53 va_start(args
, format
);
54 length
= vsnprintf(NULL
, 0, format
, args
);
57 buffer
= malloc(sizeof(char) * (length
+ 1));
59 va_start(args
, format
);
60 length
= vsnprintf(buffer
, length
+ 1, format
, args
);
64 syslog(priority
, "%s", buffer
);
67 // Function definitions