]>
git.ipfire.org Git - people/ms/mstpd.git/blob - log.h
1 /*****************************************************************************
2 Copyright (c) 2006 EMC Corporation.
3 Copyright (c) 2011 Factor-SPE
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2 of the License, or (at your option)
10 This program is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 59
17 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 The full GNU General Public License is included in this distribution in the
22 Authors: Srinivas Aji <Aji_Srinivas@emc.com>
23 Authors: Vitalii Demianets <vitas@nppfactor.kiev.ua>
25 ******************************************************************************/
33 #define LOG_LEVEL_NONE 0
34 #define LOG_LEVEL_ERROR 1
35 #define LOG_LEVEL_INFO 2
36 #define LOG_LEVEL_DEBUG 3
37 #define LOG_LEVEL_STATE_MACHINE_TRANSITION 4
38 #define LOG_LEVEL_MAX 100
40 #define LOG_LEVEL_DEFAULT LOG_LEVEL_INFO
42 extern void Dprintf(int level
, const char *fmt
, ...);
43 extern void vDprintf(int level
, const char *fmt
, va_list ap
);
46 #define PRINT(_level, _fmt, _args...) Dprintf(_level, _fmt, ##_args)
48 #define TSTM(x, y, _fmt, _args...) \
51 PRINT(LOG_LEVEL_ERROR, "Error in %s at %s:%d verifying %s. " _fmt, \
52 __PRETTY_FUNCTION__, __FILE__, __LINE__, #x, ##_args); \
56 #define TST(x, y) TSTM(x, y, "")
58 #define LOG(_fmt, _args...) \
59 PRINT(LOG_LEVEL_DEBUG, "%s: " _fmt, __PRETTY_FUNCTION__, ##_args)
61 #define INFO(_fmt, _args...) \
62 PRINT(LOG_LEVEL_INFO, "%s: " _fmt, __PRETTY_FUNCTION__, ##_args)
65 #define ERROR(_fmt, _args...) \
66 PRINT(LOG_LEVEL_ERROR, "%s: " _fmt, __PRETTY_FUNCTION__, ##_args)
69 #include "ctl_socket_server.h"
70 #define ERROR(_fmt, _args...) \
72 PRINT(LOG_LEVEL_ERROR, "error, %s: " _fmt, __PRETTY_FUNCTION__, \
74 ctl_err_log(_fmt "\n", ##_args); \
78 static inline void dump_hex(void *b
, int l
)
80 unsigned char *buf
= b
;
83 for (i
= 0; i
< l
; i
+= 16) {
84 for (j
= 0; j
< 16 && i
+ j
< l
; ++j
)
85 sprintf(logbuf
+ j
* 3, " %02x", buf
[i
+ j
]);
86 PRINT(LOG_LEVEL_INFO
, "%s", logbuf
);
88 PRINT(LOG_LEVEL_INFO
, "\n");