GCS
0.2.3
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
src
gu_log.h
1
// Copyright (C) 2007-2014 Codership Oy <info@codership.com>
2
9
#ifndef _gu_log_h_
10
#define _gu_log_h_
11
12
#include "gu_macros.h"
13
#include <stdlib.h>
/* For NULL */
14
15
#if defined(__cplusplus)
16
extern
"C"
17
{
18
#endif
19
34
typedef
enum
gu_log_severity
35
{
36
GU_LOG_FATAL,
37
GU_LOG_ERROR,
38
GU_LOG_WARN,
39
GU_LOG_INFO,
40
GU_LOG_DEBUG
41
}
42
gu_log_severity_t;
43
49
typedef
void (*gu_log_cb_t) (
int
severity,
const
char
* msg);
50
52
extern
int
53
gu_log (gu_log_severity_t severity,
54
const
char
* file,
55
const
char
*
function
,
56
const
int
line,
57
...);
58
62
extern
gu_log_severity_t gu_log_max_level;
63
64
#define gu_log_debug (GU_LOG_DEBUG == gu_log_max_level)
65
66
#if defined(__cplusplus)
67
}
68
#endif
69
70
#if !defined(__cplusplus) || defined(GALERA_LOG_H_ENABLE_CXX)
71
// NOTE: don't add "\n" here even if you really want to do it
72
#define GU_LOG_C(level, ...)\
73
gu_log(level, __FILE__, __PRETTY_FUNCTION__, __LINE__,\
74
__VA_ARGS__, NULL)
75
82
#define gu_fatal(...) GU_LOG_C(GU_LOG_FATAL, __VA_ARGS__, NULL)
83
#define gu_error(...) GU_LOG_C(GU_LOG_ERROR, __VA_ARGS__, NULL)
84
#define gu_warn(...) GU_LOG_C(GU_LOG_WARN, __VA_ARGS__, NULL)
85
#define gu_info(...) GU_LOG_C(GU_LOG_INFO, __VA_ARGS__, NULL)
86
#define gu_debug(...) if (gu_unlikely(gu_log_debug)) \
87
{ GU_LOG_C(GU_LOG_DEBUG, __VA_ARGS__, NULL); }
88
90
#endif
/* __cplusplus */
91
#endif
/* _gu_log_h_ */
92
93
#ifdef __GU_LOGGER__ // C++ logger should use the same stuff, so export it
94
#ifndef _gu_log_extra_
95
#define _gu_log_extra_
96
extern
"C"
97
{
98
extern
bool
gu_log_self_tstamp;
99
extern
gu_log_cb_t gu_log_cb;
100
extern
void
gu_log_cb_default (
int
,
const
char
*);
101
extern
const
char
* gu_log_level_str[];
102
}
103
#endif
/* _gu_log_extra_ */
104
#endif
/* __GU_LOGGER__ */
105
Generated on Tue Sep 16 2014 09:07:35 for GCS by
1.8.7