|
Packit |
00408a |
/*
|
|
Packit |
00408a |
* debug.h -- debugging routines for libtirpc
|
|
Packit |
00408a |
*
|
|
Packit |
00408a |
* Copyright (C) 2014 Red Hat, Steve Dickson <steved@redhat.com>
|
|
Packit |
00408a |
*
|
|
Packit |
00408a |
* Redistribution and use in source and binary forms, with or without
|
|
Packit |
00408a |
* modification, are permitted provided that the following conditions are met:
|
|
Packit |
00408a |
* - Redistributions of source code must retain the above copyright notice,
|
|
Packit |
00408a |
* this list of conditions and the following disclaimer.
|
|
Packit |
00408a |
* - Redistributions in binary form must reproduce the above copyright notice,
|
|
Packit |
00408a |
* this list of conditions and the following disclaimer in the documentation
|
|
Packit |
00408a |
* and/or other materials provided with the distribution.
|
|
Packit |
00408a |
* - Neither the name of Sun Microsystems, Inc. nor the names of its
|
|
Packit |
00408a |
* contributors may be used to endorse or promote products derived
|
|
Packit |
00408a |
* from this software without specific prior written permission.
|
|
Packit |
00408a |
*
|
|
Packit |
00408a |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit |
00408a |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
00408a |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
Packit |
00408a |
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
Packit |
00408a |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
Packit |
00408a |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
Packit |
00408a |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
Packit |
00408a |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
Packit |
00408a |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
Packit |
00408a |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
Packit |
00408a |
* POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
00408a |
*/
|
|
Packit |
00408a |
|
|
Packit |
00408a |
#ifndef _DEBUG_H
|
|
Packit |
00408a |
#define _DEBUG_H
|
|
Packit |
00408a |
|
|
Packit |
00408a |
#include <stdarg.h>
|
|
Packit |
00408a |
#include <syslog.h>
|
|
Packit |
00408a |
|
|
Packit |
00408a |
extern int libtirpc_debug_level;
|
|
Packit |
00408a |
extern int log_stderr;
|
|
Packit |
00408a |
|
|
Packit |
00408a |
void libtirpc_log_dbg(char *format, ...);
|
|
Packit |
00408a |
void libtirpc_set_debug(char *name, int level, int use_stderr);
|
|
Packit |
00408a |
|
|
Packit |
00408a |
#define LIBTIRPC_DEBUG(level, msg) \
|
|
Packit |
00408a |
do { \
|
|
Packit |
00408a |
if (level <= libtirpc_debug_level) \
|
|
Packit |
00408a |
libtirpc_log_dbg msg; \
|
|
Packit |
00408a |
} while (0)
|
|
Packit |
00408a |
|
|
Packit |
00408a |
static inline void
|
|
Packit |
00408a |
vlibtirpc_log_dbg(int level, const char *fmt, va_list args)
|
|
Packit |
00408a |
{
|
|
Packit |
00408a |
if (level <= libtirpc_debug_level) {
|
|
Packit |
00408a |
if (log_stderr) {
|
|
Packit |
00408a |
vfprintf(stderr, fmt, args);
|
|
Packit |
00408a |
fprintf(stderr, "\n");
|
|
Packit |
00408a |
} else
|
|
Packit |
00408a |
vsyslog(LOG_NOTICE, fmt, args);
|
|
Packit |
00408a |
}
|
|
Packit |
00408a |
}
|
|
Packit |
00408a |
#endif /* _DEBUG_H */
|