Blame log.c

Packit Service 26469c
/*
Packit Service 26469c
 *  log.c - ACPI daemon logging
Packit Service 26469c
 *
Packit Service 26469c
 *  Portions Copyright (C) 2000 Andrew Henroid
Packit Service 26469c
 *  Portions Copyright (C) 2001 Sun Microsystems
Packit Service 26469c
 *  Portions Copyright (C) 2004 Tim Hockin (thockin@hockin.org)
Packit Service 26469c
 *
Packit Service 26469c
 *  This program is free software; you can redistribute it and/or modify
Packit Service 26469c
 *  it under the terms of the GNU General Public License as published by
Packit Service 26469c
 *  the Free Software Foundation; either version 2 of the License, or
Packit Service 26469c
 *  (at your option) any later version.
Packit Service 26469c
 *
Packit Service 26469c
 *  This program is distributed in the hope that it will be useful,
Packit Service 26469c
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 26469c
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 26469c
 *  GNU General Public License for more details.
Packit Service 26469c
 *
Packit Service 26469c
 *  You should have received a copy of the GNU General Public License
Packit Service 26469c
 *  along with this program; if not, write to the Free Software
Packit Service 26469c
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
Packit Service 26469c
 */
Packit Service 26469c
Packit Service 26469c
#include <stdio.h>
Packit Service 26469c
#include <syslog.h>
Packit Service 26469c
#include <stdarg.h>
Packit Service 26469c
Packit Service 26469c
#include "log.h"
Packit Service 26469c
Packit Service 26469c
int log_to_stderr = 0;
Packit Service 26469c
int debug_level = 0;
Packit Service 26469c
Packit Service 26469c
int
Packit Service 26469c
#ifdef __GNUC__
Packit Service 26469c
__attribute__((format(printf, 2, 3)))
Packit Service 26469c
#endif
Packit Service 26469c
acpid_log(int level, const char *fmt, ...)
Packit Service 26469c
{
Packit Service 26469c
	if (level == LOG_DEBUG && !debug_level) return 0;
Packit Service 26469c
	va_list args;
Packit Service 26469c
	va_start(args, fmt);
Packit Service 26469c
Packit Service 26469c
	if (log_to_stderr) {
Packit Service 26469c
		vfprintf(stderr, fmt, args);
Packit Service 26469c
		fprintf(stderr, "\n");
Packit Service 26469c
	} else {
Packit Service 26469c
		vsyslog(level, fmt, args);
Packit Service 26469c
	}
Packit Service 26469c
Packit Service 26469c
	va_end(args);
Packit Service 26469c
	return 0;
Packit Service 26469c
}