diff options
author | Natanael Copa <natanael.copa@gmail.com> | 2008-12-18 21:12:55 +0100 |
---|---|---|
committer | Natanael Copa <natanael.copa@gmail.com> | 2008-12-18 21:12:55 +0100 |
commit | 5fa677e245b39735bce7243b3461723a26b16c3e (patch) | |
tree | c2f552303b5ef486fdc988d4a7bfa2bf125c811a /log.c | |
parent | d43306abc4cd63e2e2d471c17890394226a38c53 (diff) | |
download | pingu-5fa677e245b39735bce7243b3461723a26b16c3e.tar.bz2 pingu-5fa677e245b39735bce7243b3461723a26b16c3e.tar.xz |
log.c, log.h: new files
Diffstat (limited to 'log.c')
-rw-r--r-- | log.c | 60 |
1 files changed, 60 insertions, 0 deletions
@@ -0,0 +1,60 @@ +/* log.c - Logging via syslog + * copied from opennhrp + * + * Copyright (C) 2007 Timo Teräs <timo.teras@iki.fi> + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 or later as + * published by the Free Software Foundation. + * + * See http://www.gnu.org/ for details. + */ + +#include <errno.h> +#include <stdio.h> +#include <string.h> +#include <syslog.h> +#include <stdarg.h> + +#include "pingu.h" +#include "log.h" + +void log_init(void) +{ + openlog("pingu", LOG_PERROR | LOG_PID, LOG_DAEMON); +} + +void log_debug(const char *format, ...) +{ + va_list va; + + if (pingu_verbose) { + va_start(va, format); + vsyslog(LOG_DEBUG, format, va); + va_end(va); + } +} + +void log_perror(const char *message) +{ + log_error("%s: %s", message, strerror(errno)); +} + +void log_error(const char *format, ...) +{ + va_list va; + + va_start(va, format); + vsyslog(LOG_ERR, format, va); + va_end(va); +} + +void log_info(const char *format, ...) +{ + va_list va; + + va_start(va, format); + vsyslog(LOG_INFO, format, va); + va_end(va); +} |