libcoap  4.1.2
Macros | Functions | Variables
debug.c File Reference
#include "coap_config.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "block.h"
#include "debug.h"
#include "encode.h"
#include "net.h"
Include dependency graph for debug.c:

Go to the source code of this file.

Macros

#define min(a, b)   ((a) < (b) ? (a) : (b))
 

Functions

const char * coap_package_name (void)
 Returns a zero-terminated string with the name of this library. More...
 
const char * coap_package_version (void)
 Returns a zero-terminated string with the library version. More...
 
coap_log_t coap_get_log_level (void)
 Returns the current log level. More...
 
void coap_set_log_level (coap_log_t level)
 Sets the log level to the specified value. More...
 
static size_t print_timestamp (char *s, size_t len, coap_tick_t t)
 
static size_t strnlen (const char *s, size_t maxlen)
 A length-safe strlen() fake. More...
 
static unsigned int print_readable (const unsigned char *data, unsigned int len, unsigned char *result, unsigned int buflen, int encode_always)
 
size_t coap_print_addr (const struct coap_address_t *addr, unsigned char *buf, size_t len)
 
static const char * msg_type_string (uint8_t t)
 Returns a textual description of the message type t. More...
 
static const char * msg_code_string (uint8_t c)
 Returns a textual description of the method or response code. More...
 
static const char * msg_option_string (uint16_t option_type)
 Returns a textual description of the option name. More...
 
static unsigned int print_content_format (unsigned int format_type, unsigned char *result, unsigned int buflen)
 
static int is_binary (int content_format)
 Returns 1 if the given content_format is either unknown or known to carry binary data. More...
 
void coap_show_pdu (const coap_pdu_t *pdu)
 
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_WARNING). More...
 

Variables

static coap_log_t maxlog = LOG_WARNING
 
static char * loglevels []
 

Macro Definition Documentation

§ min

#define min (   a,
 
)    ((a) < (b) ? (a) : (b))

Definition at line 158 of file debug.c.

Function Documentation

§ coap_get_log_level()

coap_log_t coap_get_log_level ( void  )

Returns the current log level.

Definition at line 60 of file debug.c.

Here is the caller graph for this function:

§ 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_WARNING).

The text is output only when level is below or equal to the log level that set by coap_set_log_level().

Definition at line 483 of file debug.c.

Here is the call graph for this function:

§ coap_package_name()

const char* coap_package_name ( void  )

Returns a zero-terminated string with the name of this library.

Definition at line 51 of file debug.c.

§ coap_package_version()

const char* coap_package_version ( void  )

Returns a zero-terminated string with the library version.

Definition at line 55 of file debug.c.

§ coap_print_addr()

size_t coap_print_addr ( const struct coap_address_t addr,
unsigned char *  buf,
size_t  len 
)

Definition at line 162 of file debug.c.

Here is the call graph for this function:
Here is the caller graph for this function:

§ coap_set_log_level()

void coap_set_log_level ( coap_log_t  level)

Sets the log level to the specified value.

Definition at line 65 of file debug.c.

§ coap_show_pdu()

void coap_show_pdu ( const coap_pdu_t pdu)

Definition at line 375 of file debug.c.

Here is the call graph for this function:
Here is the caller graph for this function:

§ is_binary()

static int is_binary ( int  content_format)
inlinestatic

Returns 1 if the given content_format is either unknown or known to carry binary data.

The return value 0 hence indicates printable data which is also assumed if content_format is 01.

Definition at line 366 of file debug.c.

Here is the caller graph for this function:

§ msg_code_string()

static const char* msg_code_string ( uint8_t  c)
static

Returns a textual description of the method or response code.

Definition at line 272 of file debug.c.

Here is the caller graph for this function:

§ msg_option_string()

static const char* msg_option_string ( uint16_t  option_type)
static

Returns a textual description of the option name.

Definition at line 286 of file debug.c.

Here is the caller graph for this function:

§ msg_type_string()

static const char* msg_type_string ( uint8_t  t)
static

Returns a textual description of the message type t.

Definition at line 264 of file debug.c.

Here is the caller graph for this function:

§ print_content_format()

static unsigned int print_content_format ( unsigned int  format_type,
unsigned char *  result,
unsigned int  buflen 
)
static

Definition at line 330 of file debug.c.

Here is the caller graph for this function:

§ print_readable()

static unsigned int print_readable ( const unsigned char *  data,
unsigned int  len,
unsigned char *  result,
unsigned int  buflen,
int  encode_always 
)
static

Definition at line 121 of file debug.c.

Here is the caller graph for this function:

§ print_timestamp()

static size_t print_timestamp ( char *  s,
size_t  len,
coap_tick_t  t 
)
inlinestatic

Definition at line 87 of file debug.c.

Here is the call graph for this function:
Here is the caller graph for this function:

§ strnlen()

static size_t strnlen ( const char *  s,
size_t  maxlen 
)
inlinestatic

A length-safe strlen() fake.

Parameters
sThe string to count characters != 0.
maxlenThe maximum length of s.
Returns
The length of s.

Definition at line 112 of file debug.c.

Here is the caller graph for this function:

Variable Documentation

§ loglevels

char* loglevels[]
static
Initial value:
= {
"EMRG", "ALRT", "CRIT", "ERR", "WARN", "NOTE", "INFO", "DEBG"
}

Definition at line 70 of file debug.c.

§ maxlog

coap_log_t maxlog = LOG_WARNING
static

Definition at line 49 of file debug.c.