100#define LOGMSG_SIZE MAX(BUFSIZ, 8192)
268#define VERBOSE_BUF_INIT_SIZE 256
271#define LOG_BUF_INIT_SIZE 256
277 char call_identifier_str[13];
281 snprintf(call_identifier_str,
sizeof(call_identifier_str),
"[C-%08x]", msg->
callid);
283 call_identifier_str[0] =
'\0';
288 "s: {s: {s: s, s: s, s: i}, "
291 "timestamp", msg->
date,
294 "callid",
S_OR(call_identifier_str,
""),
297 "filename", msg->
file,
313 json_str_len = strlen(
str);
314 if (json_str_len > size - 1) {
315 json_str_len = size - 1;
317 buf[json_str_len] =
'\n';
318 buf[json_str_len + 1] =
'\0';
376 if (!(p = strchr(fmt,
'\n'))) {
377 p = strchr(fmt,
'\0') - 1;
393 char call_identifier_str[13];
396 snprintf(call_identifier_str,
sizeof(call_identifier_str),
"[C-%08x]", msg->
callid);
398 call_identifier_str[0] =
'\0';
401 switch (chan->
type) {
403 snprintf(
buf, size,
"%s[%d]%s: %s:%d in %s: %s",
409 snprintf(
buf, size,
"[%s] %s[%d]%s %s: %s",
418 int has_line = (msg->
line > 0);
430 snprintf(linestr,
sizeof(linestr),
"%d", msg->
line);
457 char call_identifier_str[13];
460 int has_line = (msg->
line > 0);
464 snprintf(call_identifier_str,
sizeof(call_identifier_str),
"[C-%08x]", msg->
callid);
466 call_identifier_str[0] =
'\0';
469 switch (chan->
type) {
471 snprintf(
buf, size,
"%s[%d]%s: %s:%d in %s: %s",
479 snprintf(linestr,
sizeof(linestr),
"%d", msg->
line);
481 snprintf(
buf, size,
"[%s] %s[%d]%s: %s%s%s%s%s%s%s",
486 has_file ? msg->
file :
"",
488 has_line ? linestr :
"",
491 has_func ?
": " :
"",
508 unsigned int logmask = 0;
511 unsigned int verb_level;
516 w = strchr(stringp,
'[');
518 char *
end = strchr(w + 1,
']');
520 fprintf(stderr,
"Logger Warning: bad formatter definition for %s in logger.conf\n", chan->
filename);
522 char *formatter_name = w + 1;
527 if (!strcasecmp(formatter_name,
"json")) {
529 }
else if (!strcasecmp(formatter_name,
"default")) {
531 }
else if (!strcasecmp(formatter_name,
"plain")) {
534 fprintf(stderr,
"Logger Warning: Unknown formatter definition %s for %s in logger.conf; using 'default'\n",
545 while ((w =
strsep(&stringp,
","))) {
550 if (!strcmp(w,
"*")) {
551 logmask = 0xFFFFFFFF;
552 }
else if (!strncasecmp(w,
"verbose(", 8)) {
588 const char *log_dir_prefix =
"";
589 const char *log_dir_separator =
"";
593 if (!strcasecmp(channel,
"console")) {
597 if (!strncasecmp(channel,
"syslog", 6)) {
604 if (channel[0] !=
'/') {
606 log_dir_separator =
"/";
610 snprintf(filename, size,
"%s%s%s.%s",
611 log_dir_prefix, log_dir_separator, channel,
hostname);
613 snprintf(filename, size,
"%s%s%s",
614 log_dir_prefix, log_dir_separator, channel);
649 char datestring[256];
660 if (!strcasecmp(channel,
"console")) {
662 }
else if (!strncasecmp(channel,
"syslog", 6)) {
667 facility = strchr(channel,
'.');
668 if (!facility++ || !facility) {
675 fprintf(stderr,
"Logger Warning: bad syslog facility in logger.conf\n");
681 openlog(
"asterisk", LOG_PID, chan->
facility);
698 fprintf(chan->
fileptr,
"[%s] Asterisk %s built by %s @ %s on a %s running %s on %s\n",
739 for (i = 0; i <
len; i++) {
740 if (!strcmp(
levels[i], level)) {
790 chan =
make_logchannel(
"console",
"error,warning,notice,verbose", 0, 0);
792 fprintf(stderr,
"ERROR: Failed to initialize default logging\n");
806 fprintf(stderr,
"What box has no hostname???\n");
832 if (strcasecmp(s,
"timestamp") == 0) {
834 }
else if (strcasecmp(s,
"rotate") == 0) {
836 }
else if (strcasecmp(s,
"sequential") == 0) {
838 }
else if (strcasecmp(s,
"none") == 0) {
841 fprintf(stderr,
"Unknown rotatestrategy: %s\n", s);
846 fprintf(stderr,
"rotatetimestamp option has been deprecated. Please use rotatestrategy instead.\n");
851 fprintf(stderr,
"logger_queue_limit has an invalid value. Leaving at default of %d.\n",
855 fprintf(stderr,
"logger_queue_limit must be >= 10. Setting to 10.\n");
864 char *new_custom_levels[16] = { };
865 unsigned int level, new_level = 0;
868 while ((logfile =
strsep(&customlogs,
","))) {
869 new_custom_levels[new_level++] = logfile;
883 while ((logfile = new_custom_levels[new_level++])) {
920 char *msg =
NULL, *emsg =
NULL, *sptr, *eptr;
926 if ((size = vsnprintf(msg, 0, fmt, ap)) < 0) {
938 vsnprintf(msg, size + 1, fmt, aq);
946 for (sptr = msg, eptr = emsg; ; sptr++) {
957 fprintf(stdout,
"verbose \"%s\" %d\n", emsg, level);
962void ast_queue_log(
const char *queuename,
const char *callid,
const char *agent,
const char *
event,
const char *fmt, ...)
983 ast_strftime(time_str,
sizeof(time_str),
"%F %T.%6q", &tm);
985 vsnprintf(qlog_msg,
sizeof(qlog_msg), fmt, ap);
987 if (
logfiles.queue_adaptive_realtime) {
1004 "queuename", queuename,
1016 "queuename", queuename,
1030 qlog_len = snprintf(qlog_msg,
sizeof(qlog_msg),
"%ld|%s|%s|%s|%s|", (
long)time(
NULL), callid, queuename, agent,
event);
1031 vsnprintf(qlog_msg + qlog_len,
sizeof(qlog_msg) - qlog_len, fmt, ap);
1035 fprintf(
qlog,
"%s\n", qlog_msg);
1046 int x, y, which, found, res = 0, fd;
1047 char *suffixes[4] = {
"",
".gz",
".bz2",
".Z" };
1054 for (x = 0; ; x++) {
1055 snprintf(
new,
sizeof(
new),
"%s.%d", filename, x);
1056 fd = open(
new, O_RDONLY);
1062 if (rename(filename,
new)) {
1063 fprintf(stderr,
"Unable to rename file '%s' to '%s'\n", filename,
new);
1070 snprintf(
new,
sizeof(
new),
"%s.%ld", filename, (
long)time(
NULL));
1071 if (rename(filename,
new)) {
1072 fprintf(stderr,
"Unable to rename file '%s' to '%s'\n", filename,
new);
1080 for (x = 0; ; x++) {
1082 for (which = 0; which <
ARRAY_LEN(suffixes); which++) {
1083 snprintf(
new,
sizeof(
new),
"%s.%d%s", filename, x, suffixes[which]);
1084 fd = open(
new, O_RDONLY);
1097 for (y = x; y > 0; y--) {
1098 for (which = 0; which <
ARRAY_LEN(suffixes); which++) {
1099 snprintf(old,
sizeof(old),
"%s.%d%s", filename, y - 1, suffixes[which]);
1100 fd = open(old, O_RDONLY);
1104 snprintf(
new,
sizeof(
new),
"%s.%d%s", filename, y, suffixes[which]);
1105 if (rename(old,
new)) {
1106 fprintf(stderr,
"Unable to rename file '%s' to '%s'\n", old,
new);
1115 snprintf(
new,
sizeof(
new),
"%s.0", filename);
1116 if (rename(filename,
new)) {
1117 fprintf(stderr,
"Unable to rename file '%s' to '%s'\n", filename,
new);
1157 logfiles.queue_adaptive_realtime = 1;
1159 logfiles.queue_adaptive_realtime = 0;
1201 qlog = fopen(qfname,
"a");
1211 int queue_rotate = rotate;
1220 if (ftello(
qlog) > 0x40000000) {
1242 int rotate_this = 0;
1249 if (rotate || rotate_this) {
1264 ast_queue_log(
"NONE",
"NONE",
"NONE",
"CONFIGRELOAD",
"%s",
"");
1265 ast_verb(1,
"Asterisk Queue Logger restarted\n");
1280 "Usage: logger reload [<alt-conf>]\n"
1281 " Reloads the logger subsystem state. Use after restarting syslogd(8) if you are using syslog logging.\n";
1287 ast_cli(
a->fd,
"Failed to reload the logger\n");
1299 "Usage: logger rotate\n"
1300 " Rotates and Reopens the log files.\n";
1306 ast_cli(
a->fd,
"Failed to reload the logger and rotate log files\n");
1360 e->
command =
"logger set level {DEBUG|TRACE|NOTICE|WARNING|ERROR|VERBOSE|DTMF} {on|off}";
1362 "Usage: logger set level {DEBUG|TRACE|NOTICE|WARNING|ERROR|VERBOSE|DTMF} {on|off}\n"
1363 " Set a specific log level to enabled/disabled for this console.\n";
1387 ast_cli(
a->fd,
"Logger status for '%s' has been set to '%s'.\n",
levels[level],
state ?
"on" :
"off");
1395 const char *
status,
const char *configuration,
void *data),
void *data)
1439#define FORMATL "%-35.35s %-8.8s %-10.10s %-9.9s "
1443 e->
command =
"logger show channels";
1445 "Usage: logger show channels\n"
1446 " List configured logger channels.\n";
1462 chan->
disabled ?
"Disabled" :
"Enabled");
1480#define FORMATL2 "%5s %s\n"
1484 e->
command =
"logger show levels";
1486 "Usage: logger show levels\n"
1487 " List configured logger levels.\n";
1540 e->
command =
"logger add channel";
1542 "Usage: logger add channel <name> <levels>\n"
1543 " Adds a temporary logger channel. This logger channel\n"
1544 " will exist until removed or until Asterisk is restarted.\n"
1545 " <levels> is a comma-separated list of desired logger\n"
1546 " levels such as: verbose,warning,error\n"
1547 " An optional formatter may be specified with the levels;\n"
1548 " valid values are '[json]' and '[default]'.\n";
1562 ast_cli(
a->fd,
"Logger channel '%s' already exists\n",
a->argv[3]);
1567 ast_cli(
a->fd,
"ERROR: Unable to create log channel '%s'\n",
a->argv[3]);
1601 char *gen_ret =
NULL;
1605 e->
command =
"logger remove channel";
1607 "Usage: logger remove channel <name>\n"
1608 " Removes a temporary logger channel.\n";
1611 if (
a->argc > 4 || (
a->argc == 4 &&
a->pos > 3)) {
1617 || !strncmp(
a->argv[3], chan->
filename, strlen(
a->argv[3])))) {
1618 if (gen_count ==
a->n) {
1635 ast_cli(
a->fd,
"Removed dynamic logger channel '%s'\n",
a->argv[3]);
1638 ast_cli(
a->fd,
"Unable to find dynamic logger channel '%s'\n",
a->argv[3]);
1641 ast_cli(
a->fd,
"Internal failure attempting to delete dynamic logger channel '%s'\n",
a->argv[3]);
1662 char **callid_group;
1664 return callid_group ? *callid_group :
NULL;
1671 char **callid_group;
1684 if (!*callid_group) {
1693 if (!*callid_group) {
1720 if (!strcmp(
group, cgl->name)) {
1744 strcpy(cgl->name,
group);
1755 const char *callidgroup;
1768 if (!strcmp(callidgroup, cgl->name)) {
1787 .
name =
"LOG_GROUP",
1797 e->
command =
"logger filter changroup";
1799 "Usage: logger filter changroup <group> {on|off}\n"
1800 " Add or remove channel groups from log filtering.\n"
1801 " If filtering is active, only channels assigned\n"
1802 " to a group that has been enabled using this command\n"
1803 " will have execution shown in the CLI.\n";
1815 ast_cli(
a->fd,
"Failed to set channel group filter for group %s\n",
a->argv[3]);
1819 ast_cli(
a->fd,
"Logging of channel group '%s' is now %s\n",
a->argv[3],
enabled ?
"enabled" :
"disabled");
1830 e->
command =
"logger filter show";
1832 "Usage: logger filter show\n"
1833 " Show current logger filtering settings.\n";
1841 ast_cli(
a->fd,
"%3d %-32s\n", ++i, cgl->name);
1846 ast_cli(
a->fd,
"%d channel group%s currently enabled\n", i,
ESS(i));
1848 ast_cli(
a->fd,
"No filtering currently active\n");
1859 e->
command =
"logger filter reset";
1861 "Usage: logger filter reset\n"
1862 " Reset the logger filter.\n"
1863 " This removes any channel groups from filtering\n"
1864 " (all channel execution will be shown)\n";
1872 ast_cli(
a->fd,
"Log filtering has been reset (%d filter%s removed)\n", removed,
ESS(removed));
1897 .sa_flags = SA_RESTART,
1924 switch (chan->
type) {
1929 if (syslog_level < 0) {
1931 fprintf(stderr,
"ast_log_vsyslog called with bogus level: %d\n",
logmsg->
level);
1936 syslog_level = chan->
facility | syslog_level;
1938 syslog(syslog_level,
"%s",
buf);
1964 fprintf(stderr,
"**** Asterisk Logging Error: ***********\n");
1966 fprintf(stderr,
"Asterisk logging error: Out of disk space, can't log to log file %s\n", chan->
filename);
1968 fprintf(stderr,
"Logger Warning: Unable to write to log file '%s': %s (disabled)\n", chan->
filename, strerror(
errno));
1987 ast_verb(1,
"Rotated Logs Per SIGXFSZ (Exceeded file size limit)\n");
1995 const
char *fmt, va_list ap)
2002 char datestring[256];
2059 const
char *fmt, ...)
2090 "Logging resumed. %d message%s discarded.\n",
2105 while ((msg =
next)) {
2143 qlog = fopen(qfname,
"a");
2171 ast_queue_log(
"NONE",
"NONE",
"NONE",
"QUEUESTART",
"%s",
"");
2212 ast_log(
LOG_ERROR,
"Errors detected in logger.conf. Default console logging is being used.\n");
2265 snprintf(buffer, buffer_size,
"[C-%08x]", callid);
2279 return callid ? *callid : 0;
2306 "already associated with callid [C-%08x].\n", callid, *pointing);
2355 if (callid && callid_created) {
2364static void __attribute__((format(printf, 7, 0)))
ast_log_full(
int level,
int sublevel,
2365 const
char *
file,
int line, const
char *function,
ast_callid callid,
2366 const
char *fmt, va_list ap)
2393 "Log queue threshold (%d) exceeded. Discarding new messages.\n",
logger_queue_limit);
2502 ast_str_append(&
buf, 0,
"Got %d backtrace record%c\n", count - 3, count - 3 != 1 ?
's' :
' ');
2516 ast_log(
LOG_WARNING,
"Must run configure with '--with-execinfo' for stack backtraces.\n");
2574 if (verb_level < *console->
level) {
2583 if (verb_level < log->verbosity) {
2700#define LOTS_O_SPACES " "
2702unsigned long _ast_trace_get_indent(
void)
2707void _ast_trace_set_indent(
unsigned long indent)
2712unsigned long _ast_trace_inc_indent(
void)
2721unsigned long _ast_trace_dec_indent(
void)
2731 unsigned long new_indent,
const char* format, ...)
2743 indent = new_indent;
2753 switch(indent_type) {
2781 va_start(ap, format);
2802 "Unable to register dynamic logger level '%s': a standard logger level uses that name.\n",
2811 "Unable to register dynamic logger level '%s'; maximum number of levels registered.\n",
2898 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.
char * strsep(char **str, const char *delims)
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.
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
static struct @370 logfiles
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 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.
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.
@ AST_DYNSTR_BUILD_FAILED
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 logformatter formatter
struct logchannel::@371 list
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::@373 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.