Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
#include "asterisk.h"
#include "asterisk/cli.h"
#include "asterisk/conversions.h"
#include "asterisk/logger_category.h"
#include "asterisk/vector.h"
Go to the source code of this file.
Data Structures | |
struct | categories_level_t |
struct | category_t |
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... | |
AST_VECTOR_RW (categories_t, struct category_t *) | |
static int | casecmp_by_name (const struct category_t *category, const char *name) |
static char * | category_complete (struct categories_level_t *level, const char *const *argv, int argc, const char *word, int state) |
static int | category_is_allowed (int sublevel, struct categories_level_t *level, uintmax_t ids) |
static uintmax_t | category_register (struct categories_level_t *level, const char *name) |
static int | category_set_sublevel (struct category_t *category, struct categories_level_t *level, const char *name, int sublevel) |
static int | category_set_sublevels (struct categories_level_t *level, const char *const *names, size_t size, int default_sublevel) |
static int | category_unregister (struct categories_level_t *level, const char *name) |
static int | cmp_by_name (const struct category_t *category, const char *name) |
static uintmax_t | get_next_id (struct categories_level_t *level) |
Retrieve the next available id. More... | |
Variables | |
static struct categories_level_t | debug_categories |
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.
argv | A list of already completed options |
argc | The number of already completed options |
word | The word to complete |
state | The state |
0 | Success |
-1 | Failure |
Definition at line 300 of file logger_category.c.
References category_complete(), and debug_categories.
Referenced by handle_debug_category().
int ast_debug_category_is_allowed | ( | int | sublevel, |
uintmax_t | ids | ||
) |
Check if a debug category is enabled, and allowed to output.
sublevel | Current set sublevel must be this sublevel or less |
ids | One or more unique category ids to check |
1 | if allowed |
0 | if not allowed |
Definition at line 306 of file logger_category.c.
References category_is_allowed(), debug_categories, and categories_level_t::sublevel.
uintmax_t ast_debug_category_register | ( | const char * | name | ) |
Register a debug level logger category.
name | The name of the category |
0 | if failed to register/retrieve an id |
Definition at line 279 of file logger_category.c.
References category_register(), debug_categories, and name.
Referenced by ast_rtp_engine_init(), and ast_stun_init().
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.
name | The name of the category |
sublevel | The debug sublevel output number |
0 | Success |
-1 | Failure |
Definition at line 289 of file logger_category.c.
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().
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.
names | An array of category names |
size | The size of the array (number of elements) |
default_sublevel | The sublevel value to use if one is not associated with a name |
0 | Success |
-1 | Failure |
Definition at line 294 of file logger_category.c.
References category_set_sublevels(), and debug_categories.
Referenced by handle_debug_category().
int ast_debug_category_unregister | ( | const char * | name | ) |
Un-register a debug level logger category.
0 | Success |
-1 | Failure |
Definition at line 284 of file logger_category.c.
References category_unregister(), debug_categories, and name.
Referenced by rtp_engine_atexit(), and stun_shutdown().
int ast_logger_category_load | ( | void | ) |
Load/Initialize system wide logger category functionality.
0 | Success |
-1 | Failure |
Definition at line 317 of file logger_category.c.
References AST_VECTOR_RW_INIT, categories_level_t::categories, and debug_categories.
Referenced by init_logger().
int ast_logger_category_unload | ( | void | ) |
Unload system wide logger category functionality.
0 | Success |
-1 | Failure |
Definition at line 311 of file logger_category.c.
References AST_VECTOR_RW_FREE, categories_level_t::categories, and debug_categories.
Referenced by close_logger().
AST_VECTOR_RW | ( | categories_t | , |
struct category_t * | |||
) |
|
static |
Definition at line 113 of file logger_category.c.
References category_t::name, and name.
Referenced by category_set_sublevel().
|
static |
Definition at line 196 of file logger_category.c.
References ast_cli_completion_add(), ast_strdup, AST_VECTOR_GET, AST_VECTOR_RW_RDLOCK, AST_VECTOR_RW_UNLOCK, AST_VECTOR_SIZE, categories_level_t::categories, category_t::name, and NULL.
Referenced by ast_debug_category_complete().
|
static |
Definition at line 241 of file logger_category.c.
References AST_LOG_CATEGORY_DISABLED, AST_LOG_CATEGORY_ENABLED, AST_VECTOR_GET, AST_VECTOR_RW_RDLOCK, AST_VECTOR_RW_UNLOCK, AST_VECTOR_SIZE, categories_level_t::categories, category_t::id, categories_level_t::state, and category_t::sublevel.
Referenced by ast_debug_category_is_allowed().
|
static |
Definition at line 66 of file logger_category.c.
References ast_calloc, ast_log, AST_LOG_CATEGORY_DISABLED, AST_VECTOR_APPEND, AST_VECTOR_GET_INDEX, AST_VECTOR_RW_UNLOCK, AST_VECTOR_RW_WRLOCK, categories_level_t::categories, cmp_by_name(), get_next_id(), category_t::id, LOG_ERROR, category_t::name, name, and category_t::sublevel.
Referenced by ast_debug_category_register().
|
static |
Definition at line 118 of file logger_category.c.
References AST_LOG_CATEGORY_DISABLED, AST_VECTOR_GET_CMP, AST_VECTOR_RW_UNLOCK, AST_VECTOR_RW_WRLOCK, casecmp_by_name(), categories_level_t::categories, category_t::id, name, categories_level_t::state, and category_t::sublevel.
Referenced by ast_debug_category_set_sublevel(), and category_set_sublevels().
|
static |
Definition at line 159 of file logger_category.c.
References ast_copy_string(), ast_str_to_int(), AST_VECTOR_CALLBACK_VOID, AST_VECTOR_RW_UNLOCK, AST_VECTOR_RW_WRLOCK, categories_level_t::categories, category_set_sublevel(), len(), name, NULL, categories_level_t::state, and category_t::sublevel.
Referenced by ast_debug_category_set_sublevels().
|
static |
Definition at line 102 of file logger_category.c.
References ast_free, AST_VECTOR_REMOVE_CMP_UNORDERED, AST_VECTOR_RW_UNLOCK, AST_VECTOR_RW_WRLOCK, categories_level_t::categories, cmp_by_name(), and name.
Referenced by ast_debug_category_unregister().
|
static |
Definition at line 61 of file logger_category.c.
References category_t::name, and name.
Referenced by category_register(), and category_unregister().
|
static |
Retrieve the next available id.
Ids must be a power of 2. This allows for fast lookup, and "or'ing" of ids in order to permit multiple categories in a log statement.
Definition at line 47 of file logger_category.c.
References categories_level_t::id_pool.
Referenced by category_register().
|
static |
Definition at line 272 of file logger_category.c.
Referenced by ast_debug_category_complete(), ast_debug_category_is_allowed(), ast_debug_category_register(), ast_debug_category_set_sublevel(), ast_debug_category_set_sublevels(), ast_debug_category_unregister(), ast_logger_category_load(), and ast_logger_category_unload().