/* 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, or (at your option) any later version. 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. Derived from checkpassword-pam by Alexey Mahotkin 2002-2004 Modified and enhanced by Manuel Mausz 2017 */ #define _DEFAULT_SOURCE 1 #include #include #include #include "logging.h" extern int opt_debug; extern int opt_use_syslog; inline void log_init(const char *ident) { if (opt_use_syslog) openlog(ident, LOG_PID, LOG_AUTH); } inline void log_close() { closelog(); } void log_error(const char *format, ...) { va_list args; va_start(args, format); if (opt_use_syslog) (void)vsyslog(LOG_ERR, format, args); else { (void)vfprintf(stderr, format, args); (void)fputc('\n', stderr); } } void log_debug(const char *format, ...) { if (!opt_debug) return; va_list args; va_start(args, format); if (opt_use_syslog) (void)vsyslog(LOG_DEBUG, format, args); else { (void)vfprintf(stderr, format, args); (void)fputc('\n', stderr); } }