File: debug_syslog.c

package info (click to toggle)
cctools 9.9-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 44,624 kB
  • sloc: ansic: 192,539; python: 20,827; cpp: 20,199; sh: 11,719; perl: 4,106; xml: 3,688; makefile: 1,224
file content (38 lines) | stat: -rw-r--r-- 751 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
Copyright (C) 2014- The University of Notre Dame
This software is distributed under the GNU General Public License.
See the file COPYING for details.
*/

#ifdef HAS_SYSLOG_H

#include "debug.h"

#include <syslog.h>

#include <stdarg.h>

void debug_syslog_write (INT64_T flags, const char *str)
{
	int priority = LOG_USER;
	if (flags & D_FATAL) {
		priority |= LOG_NOTICE;
	} else if (flags & D_ERROR) {
		priority |= LOG_ERR;
	} else if (flags & D_NOTICE) {
		priority |= LOG_CRIT;
	} else if (flags & D_DEBUG) {
		priority |= LOG_DEBUG;
	} else {
		priority |= LOG_INFO;
	}
	syslog(priority, "%s", str);
}

void debug_syslog_config (const char *name)
{
	openlog(name, LOG_PID|LOG_NOWAIT, LOG_USER);
}
#endif

/* vim: set noexpandtab tabstop=4: */