File: log.h

package info (click to toggle)
moc 1%3A2.6.0~svn-r3005-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,656 kB
  • sloc: ansic: 31,749; sh: 929; cpp: 487; makefile: 240
file content (75 lines) | stat: -rw-r--r-- 1,454 bytes parent folder | download | duplicates (5)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef LOG_H
#define LOG_H

#include <stdio.h>

#ifdef __cplusplus
extern "C" {
#endif

/* Suppress overly-enthusiastic GNU variadic macro extensions warning. */
#if defined(__clang__) && HAVE_VARIADIC_MACRO_WARNING
# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#endif

#ifdef DEBUG
# define debug logit
#else
# define debug(...)  do {} while (0)
#endif

#ifndef NDEBUG
# define logit(...) \
	internal_logit (__FILE__, __LINE__, __func__, ## __VA_ARGS__)
#else
# define logit(...)  do {} while (0)
#endif

#ifndef STRERROR_FN
# define STRERROR_FN xstrerror
#endif

#ifndef NDEBUG
#define log_errno(format, errnum) \
	do { \
		char *err##__LINE__ = STRERROR_FN (errnum); \
		logit (format ": %s", err##__LINE__); \
		free (err##__LINE__); \
	} while (0)
#else
# define log_errno(...) do {} while (0)
#endif

void internal_logit (const char *file, const int line, const char *function,
		const char *format, ...) ATTR_PRINTF(4, 5);

#ifndef NDEBUG
# define LOGIT_ONLY
#else
# define LOGIT_ONLY ATTR_UNUSED
#endif

#if !defined(NDEBUG) && defined(DEBUG)
# define DEBUG_ONLY
#else
# define DEBUG_ONLY ATTR_UNUSED
#endif

void log_init_stream (FILE *f, const char *fn);
void log_circular_start ();
void log_circular_log ();
void log_circular_reset ();
void log_circular_stop ();
void log_close ();

#ifndef NDEBUG
void log_signal (int sig);
#else
# define log_signal(...) do {} while (0)
#endif

#ifdef __cplusplus
}
#endif

#endif