clsync
Toggle main menu visibility
Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
1
/*
2
clsync - file tree sync utility based on inotify/kqueue
3
4
Copyright (C) 2013-2014 Dmitry Yu Okunev <dyokunev@ut.mephi.ru> 0x8E30679C
5
6
This program is free software: you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#ifndef __CLSYNC_ERROR_H
21
#define __CLSYNC_ERROR_H
22
23
#define BACKTRACE_LENGTH 256
24
25
#ifdef _DEBUG_FORCE
26
# define DEBUGLEVEL_LIMIT 255
27
#else
28
# define DEBUGLEVEL_LIMIT 9
29
#endif
30
31
extern
void
_critical
(
const
char
*
const
function_name,
const
char
*fmt, ... );
32
#define critical(...) _critical(__func__, __VA_ARGS__)
33
#define critical_on(cond) {debug(30, "critical_on: checking: %s", TOSTR(cond)); if (unlikely(cond)) {critical("Assert: "TOSTR(cond));}}
34
35
extern
void
_error
(
const
char
*
const
function_name,
const
char
*fmt, ... );
36
#define error(...) _error(__func__, __VA_ARGS__)
37
#define error_on(cond) {if (unlikely(cond)) {error("Error: ("TOSTR(cond)") != 0");}}
38
39
extern
void
_warning
(
const
char
*
const
function_name,
const
char
*fmt, ... );
40
#define warning(...) _warning(__func__, __VA_ARGS__)
41
42
extern
void
_info
(
const
char
*
const
function_name,
const
char
*fmt, ... );
43
#define info(...) _info(__func__, __VA_ARGS__)
44
45
#ifdef _DEBUG_SUPPORT
46
extern
void
_debug (
int
debug_level,
const
char
*
const
function_name,
const
char
*fmt, ... );
47
# define debug(debug_level, ...) {if (debug_level < DEBUGLEVEL_LIMIT) _debug(debug_level, __func__, __VA_ARGS__);}
48
# define error_or_debug(debug_level, ...) ((debug_level)<0 ? _error(__func__, __VA_ARGS__) : _debug(debug_level, __func__, __VA_ARGS__))
49
#else
50
# define debug(debug_level, ...) {}
51
# define error_or_debug(debug_level, ...) ((debug_level)<0 ? _error(__func__, __VA_ARGS__) : (void)0)
52
53
#endif
54
55
#define debug_call(debug_level, code) debug(debug_level, "%s -> %i", TOSTR(code), code)
56
57
#define critical_or_warning(cond, ...) ((cond) ? _critical : _warning)(__func__, __VA_ARGS__)
58
59
enum
ipc_type
{
60
IPCT_PRIVATE
,
61
IPCT_SHARED
,
62
};
63
typedef
enum
ipc_type
ipc_type_t
;
64
65
extern
void
error_init
(
void
*_outputmethod,
int
*_quiet,
int
*_verbose,
int
*_debug );
66
extern
void
error_init_ipc
(
ipc_type_t
ipc_type
);
67
extern
void
error_deinit
();
68
69
enum
outputmethod
{
70
OM_STDERR
= 0,
71
OM_STDOUT
,
72
OM_SYSLOG
,
73
74
OM_MAX
75
};
76
typedef
enum
outputmethod
outputmethod_t
;
77
78
#endif
79
ipc_type_t
enum ipc_type ipc_type_t
Definition
error.h:63
outputmethod
outputmethod
Definition
error.h:69
OM_STDOUT
@ OM_STDOUT
Definition
error.h:71
OM_STDERR
@ OM_STDERR
Definition
error.h:70
OM_MAX
@ OM_MAX
Definition
error.h:74
OM_SYSLOG
@ OM_SYSLOG
Definition
error.h:72
_warning
void _warning(const char *const function_name, const char *fmt,...)
Definition
error.c:298
error_init
void error_init(void *_outputmethod, int *_quiet, int *_verbose, int *_debug)
Definition
error.c:356
error_deinit
void error_deinit()
Definition
error.c:389
_info
void _info(const char *const function_name, const char *fmt,...)
Definition
error.c:270
error_init_ipc
void error_init_ipc(ipc_type_t ipc_type)
Definition
error.c:367
ipc_type
ipc_type
Definition
error.h:59
IPCT_SHARED
@ IPCT_SHARED
Definition
error.h:61
IPCT_PRIVATE
@ IPCT_PRIVATE
Definition
error.h:60
_critical
void _critical(const char *const function_name, const char *fmt,...)
Definition
error.c:184
_error
void _error(const char *const function_name, const char *fmt,...)
Definition
error.c:238
outputmethod_t
enum outputmethod outputmethod_t
Definition
error.h:76
Generated on
for clsync by
1.17.0