wireshark/epan/crypt/dot11decrypt_debug.h
Mikael Kanstrup e60b8d1eb1 dot11decrypt: Shorten the debug macros
The debug log macros are really long and require function name as
one parameter. This makes debug log lines either too wide or span
several lines of source code. Shorten the macro defines and make
use of G_STRFUNC to avoid manual function name entries in code.

NOTE: A bonus of removing all the manual function name entries is
that browsing/searching the code for function names is much easier.

Change-Id: Ia643f56df76e4a1b01ee6e6818cd61ec01047d33
Reviewed-on: https://code.wireshark.org/review/34927
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2019-11-03 17:20:46 +00:00

68 lines
1.7 KiB
C

/* airpcap_debug.h
*
* Copyright (c) 2006 CACE Technologies, Davis (California)
* All rights reserved.
*
* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only)
*/
#ifndef _DOT11DECRYPT_DEBUG_H
#define _DOT11DECRYPT_DEBUG_H
#include "dot11decrypt_interop.h"
/* #define DOT11DECRYPT_DEBUG 1 */
/* Debug level definition */
#define DEBUG_LEVEL_1 1
#define DEBUG_LEVEL_2 2
#define DEBUG_LEVEL_3 3
#define DEBUG_LEVEL_4 4
#define DEBUG_LEVEL_5 5
#define DEBUG_USED_LEVEL DEBUG_LEVEL_3
/******************************************************************************/
/* Debug section: internal function to print debug information */
/* */
#ifdef DOT11DECRYPT_DEBUG
#include <stdio.h>
#include <time.h>
#include <epan/to_str.h>
static inline void print_debug_line(const CHAR *function, const CHAR *msg, const INT level)
{
if (level <= DEBUG_USED_LEVEL)
g_warning("dbg(%d)|(%s) %s", level, function, msg);
}
#define DEBUG_PRINT_LINE(msg, level) print_debug_line(G_STRFUNC , msg, level)
#ifdef _TRACE
#define DEBUG_TRACE_START() print_debug_line(G_STRFUNC, "Start!", DEBUG_USED_LEVEL)
#define DEBUG_TRACE_END() print_debug_line(G_STRFUNC, "End!", DEBUG_USED_LEVEL)
#else
#define DEBUG_TRACE_START()
#define DEBUG_TRACE_END()
#endif
static inline void DEBUG_DUMP(const char* x, const guint8* y, int z)
{
char* tmp_str = bytes_to_str(NULL, y, (z));
g_warning("%s: %s", x, tmp_str);
wmem_free(NULL, tmp_str);
}
#else /* !defined DOT11DECRYPT_DEBUG */
#define DEBUG_TRACE_START()
#define DEBUG_TRACE_END()
#define DEBUG_PRINT_LINE(msg, level)
#define DEBUG_DUMP(x,y,z)
#endif /* ?defined DOT11DECRYPT_DEBUG */
#endif /* ?defined _DOT11DECRYPT_DEBUG_H */