summaryrefslogtreecommitdiff
path: root/src/usyslog.h
blob: 5b127a90cb24ac178a1245db681bde0773b02fdd (plain)
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
/*
 * License: BSD-style license
 * Copyright: Bernd Schubert <bernd.schubert@fastmail.fm>
 */

#include <syslog.h>
#include <stdbool.h>

#define MAX_SYSLOG_MESSAGES 32	// max number of buffered syslog messages
#define MAX_MSG_SIZE 256	// max string length for syslog messages

/* chained buffer list of syslog entries  */
typedef struct ulogs {
	int priority; // first argument for syslog()
	char message[MAX_MSG_SIZE]; // 2nd argument for syslog() 
	bool used;		// is this entry used?
	pthread_mutex_t lock;	// lock a single entry
	struct ulogs *next;	// pointer to the next entry
} ulogs_t;


void init_syslog(void);
void usyslog(int priority, const char *format, ...);


#define USYSLOG(priority, format, ...)  			\
	do {							\
		DBG(format, ##__VA_ARGS__);			\
		usyslog(priority, format, ##__VA_ARGS__);	\
	} while (0);