Asterisk - The Open Source Telephony Project GIT-master-2de1a68
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 { \
if (DEBUG_ATLEAST(sublevel) || ast_debug_category_is_allowed(sublevel, ids)) { \
ast_log(AST_LOG_DEBUG, __VA_ARGS__); \
} \
} while (0)
#define DEBUG_ATLEAST(level)
#define AST_LOG_DEBUG
int ast_debug_category_is_allowed(int sublevel, uintmax_t ids)
Check if a debug category is enabled, and allowed to output.

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 176 of file logger_category.h.

◆ AST_LOG_CATEGORY_DISABLED

#define AST_LOG_CATEGORY_DISABLED   0

Logger category is disabled

Definition at line 31 of file logger_category.h.

◆ AST_LOG_CATEGORY_ENABLED

#define AST_LOG_CATEGORY_ENABLED   -1

Logger category is enabled

Definition at line 26 of file logger_category.h.

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
-1Failure
Since
16.14
17.8
18.0

Definition at line 300 of file logger_category.c.

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

References category_complete(), and debug_categories.

Referenced by handle_debug_category().

◆ 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
0if not allowed
Since
16.14
17.8
18.0

Definition at line 306 of file logger_category.c.

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

References category_is_allowed(), debug_categories, and categories_level_t::sublevel.

◆ 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
Return values
0if failed to register/retrieve an id
Returns
id for the registered category
Since
16.14
17.8
18.0

Definition at line 279 of file logger_category.c.

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

References category_register(), debug_categories, and name.

Referenced by ast_rtp_engine_init(), and ast_stun_init().

◆ 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
-1Failure
Since
16.14
17.8
18.0

Definition at line 289 of file logger_category.c.

290{
291 return category_set_sublevel(NULL, &debug_categories, name, sublevel);
292}
static int category_set_sublevel(struct category_t *category, struct categories_level_t *level, const char *name, int sublevel)
#define NULL
Definition: resample.c:96

References category_set_sublevel(), debug_categories, name, NULL, and categories_level_t::sublevel.

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().

◆ 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
-1Failure
Since
16.14
17.8
18.0

Definition at line 294 of file logger_category.c.

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)

References category_set_sublevels(), and debug_categories.

Referenced by handle_debug_category().

◆ ast_debug_category_unregister()

int ast_debug_category_unregister ( const char *  name)

Un-register a debug level logger category.

Return values
0Success
-1Failure
Since
16.14
17.8
18.0

Definition at line 284 of file logger_category.c.

285{
287}
static int category_unregister(struct categories_level_t *level, const char *name)

References category_unregister(), debug_categories, and name.

Referenced by rtp_engine_shutdown(), and stun_shutdown().

◆ ast_logger_category_load()

int ast_logger_category_load ( void  )

Load/Initialize system wide logger category functionality.

Return values
0Success
-1Failure
Since
16.14
17.8
18.0

Definition at line 317 of file logger_category.c.

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

References AST_VECTOR_RW_INIT, categories_level_t::categories, and debug_categories.

Referenced by init_logger().

◆ ast_logger_category_unload()

int ast_logger_category_unload ( void  )

Unload system wide logger category functionality.

Return values
0Success
-1Failure
Since
16.14
17.8
18.0

Definition at line 311 of file logger_category.c.

312{
314 return 0;
315}
#define AST_VECTOR_RW_FREE(vec)
Deallocates this locked vector.
Definition: vector.h:202

References AST_VECTOR_RW_FREE, categories_level_t::categories, and debug_categories.

Referenced by close_logger().