#include "ucw/lib.h"
#include "ucw/log.h"
+#include "ucw/log-internal.h"
#include "ucw/simple-lists.h"
#include <stdio.h>
.name = "stderr",
.use_count = 1000000,
.handler = default_log_handler,
- .levels = LS_ALL_LEVELS,
+ .levels = ~0U,
.msgfmt = LSFMT_DEFAULT,
// an empty clist
.substreams.head.next = (cnode *) &log_stream_default.substreams.head,
/* Check the stream existence */
if (!ls)
{
- msg((LS_INTERNAL_MASK&cat)|L_WARN, "No log_stream with number %d! Logging to the default log.", LS_GET_STRNUM(cat));
+ msg((LS_CTRL_MASK&cat)|L_WARN, "No log_stream with number %d! Logging to the default log.", LS_GET_STRNUM(cat));
ls = &log_stream_default;
}
/* Get the current time */
- if (!(cat & LSFLAG_SIGHANDLER))
+ if (!(cat & L_SIGHANDLER))
{
/* CAVEAT: These calls are not safe in signal handlers. */
gettimeofday(&tv, NULL);
if (depth > LS_MAX_DEPTH)
{
struct log_msg errm = *m;
- errm.flags = L_ERROR | (m->flags & LS_INTERNAL_MASK);
+ errm.flags = L_ERROR | (m->flags & LS_CTRL_MASK);
errm.raw_msg = "Loop in the log_stream system detected.";
log_pass_msg(0, &log_stream_default, &errm);
}
/* Process name, PID ( |log_title| + 6 + (|PID|<=10) chars ) */
if ((ls->msgfmt & LSFMT_TITLE) && log_title)
{
- if (ls->msgfmt & LSFMT_PID)
+ if ((ls->msgfmt & LSFMT_PID) && log_pid)
p += sprintf(p, "[%s (%d)] ", log_title, log_pid);
else
p += sprintf(p, "[%s] ", log_title);
int main(void)
{
- struct log_stream *ls = log_new_syslog(LOG_USER, "syslog");
+ struct log_stream *ls = log_new_syslog("local3", 0);
msg(L_INFO | ls->regnum, "Brum <%300s>", ":-)");
+ log_set_format(log_default_stream(), ~0U, LSFMT_USEC);
+ msg(L_INFO, "Brum <%300s>", ":-)");
+ log_close_all();
return 0;
}