diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2015-02-25 22:42:03 +0300 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2015-02-26 12:43:56 +0300 |
commit | ca6d5472056ceee4b8ab320167e0ae8155a95985 (patch) | |
tree | c03607ff592c76a051abfad6d65f6c1093c9ae57 /ulog.h | |
parent | 827ad8337e88ec9e0bf73a8af1d6cf8555e8ef3d (diff) |
ulog: introduce new simple logging api
The ulog api is intended to be used by procd, fstools, ubox etc. to provide
a generic logging api for early boot messages and automatic switching between
syslog / kmsg / stdout depending on the way the process is executed.
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'ulog.h')
-rw-r--r-- | ulog.h | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -0,0 +1,42 @@ +/* + * ulog - simple logging functions + * + * Copyright (C) 2015 Jo-Philipp Wich <jow@openwrt.org> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef __LIBUBOX_ULOG_H +#define __LIBUBOX_ULOG_H + +#include <syslog.h> + +enum { + ULOG_KMSG = (1 << 0), + ULOG_SYSLOG = (1 << 1), + ULOG_STDIO = (1 << 2) +}; + +void ulog_open(int channels, int facility, const char *ident); +void ulog_close(void); + +void ulog_threshold(int threshold); + +void ulog(int priority, const char *fmt, ...); + +#define ULOG_INFO(fmt, ...) ulog(LOG_INFO, fmt, ## __VA_ARGS__) +#define ULOG_NOTE(fmt, ...) ulog(LOG_NOTICE, fmt, ## __VA_ARGS__) +#define ULOG_WARN(fmt, ...) ulog(LOG_WARNING, fmt, ## __VA_ARGS__) +#define ULOG_ERR(fmt, ...) ulog(LOG_ERR, fmt, ## __VA_ARGS__) + +#endif |