clsync
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
31extern 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
35extern 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
39extern void _warning ( const char *const function_name, const char *fmt, ... );
40#define warning(...) _warning(__func__, __VA_ARGS__)
41
42extern void _info ( const char *const function_name, const char *fmt, ... );
43#define info(...) _info(__func__, __VA_ARGS__)
44
45#ifdef _DEBUG_SUPPORT
46extern 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
63typedef enum ipc_type ipc_type_t;
64
65extern void error_init ( void *_outputmethod, int *_quiet, int *_verbose, int *_debug );
66extern void error_init_ipc ( ipc_type_t ipc_type );
67extern void error_deinit();
68
77
78#endif
79
enum ipc_type ipc_type_t
Definition error.h:63
outputmethod
Definition error.h:69
@ OM_STDOUT
Definition error.h:71
@ OM_STDERR
Definition error.h:70
@ OM_MAX
Definition error.h:74
@ OM_SYSLOG
Definition error.h:72
void _warning(const char *const function_name, const char *fmt,...)
Definition error.c:298
void error_init(void *_outputmethod, int *_quiet, int *_verbose, int *_debug)
Definition error.c:356
void error_deinit()
Definition error.c:389
void _info(const char *const function_name, const char *fmt,...)
Definition error.c:270
void error_init_ipc(ipc_type_t ipc_type)
Definition error.c:367
ipc_type
Definition error.h:59
@ IPCT_SHARED
Definition error.h:61
@ IPCT_PRIVATE
Definition error.h:60
void _critical(const char *const function_name, const char *fmt,...)
Definition error.c:184
void _error(const char *const function_name, const char *fmt,...)
Definition error.c:238
enum outputmethod outputmethod_t
Definition error.h:76