2003-08-13 05:53:07 +04:00
/*
Unix SMB / CIFS implementation .
Samba debug defines
Copyright ( C ) Andrew Tridgell 2003
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2003-08-13 05:53:07 +04:00
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2003-08-13 05:53:07 +04:00
*/
2006-03-06 03:24:51 +03:00
/**
* @ file
* @ brief Debugging macros
*/
2003-08-13 05:53:07 +04:00
/* the debug operations structure - contains function pointers to
various debug implementations of each operation */
struct debug_ops {
/* function to log (using DEBUG) suspicious usage of data structure */
void ( * log_suspicious_usage ) ( const char * from , const char * info ) ;
/* function to log (using printf) suspicious usage of data structure.
* To be used in circumstances when using DEBUG would cause loop . */
void ( * print_suspicious_usage ) ( const char * from , const char * info ) ;
/* function to return process/thread id */
2004-05-25 20:24:13 +04:00
uint32_t ( * get_task_id ) ( void ) ;
2003-12-04 12:52:14 +03:00
/* function to log process/thread id */
void ( * log_task_id ) ( int fd ) ;
2003-08-13 05:53:07 +04:00
} ;
extern int DEBUGLEVEL ;
# define DEBUGLVL(level) ((level) <= DEBUGLEVEL)
2006-01-09 21:25:06 +03:00
# define _DEBUG(level, body, header) do { \
if ( DEBUGLVL ( level ) ) { \
if ( header ) { \
2006-04-08 20:25:53 +04:00
do_debug_header ( level , __location__ , __FUNCTION__ ) ; \
2006-01-09 21:25:06 +03:00
} \
do_debug body ; \
} \
} while ( 0 )
2006-03-06 03:24:51 +03:00
/**
* Write to the debug log .
*/
2007-08-27 21:21:16 +04:00
# define DEBUG(level, body) _DEBUG(level, body, true)
2006-03-06 03:24:51 +03:00
/**
* Add data to an existing debug log entry .
*/
2007-08-27 21:21:16 +04:00
# define DEBUGADD(level, body) _DEBUG(level, body, false)
2006-03-06 03:24:51 +03:00
/**
* Obtain indentation string for the debug log .
*
* Level specified by n .
*/
2003-08-13 05:53:07 +04:00
# define DEBUGTAB(n) do_debug_tab(n)
2006-03-06 03:24:51 +03:00
/** Possible destinations for the debug log */
2005-06-13 12:12:39 +04:00
enum debug_logtype { DEBUG_STDOUT = 0 , DEBUG_FILE = 1 , DEBUG_STDERR = 2 } ;