librsync
2.0.2
Main Page
Related Pages
Data Structures
Files
File List
Globals
src
trace.h
Go to the documentation of this file.
1
/*= -*- c-basic-offset: 4; indent-tabs-mode: nil; -*-
2
*
3
* librsync -- generate and apply network deltas
4
*
5
* Copyright (C) 2000, 2001, 2004 by Martin Pool <mbp@sourcefrog.net>
6
*
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU Lesser General Public License as published by
9
* the Free Software Foundation; either version 2.1 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU Lesser General Public License for more details.
16
*
17
* You should have received a copy of the GNU Lesser General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
*/
21
22
/** \file trace.h logging functions.
23
*
24
* trace may be turned off.
25
*
26
* error is always on, but you can return and continue in some way.
27
*
28
* fatal terminates the whole process.
29
*
30
* \todo A function like perror that includes strerror output. Apache does this
31
* by adding flags as well as the severity level which say whether such
32
* information should be included. */
33
34
#include <inttypes.h>
35
/* Printf format patters for standard librsync types. */
36
#define FMT_LONG "%"PRIdMAX
37
#define FMT_WEAKSUM "%08"PRIx32
38
/* Old MSVC compilers don't support "%zu" and have "%Iu" instead. */
39
#ifdef HAVE_PRINTF_Z
40
# define FMT_SIZE "%zu"
41
#else
42
# define FMT_SIZE "%Iu"
43
#endif
44
45
#if defined(__clang__) || defined(__GNUC__)
46
/** \todo Also look for the C9X predefined identifier `_function', or whatever
47
* it's called. */
48
49
void
rs_log0(
int
level,
char
const
*fn,
char
const
*fmt, ...)
50
__attribute__ ((format(printf, 3, 4)));
51
52
# ifdef DO_RS_TRACE
53
# define rs_trace(fmt, arg...) \
54
do { rs_log0(RS_LOG_DEBUG, __FUNCTION__, fmt , ##arg); \
55
} while (0)
56
# else
57
# define rs_trace(fmt, arg...)
58
# endif
/* !DO_RS_TRACE */
59
60
# define rs_log(l, s, str...) do { \
61
rs_log0((l), __FUNCTION__, (s) , ##str); \
62
} while (0)
63
64
# define rs_error(s, str...) do { \
65
rs_log0(RS_LOG_ERR, __FUNCTION__, (s) , ##str); \
66
} while (0)
67
68
# define rs_fatal(s, str...) do { \
69
rs_log0(RS_LOG_CRIT, __FUNCTION__, \
70
(s) , ##str); \
71
abort(); \
72
} while (0)
73
74
#else
/* !__GNUC__ */
75
# define rs_trace rs_trace0
76
# define rs_fatal rs_fatal0
77
# define rs_error rs_error0
78
# define rs_log rs_log0_nofn
79
#endif
/* !__GNUC__ */
80
81
void
rs_trace0(
char
const
*s, ...);
82
void
rs_fatal0(
char
const
*s, ...);
83
void
rs_error0(
char
const
*s, ...);
84
void
rs_log0(
int
level,
char
const
*fn,
char
const
*fmt, ...);
85
void
rs_log0_nofn(
int
level,
char
const
*fmt, ...);
86
87
enum
{
88
RS_LOG_PRIMASK
= 7,
/**< Mask to extract priority part. \internal */
89
90
RS_LOG_NONAME
= 8
/**< \b Don't show function name in message. */
91
};
92
93
/** \macro rs_trace_enabled()
94
*
95
* Call this before putting too much effort into generating trace messages. */
96
97
extern
int
rs_trace_level
;
98
99
#ifdef DO_RS_TRACE
100
# define rs_trace_enabled() ((rs_trace_level & RS_LOG_PRIMASK) >= RS_LOG_DEBUG)
101
#else
102
# define rs_trace_enabled() 0
103
#endif
rs_trace_level
int rs_trace_level
rs_trace_enabled()
Definition:
trace.c:56
RS_LOG_NONAME
Don't show function name in message.
Definition:
trace.h:90
RS_LOG_PRIMASK
Mask to extract priority part.
Definition:
trace.h:88
Generated on Sat Aug 17 2019 05:37:35 for librsync by
1.8.5