Asterisk - The Open Source Telephony Project  18.5.0
Macros | Functions
logger_category.h File Reference
#include "asterisk/logger.h"
Include dependency graph for logger_category.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ast_debug_category(sublevel, ids, ...)
 Log for a debug category. More...
 
#define AST_LOG_CATEGORY_DISABLED   0
 
#define AST_LOG_CATEGORY_ENABLED   -1
 

Functions

char * ast_debug_category_complete (const char *const *argv, int argc, const char *word, int state)
 Add a unique (no duplicates) result to a request for completion for debug categories. More...
 
int ast_debug_category_is_allowed (int sublevel, uintmax_t ids)
 Check if a debug category is enabled, and allowed to output. More...
 
uintmax_t ast_debug_category_register (const char *name)
 Register a debug level logger category. More...
 
int ast_debug_category_set_sublevel (const char *name, int sublevel)
 Set the debug category's sublevel. More...
 
int ast_debug_category_set_sublevels (const char *const *names, size_t size, int default_sublevel)
 Set one or more debug category's sublevel. More...
 
int ast_debug_category_unregister (const char *name)
 Un-register a debug level logger category. More...
 
int ast_logger_category_load (void)
 Load/Initialize system wide logger category functionality. More...
 
int ast_logger_category_unload (void)
 Unload system wide logger category functionality. More...
 

Macro Definition Documentation

◆ ast_debug_category

#define ast_debug_category (   sublevel,
  ids,
  ... 
)
Value:
do { \
ast_log(AST_LOG_DEBUG, __VA_ARGS__); \
} \
} while (0)
int ast_debug_category_is_allowed(int sublevel, uintmax_t ids)
Check if a debug category is enabled, and allowed to output.
#define AST_LOG_DEBUG
Definition: logger.h:246
#define DEBUG_ATLEAST(level)
Definition: logger.h:441

Log for a debug category.

This will output log data for debug under the following conditions:

  1. The specified sublevel is at, or below the current system debug level
  2. At least one of the given category ids is enabled AND a. The category sublevel is enabled OR the given sublevel is at, or below a category's specified sublevel.
Parameters
sublevelThe minimum level to output at
idsOne or more unique category ids to output for
Since
16.14
17.8
18.0

Definition at line 171 of file logger_category.h.

Referenced by ast_rtp_ice_start_media(), and rtp_add_candidates_to_ice().

◆ AST_LOG_CATEGORY_DISABLED

#define AST_LOG_CATEGORY_DISABLED   0

◆ AST_LOG_CATEGORY_ENABLED

#define AST_LOG_CATEGORY_ENABLED   -1

Function Documentation

◆ ast_debug_category_complete()

char* ast_debug_category_complete ( const char *const *  argv,
int  argc,
const char *  word,
int  state 
)

Add a unique (no duplicates) result to a request for completion for debug categories.

Parameters
argvA list of already completed options
argcThe number of already completed options
wordThe word to complete
stateThe state
Return values
0Success, -1 Failure
Since
16.14
17.8
18.0

Definition at line 300 of file logger_category.c.

References category_complete().

Referenced by handle_debug_category().

302 {
303  return category_complete(&debug_categories, argv, argc, word, state);
304 }
static struct categories_level_t debug_categories
short word
static char * category_complete(struct categories_level_t *level, const char *const *argv, int argc, const char *word, int state)

◆ ast_debug_category_is_allowed()

int ast_debug_category_is_allowed ( int  sublevel,
uintmax_t  ids 
)

Check if a debug category is enabled, and allowed to output.

Note
If more than one id is specified then if even one is allowed "true" is returned.
Parameters
sublevelCurrent set sublevel must be this sublevel or less
idsOne or more unique category ids to check
Return values
1if allowed, 0 if not allowed
Since
16.14
17.8
18.0

Definition at line 306 of file logger_category.c.

References category_is_allowed().

307 {
309 }
static int category_is_allowed(int sublevel, struct categories_level_t *level, uintmax_t ids)
static struct categories_level_t debug_categories

◆ ast_debug_category_register()

uintmax_t ast_debug_category_register ( const char *  name)

Register a debug level logger category.

Parameters
nameThe name of the category
idThe unique id of the category
Return values
0if failed to register/retrieve an id. Otherwise it returns the id for the registered category.
Since
16.14
17.8
18.0

Definition at line 279 of file logger_category.c.

References category_register().

Referenced by ast_rtp_engine_init(), and ast_stun_init().

280 {
282 }
static struct categories_level_t debug_categories
static const char name[]
Definition: cdr_mysql.c:74
static uintmax_t category_register(struct categories_level_t *level, const char *name)

◆ ast_debug_category_set_sublevel()

int ast_debug_category_set_sublevel ( const char *  name,
int  sublevel 
)

Set the debug category's sublevel.

Statements are output at a specified sublevel. Typically any number greater than or equal to 0. Other acceptable values include AST_LOG_CATEGORY_ENABLED and AST_LOG_CATEGORY_DISABLED.

Parameters
nameThe name of the category
sublevelThe debug sublevel output number
Return values
0Success, -1 Failure
Since
16.14
17.8
18.0

Definition at line 289 of file logger_category.c.

References category_set_sublevel(), and NULL.

Referenced by handle_cli_rtcp_set_debug(), handle_cli_rtp_set_debug(), handle_cli_stun_set_debug(), rtcp_do_debug_ip(), and rtp_do_debug_ip().

290 {
292 }
#define NULL
Definition: resample.c:96
static struct categories_level_t debug_categories
static const char name[]
Definition: cdr_mysql.c:74
static int category_set_sublevel(struct category_t *category, struct categories_level_t *level, const char *name, int sublevel)

◆ ast_debug_category_set_sublevels()

int ast_debug_category_set_sublevels ( const char *const *  names,
size_t  size,
int  default_sublevel 
)

Set one or more debug category's sublevel.

Accepts an array of category names, and optional associated sublevels. Sublevels can be associated with a name by using a ':' as a separator. For example:

<category name>="">:<category sublevel>="">

The given default sublevel is used if no sublevel is associated with a name.

Parameters
namesAn array of category names
sizeThe size of the array (number of elements)
default_sublevelThe sublevel value to use if one is not associated with a name
Return values
0Success, -1 Failure
Since
16.14
17.8
18.0

Definition at line 294 of file logger_category.c.

References category_set_sublevels().

Referenced by handle_debug_category().

296 {
297  return category_set_sublevels(&debug_categories, names, size, default_sublevel);
298 }
static int category_set_sublevels(struct categories_level_t *level, const char *const *names, size_t size, int default_sublevel)
static struct categories_level_t debug_categories

◆ ast_debug_category_unregister()

int ast_debug_category_unregister ( const char *  name)

Un-register a debug level logger category.

Return values
0Success, -1 Failure
Since
16.14
17.8
18.0

Definition at line 284 of file logger_category.c.

References category_unregister().

Referenced by rtp_engine_shutdown(), and stun_shutdown().

285 {
287 }
static struct categories_level_t debug_categories
static const char name[]
Definition: cdr_mysql.c:74
static int category_unregister(struct categories_level_t *level, const char *name)

◆ ast_logger_category_load()

int ast_logger_category_load ( void  )

Load/Initialize system wide logger category functionality.

Return values
0Success, -1 Failure
Since
16.14
17.8
18.0

Definition at line 317 of file logger_category.c.

References AST_VECTOR_RW_INIT, and categories_level_t::categories.

Referenced by init_logger().

318 {
320  return -1;
321  }
322 
323  return 0;
324 }
#define AST_VECTOR_RW_INIT(vec, size)
Initialize a vector with a read/write lock.
Definition: vector.h:158
struct categories_t categories
static struct categories_level_t debug_categories

◆ ast_logger_category_unload()

int ast_logger_category_unload ( void  )

Unload system wide logger category functionality.

Return values
0Success, -1 Failure
Since
16.14
17.8
18.0

Definition at line 311 of file logger_category.c.

References AST_VECTOR_RW_FREE, and categories_level_t::categories.

Referenced by close_logger().

312 {
314  return 0;
315 }
struct categories_t categories
#define AST_VECTOR_RW_FREE(vec)
Deallocates this locked vector.
Definition: vector.h:202
static struct categories_level_t debug_categories