* UCW Library -- Logging: Management of Log Streams
*
* (c) 2008 Tomas Gavenciak <gavento@ucw.cz>
- * (c) 2009 Martin Mares <mj@ucw.cz>
+ * (c) 2009--2012 Martin Mares <mj@ucw.cz>
*
* This software may be freely distributed and used according to the terms
* of the GNU Lesser General Public License.
*/
-#include "ucw/lib.h"
-#include "ucw/log.h"
-#include "ucw/log-internal.h"
-#include "ucw/simple-lists.h"
+#include <ucw/lib.h>
+#include <ucw/log.h>
+#include <ucw/log-internal.h>
+#include <ucw/simple-lists.h>
#include <string.h>
log_set_format(i->p, mask, data);
}
+void
+log_set_default_stream(struct log_stream *ls)
+{
+ struct log_stream *def = log_stream_by_flags(0);
+ log_rm_substream(def, NULL);
+ log_add_substream(def, ls);
+ log_close_stream(ls);
+}
+
/*** Registry of type names ***/
int log_register_type(const char *name)
{
if (!log_type_names)
{
- log_type_names = xmalloc_zero(LS_GET_TYPE(~0U) * sizeof(char *));
+ log_type_names = xmalloc_zero(LS_NUM_TYPES * sizeof(char *));
log_type_names[0] = "default";
}
uns id;
- for (id=0; id < LS_GET_TYPE(~0U) && log_type_names[id]; id++)
+ for (id=0; id < LS_NUM_TYPES && log_type_names[id]; id++)
if (!strcmp(log_type_names[id], name))
return LS_SET_TYPE(id);
- ASSERT(id < LS_GET_TYPE(~0U));
+ ASSERT(id < LS_NUM_TYPES);
log_type_names[id] = xstrdup(name);
return LS_SET_TYPE(id);
}
if (!log_type_names)
return -1;
- for (uns id=0; id < LS_GET_TYPE(~0U) && log_type_names[id]; id++)
+ for (uns id=0; id < LS_NUM_TYPES && log_type_names[id]; id++)
if (!strcmp(log_type_names[id], name))
return LS_SET_TYPE(id);
return -1;