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';
367 if (!(p = strchr(fmt,
'\n'))) {
368 p = strchr(fmt,
'\0') - 1;
384 char call_identifier_str[13];
387 snprintf(call_identifier_str,
sizeof(call_identifier_str),
"[C-%08x]", msg->
callid);
389 call_identifier_str[0] =
'\0';
392 switch (chan->
type) {
394 snprintf(
buf, size,
"%s[%d]%s: %s:%d in %s: %s",
400 snprintf(
buf, size,
"[%s] %s[%d]%s %s: %s",
409 int has_line = (msg->
line > 0);
421 snprintf(linestr,
sizeof(linestr),
"%d", msg->
line);
448 char call_identifier_str[13];
451 int has_line = (msg->
line > 0);
455 snprintf(call_identifier_str,
sizeof(call_identifier_str),
"[C-%08x]", msg->
callid);
457 call_identifier_str[0] =
'\0';
460 switch (chan->
type) {
462 snprintf(
buf, size,
"%s[%d]%s: %s:%d in %s: %s",
470 snprintf(linestr,
sizeof(linestr),
"%d", msg->
line);
472 snprintf(
buf, size,
"[%s] %s[%d]%s: %s%s%s%s%s%s%s",
477 has_file ? msg->
file :
"",
479 has_line ? linestr :
"",
482 has_func ?
": " :
"",
499 unsigned int logmask = 0;
502 unsigned int verb_level;
507 w = strchr(stringp,
'[');
509 char *
end = strchr(w + 1,
']');
511 fprintf(stderr,
"Logger Warning: bad formatter definition for %s in logger.conf\n", chan->
filename);
513 char *formatter_name = w + 1;
518 if (!strcasecmp(formatter_name,
"json")) {
520 }
else if (!strcasecmp(formatter_name,
"default")) {
522 }
else if (!strcasecmp(formatter_name,
"plain")) {
525 fprintf(stderr,
"Logger Warning: Unknown formatter definition %s for %s in logger.conf; using 'default'\n",
536 while ((w =
strsep(&stringp,
","))) {
541 if (!strcmp(w,
"*")) {
542 logmask = 0xFFFFFFFF;
543 }
else if (!strncasecmp(w,
"verbose(", 8)) {
579 const char *log_dir_prefix =
"";
580 const char *log_dir_separator =
"";
584 if (!strcasecmp(channel,
"console")) {
588 if (!strncasecmp(channel,
"syslog", 6)) {
595 if (channel[0] !=
'/') {
597 log_dir_separator =
"/";
601 snprintf(filename, size,
"%s%s%s.%s",
602 log_dir_prefix, log_dir_separator, channel,
hostname);
604 snprintf(filename, size,
"%s%s%s",
605 log_dir_prefix, log_dir_separator, channel);
640 char datestring[256];
651 if (!strcasecmp(channel,
"console")) {
653 }
else if (!strncasecmp(channel,
"syslog", 6)) {
658 facility = strchr(channel,
'.');
659 if (!facility++ || !facility) {
666 fprintf(stderr,
"Logger Warning: bad syslog facility in logger.conf\n");
672 openlog(
"asterisk", LOG_PID, chan->
facility);
689 fprintf(chan->
fileptr,
"[%s] Asterisk %s built by %s @ %s on a %s running %s on %s\n",
730 for (i = 0; i <
len; i++) {
731 if (!strcmp(
levels[i], level)) {
781 chan =
make_logchannel(
"console",
"error,warning,notice,verbose", 0, 0);
783 fprintf(stderr,
"ERROR: Failed to initialize default logging\n");
797 fprintf(stderr,
"What box has no hostname???\n");
823 if (strcasecmp(s,
"timestamp") == 0) {
825 }
else if (strcasecmp(s,
"rotate") == 0) {
827 }
else if (strcasecmp(s,
"sequential") == 0) {
829 }
else if (strcasecmp(s,
"none") == 0) {
832 fprintf(stderr,
"Unknown rotatestrategy: %s\n", s);
837 fprintf(stderr,
"rotatetimestamp option has been deprecated. Please use rotatestrategy instead.\n");
842 fprintf(stderr,
"logger_queue_limit has an invalid value. Leaving at default of %d.\n",
846 fprintf(stderr,
"logger_queue_limit must be >= 10. Setting to 10.\n");
855 char *new_custom_levels[16] = { };
856 unsigned int level, new_level = 0;
859 while ((logfile =
strsep(&customlogs,
","))) {
860 new_custom_levels[new_level++] = logfile;
874 while ((logfile = new_custom_levels[new_level++])) {
911 char *msg =
NULL, *emsg =
NULL, *sptr, *eptr;
917 if ((size = vsnprintf(msg, 0, fmt, ap)) < 0) {
929 vsnprintf(msg, size + 1, fmt, aq);
937 for (sptr = msg, eptr = emsg; ; sptr++) {
948 fprintf(stdout,
"verbose \"%s\" %d\n", emsg, level);
953void ast_queue_log(
const char *queuename,
const char *callid,
const char *agent,
const char *
event,
const char *fmt, ...)
974 ast_strftime(time_str,
sizeof(time_str),
"%F %T.%6q", &tm);
976 vsnprintf(qlog_msg,
sizeof(qlog_msg), fmt, ap);
978 if (
logfiles.queue_adaptive_realtime) {
995 "queuename", queuename,
1007 "queuename", queuename,
1021 qlog_len = snprintf(qlog_msg,
sizeof(qlog_msg),
"%ld|%s|%s|%s|%s|", (
long)time(
NULL), callid, queuename, agent,
event);
1022 vsnprintf(qlog_msg + qlog_len,
sizeof(qlog_msg) - qlog_len, fmt, ap);
1026 fprintf(
qlog,
"%s\n", qlog_msg);
1037 int x, y, which, found, res = 0, fd;
1038 char *suffixes[4] = {
"",
".gz",
".bz2",
".Z" };
1045 for (x = 0; ; x++) {
1046 snprintf(
new,
sizeof(
new),
"%s.%d", filename, x);
1047 fd = open(
new, O_RDONLY);
1053 if (rename(filename,
new)) {
1054 fprintf(stderr,
"Unable to rename file '%s' to '%s'\n", filename,
new);
1061 snprintf(
new,
sizeof(
new),
"%s.%ld", filename, (
long)time(
NULL));
1062 if (rename(filename,
new)) {
1063 fprintf(stderr,
"Unable to rename file '%s' to '%s'\n", filename,
new);
1071 for (x = 0; ; x++) {
1073 for (which = 0; which <
ARRAY_LEN(suffixes); which++) {
1074 snprintf(
new,
sizeof(
new),
"%s.%d%s", filename, x, suffixes[which]);
1075 fd = open(
new, O_RDONLY);
1088 for (y = x; y > 0; y--) {
1089 for (which = 0; which <
ARRAY_LEN(suffixes); which++) {
1090 snprintf(old,
sizeof(old),
"%s.%d%s", filename, y - 1, suffixes[which]);
1091 fd = open(old, O_RDONLY);
1095 snprintf(
new,
sizeof(
new),
"%s.%d%s", filename, y, suffixes[which]);
1096 if (rename(old,
new)) {
1097 fprintf(stderr,
"Unable to rename file '%s' to '%s'\n", old,
new);
1106 snprintf(
new,
sizeof(
new),
"%s.0", filename);
1107 if (rename(filename,
new)) {
1108 fprintf(stderr,
"Unable to rename file '%s' to '%s'\n", filename,
new);
1148 logfiles.queue_adaptive_realtime = 1;
1150 logfiles.queue_adaptive_realtime = 0;
1192 qlog = fopen(qfname,
"a");
1202 int queue_rotate = rotate;
1211 if (ftello(
qlog) > 0x40000000) {
1245 int rotate_this = 0;
1252 if (rotate || rotate_this) {
1267 ast_queue_log(
"NONE",
"NONE",
"NONE",
"CONFIGRELOAD",
"%s",
"");
1268 ast_verb(1,
"Asterisk Queue Logger restarted\n");
1283 "Usage: logger reload [<alt-conf>]\n"
1284 " Reloads the logger subsystem state. Use after restarting syslogd(8) if you are using syslog logging.\n";
1290 ast_cli(
a->fd,
"Failed to reload the logger\n");
1302 "Usage: logger rotate\n"
1303 " Rotates and Reopens the log files.\n";
1309 ast_cli(
a->fd,
"Failed to reload the logger and rotate log files\n");
1363 e->
command =
"logger set level {DEBUG|TRACE|NOTICE|WARNING|ERROR|VERBOSE|DTMF} {on|off}";
1365 "Usage: logger set level {DEBUG|TRACE|NOTICE|WARNING|ERROR|VERBOSE|DTMF} {on|off}\n"
1366 " Set a specific log level to enabled/disabled for this console.\n";
1390 ast_cli(
a->fd,
"Logger status for '%s' has been set to '%s'.\n",
levels[level],
state ?
"on" :
"off");
1398 const char *
status,
const char *configuration,
void *data),
void *data)
1442#define FORMATL "%-35.35s %-8.8s %-10.10s %-9.9s "
1446 e->
command =
"logger show channels";
1448 "Usage: logger show channels\n"
1449 " List configured logger channels.\n";
1465 chan->
disabled ?
"Disabled" :
"Enabled");
1483#define FORMATL2 "%5s %s\n"
1487 e->
command =
"logger show levels";
1489 "Usage: logger show levels\n"
1490 " List configured logger levels.\n";
1543 e->
command =
"logger add channel";
1545 "Usage: logger add channel <name> <levels>\n"
1546 " Adds a temporary logger channel. This logger channel\n"
1547 " will exist until removed or until Asterisk is restarted.\n"
1548 " <levels> is a comma-separated list of desired logger\n"
1549 " levels such as: verbose,warning,error\n"
1550 " An optional formatter may be specified with the levels;\n"
1551 " valid values are '[json]' and '[default]'.\n";
1565 ast_cli(
a->fd,
"Logger channel '%s' already exists\n",
a->argv[3]);
1570 ast_cli(
a->fd,
"ERROR: Unable to create log channel '%s'\n",
a->argv[3]);
1604 char *gen_ret =
NULL;
1608 e->
command =
"logger remove channel";
1610 "Usage: logger remove channel <name>\n"
1611 " Removes a temporary logger channel.\n";
1614 if (
a->argc > 4 || (
a->argc == 4 &&
a->pos > 3)) {
1620 || !strncmp(
a->argv[3], chan->
filename, strlen(
a->argv[3])))) {
1621 if (gen_count ==
a->n) {
1638 ast_cli(
a->fd,
"Removed dynamic logger channel '%s'\n",
a->argv[3]);
1641 ast_cli(
a->fd,
"Unable to find dynamic logger channel '%s'\n",
a->argv[3]);
1644 ast_cli(
a->fd,
"Internal failure attempting to delete dynamic logger channel '%s'\n",
a->argv[3]);
1665 char **callid_group;
1667 return callid_group ? *callid_group :
NULL;
1674 char **callid_group;
1687 if (!*callid_group) {
1696 if (!*callid_group) {
1723 if (!strcmp(
group, cgl->name)) {
1747 strcpy(cgl->name,
group);
1758 const char *callidgroup;
1771 if (!strcmp(callidgroup, cgl->name)) {
1790 .
name =
"LOG_GROUP",
1800 e->
command =
"logger filter changroup";
1802 "Usage: logger filter changroup <group> {on|off}\n"
1803 " Add or remove channel groups from log filtering.\n"
1804 " If filtering is active, only channels assigned\n"
1805 " to a group that has been enabled using this command\n"
1806 " will have execution shown in the CLI.\n";
1818 ast_cli(
a->fd,
"Failed to set channel group filter for group %s\n",
a->argv[3]);
1822 ast_cli(
a->fd,
"Logging of channel group '%s' is now %s\n",
a->argv[3],
enabled ?
"enabled" :
"disabled");
1833 e->
command =
"logger filter show";
1835 "Usage: logger filter show\n"
1836 " Show current logger filtering settings.\n";
1844 ast_cli(
a->fd,
"%3d %-32s\n", ++i, cgl->name);
1849 ast_cli(
a->fd,
"%d channel group%s currently enabled\n", i,
ESS(i));
1851 ast_cli(
a->fd,
"No filtering currently active\n");
1862 e->
command =
"logger filter reset";
1864 "Usage: logger filter reset\n"
1865 " Reset the logger filter.\n"
1866 " This removes any channel groups from filtering\n"
1867 " (all channel execution will be shown)\n";
1875 ast_cli(
a->fd,
"Log filtering has been reset (%d filter%s removed)\n", removed,
ESS(removed));
1900 .sa_flags = SA_RESTART,
1927 switch (chan->
type) {
1932 if (syslog_level < 0) {
1934 fprintf(stderr,
"ast_log_vsyslog called with bogus level: %d\n",
logmsg->
level);
1939 syslog_level = chan->
facility | syslog_level;
1941 syslog(syslog_level,
"%s",
buf);
1967 fprintf(stderr,
"**** Asterisk Logging Error: ***********\n");
1969 fprintf(stderr,
"Asterisk logging error: Out of disk space, can't log to log file %s\n", chan->
filename);
1971 fprintf(stderr,
"Logger Warning: Unable to write to log file '%s': %s (disabled)\n", chan->
filename, strerror(
errno));
2000 ast_verb(1,
"Rotated Logs Per SIGXFSZ (Exceeded file size limit)\n");
2008 const
char *fmt, va_list ap)
2015 char datestring[256];
2072 const
char *fmt, ...)
2103 "Logging resumed. %d message%s discarded.\n",
2118 while ((msg =
next)) {
2156 qlog = fopen(qfname,
"a");
2184 ast_queue_log(
"NONE",
"NONE",
"NONE",
"QUEUESTART",
"%s",
"");
2225 ast_log(
LOG_ERROR,
"Errors detected in logger.conf. Default console logging is being used.\n");
2278 snprintf(buffer, buffer_size,
"[C-%08x]", callid);
2292 return callid ? *callid : 0;
2319 "already associated with callid [C-%08x].\n", callid, *pointing);
2368 if (callid && callid_created) {
2377static void __attribute__((format(printf, 7, 0)))
ast_log_full(
int level,
int sublevel,
2378 const
char *
file,
int line, const
char *function,
ast_callid callid,
2379 const
char *fmt, va_list ap)
2406 "Log queue threshold (%d) exceeded. Discarding new messages.\n",
logger_queue_limit);
2515 ast_str_append(&
buf, 0,
"Got %d backtrace record%c\n", count - 3, count - 3 != 1 ?
's' :
' ');
2529 ast_log(
LOG_WARNING,
"Must run configure with '--with-execinfo' for stack backtraces.\n");
2587 if (verb_level < *console->
level) {
2596 if (verb_level < log->verbosity) {
2713#define LOTS_O_SPACES " "
2715unsigned long _ast_trace_get_indent(
void)
2720void _ast_trace_set_indent(
unsigned long indent)
2725unsigned long _ast_trace_inc_indent(
void)
2734unsigned long _ast_trace_dec_indent(
void)
2744 unsigned long new_indent,
const char* format, ...)
2756 indent = new_indent;
2766 switch(indent_type) {
2794 va_start(ap, format);
2815 "Unable to register dynamic logger level '%s': a standard logger level uses that name.\n",
2824 "Unable to register dynamic logger level '%s'; maximum number of levels registered.\n",
2911 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.
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.