debug.h
Go to the documentation of this file.
/*
* debug.h -- debug utilities
*
* Copyright (C) 2010-2011,2014 Olaf Bergmann <bergmann@tzi.org>
*
* This file is part of the CoAP library libcoap. Please see README for terms
* of use.
*/
#ifndef _COAP_DEBUG_H_
#define _COAP_DEBUG_H_
#ifndef COAP_DEBUG_FD
#define COAP_DEBUG_FD stdout
#endif
#ifndef COAP_ERR_FD
#define COAP_ERR_FD stderr
#endif
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
typedef short coap_log_t;
#else
typedef enum {
LOG_EMERG=0,
LOG_ALERT,
LOG_CRIT,
LOG_ERR,
LOG_WARNING,
LOG_NOTICE,
LOG_INFO,
LOG_DEBUG
} coap_log_t;
#endif
coap_log_t coap_get_log_level(void);
void coap_set_log_level(coap_log_t level);
const char *coap_package_name(void);
const char *coap_package_version(void);
void coap_log_impl(coap_log_t level, const char *format, ...);
#ifndef coap_log
#define coap_log(...) coap_log_impl(__VA_ARGS__)
#endif
#ifndef NDEBUG
/* A set of convenience macros for common log levels. */
#define info(...) coap_log(LOG_INFO, __VA_ARGS__)
#define warn(...) coap_log(LOG_WARNING, __VA_ARGS__)
#define debug(...) coap_log(LOG_DEBUG, __VA_ARGS__)
#include "pdu.h"
void coap_show_pdu(const coap_pdu_t *);
struct coap_address_t;
size_t coap_print_addr(const struct coap_address_t *, unsigned char *, size_t);
#else
#define debug(...)
#define info(...)
#define warn(...)
#define coap_show_pdu(x)
#define coap_print_addr(...)
#endif /* NDEBUG */
#endif /* _COAP_DEBUG_H_ */
LOG_WARNING
Definition: debug.h:31
LOG_INFO
Definition: debug.h:33
LOG_ALERT
Definition: debug.h:28
coap_get_log_level
coap_log_t coap_get_log_level(void)
Returns the current log level.
Definition: debug.c:60
coap_address_t
multi-purpose address abstraction
Definition: address.h:59
LOG_EMERG
Definition: debug.h:27
coap_show_pdu
void coap_show_pdu(const coap_pdu_t *)
Definition: debug.c:375
coap_log_impl
void coap_log_impl(coap_log_t level, const char *format,...)
Writes the given text to COAP_ERR_FD (for level <= LOG_CRIT) or COAP_DEBUG_FD (for level >= LOG_WARNI...
Definition: debug.c:483
LOG_DEBUG
Definition: debug.h:34
coap_set_log_level
void coap_set_log_level(coap_log_t level)
Sets the log level to the specified value.
Definition: debug.c:65
coap_pdu_t
Header structure for CoAP PDUs.
Definition: pdu.h:227
coap_log_t
coap_log_t
Pre-defined log levels akin to what is used in syslog.
Definition: debug.h:26
coap_package_name
const char * coap_package_name(void)
Returns a zero-terminated string with the name of this library.
Definition: debug.c:51
LOG_CRIT
Definition: debug.h:29
pdu.h
Pre-defined constants that reflect defaults for CoAP.
LOG_ERR
Definition: debug.h:30
coap_package_version
const char * coap_package_version(void)
Returns a zero-terminated string with the library version.
Definition: debug.c:55
LOG_NOTICE
Definition: debug.h:32
coap_print_addr
size_t coap_print_addr(const struct coap_address_t *, unsigned char *, size_t)
Definition: debug.c:162