103#define LOGMSG_SIZE MAX(BUFSIZ, 8192)
271#define VERBOSE_BUF_INIT_SIZE 256
274#define LOG_BUF_INIT_SIZE 256
280 char call_identifier_str[13];
284 snprintf(call_identifier_str,
sizeof(call_identifier_str),
"[C-%08x]", msg->
callid);
286 call_identifier_str[0] =
'\0';
291 "s: {s: {s: s, s: s, s: i}, "
294 "timestamp", msg->
date,
297 "callid",
S_OR(call_identifier_str,
""),
300 "filename", msg->
file,
316 json_str_len = strlen(
str);
317 if (json_str_len > size - 1) {
318 json_str_len = size - 1;
320 buf[json_str_len] =
'\n';
321 buf[json_str_len + 1] =
'\0';
379 if (!(p = strchr(fmt,
'\n'))) {
380 p = strchr(fmt,
'\0') - 1;
396 char call_identifier_str[13];
399 snprintf(call_identifier_str,
sizeof(call_identifier_str),
"[C-%08x]", msg->
callid);
401 call_identifier_str[0] =
'\0';
404 switch (chan->
type) {
406 snprintf(
buf, size,
"%s[%d]%s: %s:%d in %s: %s",
412 snprintf(
buf, size,
"[%s] %s[%d]%s %s: %s",
421 int has_line = (msg->
line > 0);
433 snprintf(linestr,
sizeof(linestr),
"%d", msg->
line);
460 char call_identifier_str[13];
463 int has_line = (msg->
line > 0);
467 snprintf(call_identifier_str,
sizeof(call_identifier_str),
"[C-%08x]", msg->
callid);
469 call_identifier_str[0] =
'\0';
472 switch (chan->
type) {
474 snprintf(
buf, size,
"%s[%d]%s: %s:%d in %s: %s",
482 snprintf(linestr,
sizeof(linestr),
"%d", msg->
line);
484 snprintf(
buf, size,
"[%s] %s[%d]%s: %s%s%s%s%s%s%s",
489 has_file ? msg->
file :
"",
491 has_line ? linestr :
"",
494 has_func ?
": " :
"",
511 unsigned int logmask = 0;
514 unsigned int verb_level;
519 w = strchr(stringp,
'[');
521 char *
end = strchr(w + 1,
']');
523 fprintf(stderr,
"Logger Warning: bad formatter definition for %s in logger.conf\n", chan->
filename);
525 char *formatter_name = w + 1;
530 if (!strcasecmp(formatter_name,
"json")) {
532 }
else if (!strcasecmp(formatter_name,
"default")) {
534 }
else if (!strcasecmp(formatter_name,
"plain")) {
537 fprintf(stderr,
"Logger Warning: Unknown formatter definition %s for %s in logger.conf; using 'default'\n",
548 while ((w =
strsep(&stringp,
","))) {
553 if (!strcmp(w,
"*")) {
554 logmask = 0xFFFFFFFF;
555 }
else if (!strncasecmp(w,
"verbose(", 8)) {
591 const char *log_dir_prefix =
"";
592 const char *log_dir_separator =
"";
596 if (!strcasecmp(channel,
"console")) {
600 if (!strncasecmp(channel,
"syslog", 6)) {
607 if (channel[0] !=
'/') {
609 log_dir_separator =
"/";
613 snprintf(filename, size,
"%s%s%s.%s",
614 log_dir_prefix, log_dir_separator, channel,
hostname);
616 snprintf(filename, size,
"%s%s%s",
617 log_dir_prefix, log_dir_separator, channel);
652 char datestring[256];
663 if (!strcasecmp(channel,
"console")) {
665 }
else if (!strncasecmp(channel,
"syslog", 6)) {
670 facility = strchr(channel,
'.');
671 if (!facility++ || !facility) {
678 fprintf(stderr,
"Logger Warning: bad syslog facility in logger.conf\n");
684 openlog(
"asterisk", LOG_PID, chan->
facility);
701 fprintf(chan->
fileptr,
"[%s] Asterisk %s built by %s @ %s on a %s running %s on %s\n",
742 for (i = 0; i <
len; i++) {
743 if (!strcmp(
levels[i], level)) {
793 chan =
make_logchannel(
"console",
"error,warning,notice,verbose", 0, 0);
795 fprintf(stderr,
"ERROR: Failed to initialize default logging\n");
809 fprintf(stderr,
"What box has no hostname???\n");
835 if (strcasecmp(s,
"timestamp") == 0) {
837 }
else if (strcasecmp(s,
"rotate") == 0) {
839 }
else if (strcasecmp(s,
"sequential") == 0) {
841 }
else if (strcasecmp(s,
"none") == 0) {
844 fprintf(stderr,
"Unknown rotatestrategy: %s\n", s);
849 fprintf(stderr,
"rotatetimestamp option has been deprecated. Please use rotatestrategy instead.\n");
854 fprintf(stderr,
"logger_queue_limit has an invalid value. Leaving at default of %d.\n",
858 fprintf(stderr,
"logger_queue_limit must be >= 10. Setting to 10.\n");
867 char *new_custom_levels[16] = { };
868 unsigned int level, new_level = 0;
871 while ((logfile =
strsep(&customlogs,
","))) {
872 new_custom_levels[new_level++] = logfile;
886 while ((logfile = new_custom_levels[new_level++])) {
923 char *msg =
NULL, *emsg =
NULL, *sptr, *eptr;
929 if ((size = vsnprintf(msg, 0, fmt, ap)) < 0) {
941 vsnprintf(msg, size + 1, fmt, aq);
949 for (sptr = msg, eptr = emsg; ; sptr++) {
960 fprintf(stdout,
"verbose \"%s\" %d\n", emsg, level);
965void ast_queue_log(
const char *queuename,
const char *callid,
const char *agent,
const char *
event,
const char *fmt, ...)
986 ast_strftime(time_str,
sizeof(time_str),
"%F %T.%6q", &tm);
988 vsnprintf(qlog_msg,
sizeof(qlog_msg), fmt, ap);
990 if (
logfiles.queue_adaptive_realtime) {
1007 "queuename", queuename,
1019 "queuename", queuename,
1033 qlog_len = snprintf(qlog_msg,
sizeof(qlog_msg),
"%ld|%s|%s|%s|%s|", (
long)time(
NULL), callid, queuename, agent,
event);
1034 vsnprintf(qlog_msg + qlog_len,
sizeof(qlog_msg) - qlog_len, fmt, ap);
1038 fprintf(
qlog,
"%s\n", qlog_msg);
1049 int x, y, which, found, res = 0, fd;
1050 char *suffixes[4] = {
"",
".gz",
".bz2",
".Z" };
1057 for (x = 0; ; x++) {
1058 snprintf(
new,
sizeof(
new),
"%s.%d", filename, x);
1059 fd = open(
new, O_RDONLY);
1065 if (rename(filename,
new)) {
1066 fprintf(stderr,
"Unable to rename file '%s' to '%s'\n", filename,
new);
1073 snprintf(
new,
sizeof(
new),
"%s.%ld", filename, (
long)time(
NULL));
1074 if (rename(filename,
new)) {
1075 fprintf(stderr,
"Unable to rename file '%s' to '%s'\n", filename,
new);
1083 for (x = 0; ; x++) {
1085 for (which = 0; which <
ARRAY_LEN(suffixes); which++) {
1086 snprintf(
new,
sizeof(
new),
"%s.%d%s", filename, x, suffixes[which]);
1087 fd = open(
new, O_RDONLY);
1100 for (y = x; y > 0; y--) {
1101 for (which = 0; which <
ARRAY_LEN(suffixes); which++) {
1102 snprintf(old,
sizeof(old),
"%s.%d%s", filename, y - 1, suffixes[which]);
1103 fd = open(old, O_RDONLY);
1107 snprintf(
new,
sizeof(
new),
"%s.%d%s", filename, y, suffixes[which]);
1108 if (rename(old,
new)) {
1109 fprintf(stderr,
"Unable to rename file '%s' to '%s'\n", old,
new);
1118 snprintf(
new,
sizeof(
new),
"%s.0", filename);
1119 if (rename(filename,
new)) {
1120 fprintf(stderr,
"Unable to rename file '%s' to '%s'\n", filename,
new);
1160 logfiles.queue_adaptive_realtime = 1;
1162 logfiles.queue_adaptive_realtime = 0;
1204 qlog = fopen(qfname,
"a");
1214 int queue_rotate = rotate;
1223 if (ftello(
qlog) > 0x40000000) {
1257 int rotate_this = 0;
1264 if (rotate || rotate_this) {
1279 ast_queue_log(
"NONE",
"NONE",
"NONE",
"CONFIGRELOAD",
"%s",
"");
1280 ast_verb(1,
"Asterisk Queue Logger restarted\n");
1295 "Usage: logger reload [<alt-conf>]\n"
1296 " Reloads the logger subsystem state. Use after restarting syslogd(8) if you are using syslog logging.\n";
1302 ast_cli(
a->fd,
"Failed to reload the logger\n");
1314 "Usage: logger rotate\n"
1315 " Rotates and Reopens the log files.\n";
1321 ast_cli(
a->fd,
"Failed to reload the logger and rotate log files\n");
1375 e->
command =
"logger set level {DEBUG|TRACE|NOTICE|WARNING|ERROR|VERBOSE|DTMF} {on|off}";
1377 "Usage: logger set level {DEBUG|TRACE|NOTICE|WARNING|ERROR|VERBOSE|DTMF} {on|off}\n"
1378 " Set a specific log level to enabled/disabled for this console.\n";
1402 ast_cli(
a->fd,
"Logger status for '%s' has been set to '%s'.\n",
levels[level],
state ?
"on" :
"off");
1410 const char *
status,
const char *configuration,
void *data),
void *data)
1454#define FORMATL "%-35.35s %-8.8s %-10.10s %-9.9s "
1458 e->
command =
"logger show channels";
1460 "Usage: logger show channels\n"
1461 " List configured logger channels.\n";
1477 chan->
disabled ?
"Disabled" :
"Enabled");
1495#define FORMATL2 "%5s %s\n"
1499 e->
command =
"logger show levels";
1501 "Usage: logger show levels\n"
1502 " List configured logger levels.\n";
1555 e->
command =
"logger add channel";
1557 "Usage: logger add channel <name> <levels>\n"
1558 " Adds a temporary logger channel. This logger channel\n"
1559 " will exist until removed or until Asterisk is restarted.\n"
1560 " <levels> is a comma-separated list of desired logger\n"
1561 " levels such as: verbose,warning,error\n"
1562 " An optional formatter may be specified with the levels;\n"
1563 " valid values are '[json]' and '[default]'.\n";
1577 ast_cli(
a->fd,
"Logger channel '%s' already exists\n",
a->argv[3]);
1582 ast_cli(
a->fd,
"ERROR: Unable to create log channel '%s'\n",
a->argv[3]);
1616 char *gen_ret =
NULL;
1620 e->
command =
"logger remove channel";
1622 "Usage: logger remove channel <name>\n"
1623 " Removes a temporary logger channel.\n";
1626 if (
a->argc > 4 || (
a->argc == 4 &&
a->pos > 3)) {
1632 || !strncmp(
a->argv[3], chan->
filename, strlen(
a->argv[3])))) {
1633 if (gen_count ==
a->n) {
1650 ast_cli(
a->fd,
"Removed dynamic logger channel '%s'\n",
a->argv[3]);
1653 ast_cli(
a->fd,
"Unable to find dynamic logger channel '%s'\n",
a->argv[3]);
1656 ast_cli(
a->fd,
"Internal failure attempting to delete dynamic logger channel '%s'\n",
a->argv[3]);
1677 char **callid_group;
1679 return callid_group ? *callid_group :
NULL;
1686 char **callid_group;
1699 if (!*callid_group) {
1708 if (!*callid_group) {
1735 if (!strcmp(
group, cgl->name)) {
1759 strcpy(cgl->name,
group);
1770 const char *callidgroup;
1783 if (!strcmp(callidgroup, cgl->name)) {
1802 .
name =
"LOG_GROUP",
1812 e->
command =
"logger filter changroup";
1814 "Usage: logger filter changroup <group> {on|off}\n"
1815 " Add or remove channel groups from log filtering.\n"
1816 " If filtering is active, only channels assigned\n"
1817 " to a group that has been enabled using this command\n"
1818 " will have execution shown in the CLI.\n";
1830 ast_cli(
a->fd,
"Failed to set channel group filter for group %s\n",
a->argv[3]);
1834 ast_cli(
a->fd,
"Logging of channel group '%s' is now %s\n",
a->argv[3],
enabled ?
"enabled" :
"disabled");
1845 e->
command =
"logger filter show";
1847 "Usage: logger filter show\n"
1848 " Show current logger filtering settings.\n";
1856 ast_cli(
a->fd,
"%3d %-32s\n", ++i, cgl->name);
1861 ast_cli(
a->fd,
"%d channel group%s currently enabled\n", i,
ESS(i));
1863 ast_cli(
a->fd,
"No filtering currently active\n");
1874 e->
command =
"logger filter reset";
1876 "Usage: logger filter reset\n"
1877 " Reset the logger filter.\n"
1878 " This removes any channel groups from filtering\n"
1879 " (all channel execution will be shown)\n";
1887 ast_cli(
a->fd,
"Log filtering has been reset (%d filter%s removed)\n", removed,
ESS(removed));
1912 .sa_flags = SA_RESTART,
1939 switch (chan->
type) {
1944 if (syslog_level < 0) {
1946 fprintf(stderr,
"ast_log_vsyslog called with bogus level: %d\n",
logmsg->
level);
1951 syslog_level = chan->
facility | syslog_level;
1953 syslog(syslog_level,
"%s",
buf);
1979 fprintf(stderr,
"**** Asterisk Logging Error: ***********\n");
1981 fprintf(stderr,
"Asterisk logging error: Out of disk space, can't log to log file %s\n", chan->
filename);
1983 fprintf(stderr,
"Logger Warning: Unable to write to log file '%s': %s (disabled)\n", chan->
filename, strerror(
errno));
2012 ast_verb(1,
"Rotated Logs Per SIGXFSZ (Exceeded file size limit)\n");
2020 const
char *fmt, va_list ap)
2027 char datestring[256];
2084 const
char *fmt, ...)
2115 "Logging resumed. %d message%s discarded.\n",
2130 while ((msg =
next)) {
2168 qlog = fopen(qfname,
"a");
2196 ast_queue_log(
"NONE",
"NONE",
"NONE",
"QUEUESTART",
"%s",
"");
2237 ast_log(
LOG_ERROR,
"Errors detected in logger.conf. Default console logging is being used.\n");
2290 snprintf(buffer, buffer_size,
"[C-%08x]", callid);
2304 return callid ? *callid : 0;
2331 "already associated with callid [C-%08x].\n", callid, *pointing);
2380 if (callid && callid_created) {
2389static void __attribute__((format(printf, 7, 0)))
ast_log_full(
int level,
int sublevel,
2390 const
char *
file,
int line, const
char *function,
ast_callid callid,
2391 const
char *fmt, va_list ap)
2418 "Log queue threshold (%d) exceeded. Discarding new messages.\n",
logger_queue_limit);
2527 ast_str_append(&
buf, 0,
"Got %d backtrace record%c\n", count - 3, count - 3 != 1 ?
's' :
' ');
2541 ast_log(
LOG_WARNING,
"Must run configure with '--with-execinfo' for stack backtraces.\n");
2599 if (verb_level < *console->
level) {
2608 if (verb_level < log->verbosity) {
2725#define LOTS_O_SPACES " "
2727unsigned long _ast_trace_get_indent(
void)
2732void _ast_trace_set_indent(
unsigned long indent)
2737unsigned long _ast_trace_inc_indent(
void)
2746unsigned long _ast_trace_dec_indent(
void)
2756 unsigned long new_indent,
const char* format, ...)
2768 indent = new_indent;
2778 switch(indent_type) {
2806 va_start(ap, format);
2827 "Unable to register dynamic logger level '%s': a standard logger level uses that name.\n",
2836 "Unable to register dynamic logger level '%s'; maximum number of levels registered.\n",
2923 ast_debug(1,
"Unregistered dynamic logger level '%s' with index %u.\n",
name, x);
Prototypes for public functions only of internal interest,.
Asterisk version information.
const char * ast_get_version(void)
Retrieve the Asterisk version string.
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_malloc(len)
A wrapper for malloc()
Asterisk backtrace generation.
#define ast_bt_free_symbols(string_vector)
#define ast_bt_get_symbols(addresses, num_frames)
#define ast_bt_destroy(bt)
const char * ast_build_os
const char * ast_build_machine
const char * ast_build_hostname
const char * ast_build_user
const char * ast_build_date
static int available(struct dahdi_pvt **pvt, int is_specific_channel)
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
#define ast_channel_unref(c)
Decrease channel reference count.
#define ast_dummy_channel_alloc()
Create a fake channel structure.
Standard Command Line Interface.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
#define AST_CLI_DEFINE(fn, txt,...)
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_init_logger_for_socket_console(void)
load logger.conf configuration for console socket connections
ast_trace_indent_type
Controls if and when indenting is applied.
@ AST_TRACE_INDENT_INC_BEFORE
@ AST_TRACE_INDENT_PROVIDED
@ AST_TRACE_INDENT_INC_AFTER
@ AST_TRACE_INDENT_DEC_BEFORE
@ AST_TRACE_INDENT_DEC_AFTER
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
int ast_safe_system(const char *s)
Safely spawn an OS shell command while closing file descriptors.
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
char * strsep(char **str, const char *delims)
Configuration File Parser.
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
int ast_realtime_require_field(const char *family,...) attribute_sentinel
Inform realtime what fields that may be stored.
int ast_unload_realtime(const char *family)
Release any resources cached for a realtime family.
#define CONFIG_STATUS_FILEINVALID
int ast_check_realtime(const char *family)
Check if realtime engine is configured for family.
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
int ast_store_realtime(const char *family,...) attribute_sentinel
Create realtime configuration.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Support for logging to various files, console and syslog Configuration in file logger....
#define ast_debug(level,...)
Log a DEBUG message.
#define VERBOSE_PREFIX_10
void ast_console_toggle_loglevel(int fd, int level, int state)
enables or disables logging of a specified level to the console fd specifies the index of the console...
void ast_console_puts_mutable(const char *string, int level)
log the string to the console, and all attached console clients
#define ast_verb(level,...)
void ast_console_puts_mutable_full(const char *message, int level, int sublevel)
log the string to the console, and all attached console clients
Asterisk JSON abstraction layer.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
void ast_json_free(void *p)
Asterisk's custom JSON allocator. Exposed for use by unit tests.
#define ast_json_dump_string(root)
Encode a JSON value to a compact string.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
#define AST_RWLIST_REMOVE_CURRENT
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
#define AST_LIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized.
#define AST_RWLIST_REMOVE_HEAD
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_RWLIST_REMOVE
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_RWLIST_TRAVERSE_SAFE_END
#define AST_LIST_LOCK(head)
Locks a list.
#define AST_RWLIST_TRAVERSE
#define AST_RWLIST_INSERT_HEAD
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
Asterisk locking-related definitions:
#define ast_cond_destroy(cond)
#define ast_cond_wait(cond, mutex)
#define AST_PTHREADT_NULL
#define ast_cond_init(cond, attr)
#define ast_mutex_init(pmutex)
#define ast_mutex_unlock(a)
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
pthread_cond_t ast_cond_t
#define ast_mutex_destroy(a)
#define ast_mutex_lock(a)
#define AST_MUTEX_DEFINE_STATIC(mutex)
#define ast_cond_signal(cond)
unsigned int queue_log_to_file
int ast_logger_get_dynamic_level(const char *name)
Retrieve dynamic logging level id.
static void make_filename(const char *channel, char *filename, size_t size)
create the filename that will be used for a logger channel.
static int format_log_json(struct logchannel *channel, struct logmsg *msg, char *buf, size_t size)
static int init_logger_chain(const char *altconf)
Read config, setup channels.
int ast_logger_get_queue_limit(void)
Get the maximum number of messages allowed in the processing queue.
static unsigned int global_logmask
void __ast_verbose_ap(const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt, va_list ap)
static int format_log_plain(struct logchannel *chan, struct logmsg *msg, char *buf, size_t size)
int ast_logger_rotate_channel(const char *log_channel)
Rotate the specified log channel.
static char * handle_logger_remove_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
void ast_callid_strnprint(char *buffer, size_t buffer_size, ast_callid callid)
copy a string representation of the callid into a target string
static char * handle_logger_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command to show logging system configuration.
static char * handle_logger_show_levels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command to show logging levels.
AST_THREADSTORAGE_RAW(in_safe_log)
static void verb_console_free(void *v_console)
static int callid_group_remove_filters(void)
static char dateformat[256]
void ast_callid_threadstorage_auto_clean(ast_callid callid, int callid_created)
Use in conjunction with ast_callid_threadstorage_auto. Cleans up the references and if the callid was...
void logger_queue_start(void)
Start the ast_queue_log() logger.
void ast_verb_console_unregister(void)
Unregister this thread's console verbosity level.
static char * levels[NUMLOGLEVELS]
Logging channels used in the Asterisk logging system.
static int callid_filtering
static int filesize_reload_needed
static int custom_level_still_exists(char **levels, char *level, size_t len)
Checks if level exists in array of level names.
static struct ast_custom_function log_group_function
int ast_logger_create_channel(const char *log_channel, const char *components)
Create a log channel.
static void _handle_SIGXFSZ(int sig)
void ast_verb_console_register(int *level)
Register this thread's console verbosity level pointer.
static int log_group_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
static char * handle_logger_chanloggroup_filter(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void ast_log_full(int level, int sublevel, const char *file, int line, const char *function, ast_callid callid, const char *fmt, va_list ap)
send log messages to syslog and/or the console
int ast_callid_threadassoc_change(ast_callid callid)
Sets what is stored in the thread storage to the given callid if it does not match what is already th...
static int close_logger_thread
void ast_log_safe(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message with protection against recursion.
static char * custom_dynamic_levels[NUMLOGLEVELS]
Custom dynamic logging levels added by the user.
int ast_logger_rotate()
Reload logger while rotating log files.
int ast_logger_remove_channel(const char *log_channel)
Delete the specified log channel.
static struct logchannel * make_logchannel(const char *channel, const char *components, int lineno, int dynamic)
static int logger_queue_rt_start(void)
int ast_logger_get_channels(int(*logentry)(const char *channel, const char *type, const char *status, const char *configuration, void *data), void *data)
Retrieve the existing log channels.
static int reload_logger(int rotate, const char *altconf)
int ast_is_logger_initialized(void)
Test if logger is initialized.
static char * handle_logger_filter_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct ast_threadstorage verbose_buf
static void update_logchannels(void)
ast_callid ast_read_threadstorage_callid(void)
extracts the callerid from the thread
static int display_callids
static int logger_initialized
static char exec_after_rotate[256]
static pthread_t logthread
int ast_callid_threadassoc_add(ast_callid callid)
Adds a known callid to thread storage of the calling thread.
ast_callid ast_create_callid(void)
factory function to create a new uniquely identifying callid.
static int logger_queue_limit
static struct logformatter logformatter_json
static int callid_group_set_filter(const char *group, int enabled)
static int logger_queue_size
static struct logformatter logformatter_default
unsigned int queue_log_realtime_use_gmt
static int reload_module(void)
static int logger_add_verbose_magic(struct logmsg *logmsg, char *buf, size_t size)
void __ast_verbose_callid(const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt,...)
Send a verbose message (based on verbose level) with deliberately specified callid.
static unsigned int high_water_alert
static char queue_log_name[256]
static int logger_register_level(const char *name)
#define LOG_BUF_INIT_SIZE
static ast_mutex_t verb_update_lock
static void make_components(struct logchannel *chan)
void __ast_verbose(const char *file, int line, const char *func, int level, const char *fmt,...)
Send a verbose message (based on verbose level)
void ast_log_ap(int level, const char *file, int line, const char *function, const char *fmt, va_list ap)
static char * handle_logger_filter_reset(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static const int colors[NUMLOGLEVELS]
Colors used in the console for logging.
static int format_log_default(struct logchannel *chan, struct logmsg *msg, char *buf, size_t size)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
static struct sigaction handle_SIGXFSZ
static struct ast_threadstorage unique_callid
int ast_callid_threadassoc_remove(void)
Removes callid from thread storage of the calling thread.
void ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt,...)
int ast_callid_threadstorage_auto(ast_callid *callid)
Checks thread storage for a callid and stores a reference if it exists. If not, then a new one will b...
int ast_logger_register_level(const char *name)
Register a new logger level.
static struct ast_threadstorage callid_group_name
static struct @367 logfiles
static void * logger_thread(void *data)
Actual logging thread.
void ast_logger_set_queue_limit(int queue_limit)
Set the maximum number of messages allowed in the processing queue.
void ast_verb_update(void)
Re-evaluate the system max verbosity level (ast_verb_sys_level).
static char * handle_logger_set_level(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct logformatter logformatter_plain
static int callid_set_chanloggroup(const char *group)
static ast_cond_t logcond
#define VERBOSE_BUF_INIT_SIZE
void ast_child_verbose(int level, const char *fmt,...)
static int logger_unregister_level(const char *name)
static struct ast_threadstorage my_verb_console
static void logger_print_normal(struct logmsg *logmsg)
Print a normal log message to the channels.
static int load_module(void)
void ast_log_callid(int level, const char *file, int line, const char *function, ast_callid callid, const char *fmt,...)
Used for sending a log message with a known call_id This is a modified logger function which is funct...
static struct logchannel * find_logchannel(const char *channel)
Find a particular logger channel by name.
static struct ast_threadstorage log_buf
static int unload_module(void)
static char * handle_logger_add_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void logger_queue_init(void)
static int callid_logging_enabled(void)
static struct logmsg * format_log_message_ap(int level, int sublevel, const char *file, int line, const char *function, ast_callid callid, const char *fmt, va_list ap)
static char * handle_logger_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct ast_cli_entry cli_logger[]
static int logger_queue_restart(int queue_rotate)
int ast_verb_console_get(void)
Get this thread's console verbosity level.
static char * handle_logger_rotate(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
const char * ast_logger_get_dateformat(void)
Get the logger configured date format.
void ast_logger_unregister_level(const char *name)
Unregister a previously registered logger level.
unsigned int queue_adaptive_realtime
static int logger_messages_discarded
static int rotate_file(const char *filename)
static const char * get_callid_group(void)
static volatile int next_unique_callid
static char hostname[MAXHOSTNAMELEN]
void ast_log_backtrace(void)
Log a backtrace of the current thread's execution stack to the Asterisk log.
void ast_verb_console_set(int verb_level)
Set this thread's console verbosity level.
static void verb_console_unregister(struct verb_console *console)
static int logger_get_dynamic_level(const char *name)
static struct logmsg * format_log_message(int level, int sublevel, const char *file, int line, const char *function, ast_callid callid, const char *fmt,...)
static void logmsg_free(struct logmsg *msg)
static struct ast_threadstorage verbose_build_buf
int ast_logger_category_load(void)
Load/Initialize system wide logger category functionality.
int ast_logger_category_unload(void)
Unload system wide logger category functionality.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
#define EVENT_FLAG_SYSTEM
Asterisk module definitions.
@ AST_MODFLAG_GLOBAL_SYMBOLS
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
Asterisk file paths, configured in asterisk.conf.
const char * ast_config_AST_SYSTEM_NAME
const char * ast_config_AST_LOG_DIR
Core PBX routines and definitions.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
#define ast_custom_function_register(acf)
Register a custom function.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
#define ast_calloc_with_stringfields(n, type, size)
Allocate a structure with embedded stringfields in a single allocation.
#define AST_STRING_FIELD(name)
Declare a string field.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
String manipulation functions.
@ AST_DYNSTR_BUILD_FAILED
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
int ast_str_set_va(struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap)
Set a dynamic string from a va_list.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
static int force_inline attribute_pure ast_ends_with(const char *str, const char *suffix)
Checks whether a string ends with another.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
char * ast_str_append_substr(struct ast_str **buf, ssize_t maxlen, const char *src, size_t maxsrc)
Append a non-NULL terminated substring to the end of a dynamic string.
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
A structure to hold backtrace information. This structure provides an easy means to store backtrace i...
void * addresses[AST_MAX_BT_FRAMES]
Main Channel structure associated with a channel.
descriptor for a cli entry.
Data structure associated with a custom dialplan function.
Structure used to handle boolean flags.
Abstract JSON element (object, array, string, int, ...).
Support for dynamic strings.
Structure for variables, used for configurations and for channel variables.
String vector definitions.
struct logchannel::@368 list
struct logformatter formatter
const ast_string_field level_name
const ast_string_field message
const ast_string_field file
const ast_string_field function
const ast_string_field date
struct verb_console::@370 node
Syslog support functions for Asterisk logging.
int ast_syslog_priority_from_loglevel(int level)
Maps an Asterisk log level (i.e. LOG_ERROR) to a syslog priority constant.
int ast_syslog_facility(const char *facility)
Maps a syslog facility name from a string to a syslog facility constant.
Handy terminal functions for vt* terms.
char * term_strip(char *outbuf, const char *inbuf, int maxout)
Remove colorings from a specified string.
#define COLORIZE(fg, bg, str)
#define COLORIZE_FMT
Shortcut macros for coloring a set of text.
Definitions to aid in the use of thread local storage.
int ast_threadstorage_set_ptr(struct ast_threadstorage *ts, void *ptr)
Set a raw pointer from threadstorage.
void * ast_threadstorage_get_ptr(struct ast_threadstorage *ts)
Retrieve a raw pointer from threadstorage.
#define AST_THREADSTORAGE_CUSTOM(a, b, c)
Define a thread storage variable, with custom initialization and cleanup.
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
Time-related functions and macros.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define ast_pthread_create(a, b, c, d)
int ast_get_tid(void)
Get current thread ID.
int ast_mkdir(const char *path, int mode)
Recursively create directory path.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.