X-Git-Url: http://git.archive.openwrt.org/?p=project%2Flibubox.git;a=blobdiff_plain;f=ulog.h;h=4818b1a8b5dfb8121352a4e625fc80e4ee662c22;hp=ce0cfb218c431b0b9cbeb61922b77e154ff2dd93;hb=6a75b3b6437d3c98d852c1bca131c8f81646f2f5;hpb=e82d74f89809c6c01f71168b3b8fdcf490e93fa7 diff --git a/ulog.h b/ulog.h index ce0cfb2..4818b1a 100644 --- a/ulog.h +++ b/ulog.h @@ -1,31 +1,42 @@ /* - * Copyright (C) 2010 John Crispin - * Copyright (C) 2010 Steven Barth + * ulog - simple logging functions * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Copyright (C) 2015 Jo-Philipp Wich * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + * 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 _ULOG_H__ -#define _ULOG_H__ +#ifndef __LIBUBOX_ULOG_H +#define __LIBUBOX_ULOG_H #include -#define LOG log_printf -#define log_start(name, daemon) \ - openlog(name, (LOG_PERROR | LOG_CONS), LOG_USER) -#define log_printf(...) syslog(LOG_NOTICE, __VA_ARGS__) +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