254 #define VERBOSE_BUF_INIT_SIZE 256 257 #define LOG_BUF_INIT_SIZE 256 263 char call_identifier_str[13];
267 snprintf(call_identifier_str,
sizeof(call_identifier_str),
"[C-%08x]", msg->
callid);
269 call_identifier_str[0] =
'\0';
274 "s: {s: {s: s, s: s, s: i}, " 277 "timestamp", msg->
date,
280 "callid",
S_OR(call_identifier_str,
""),
283 "filename", msg->
file,
299 json_str_len = strlen(str);
300 if (json_str_len > size - 1) {
301 json_str_len = size - 1;
303 buf[json_str_len] =
'\n';
304 buf[json_str_len + 1] =
'\0';
350 if (!(p = strchr(fmt,
'\n'))) {
351 p = strchr(fmt,
'\0') - 1;
367 char call_identifier_str[13];
370 snprintf(call_identifier_str,
sizeof(call_identifier_str),
"[C-%08x]", msg->
callid);
372 call_identifier_str[0] =
'\0';
375 switch (chan->
type) {
377 snprintf(buf, size,
"%s[%d]%s: %s:%d in %s: %s",
378 levels[msg->
level], msg->
lwp, call_identifier_str, msg->
file,
383 snprintf(buf, size,
"[%s] %s[%d]%s %s: %s",
392 int has_line = (msg->
line > 0);
404 snprintf(linestr,
sizeof(linestr),
"%d", msg->
line);
431 char call_identifier_str[13];
434 int has_line = (msg->
line > 0);
438 snprintf(call_identifier_str,
sizeof(call_identifier_str),
"[C-%08x]", msg->
callid);
440 call_identifier_str[0] =
'\0';
443 switch (chan->
type) {
445 snprintf(buf, size,
"%s[%d]%s: %s:%d in %s: %s",
446 levels[msg->
level], msg->
lwp, call_identifier_str, msg->
file,
453 snprintf(linestr,
sizeof(linestr),
"%d", msg->
line);
455 snprintf(buf, size,
"[%s] %s[%d]%s: %s%s%s%s%s%s%s",
460 has_file ? msg->
file :
"",
462 has_line ? linestr :
"",
465 has_func ?
": " :
"",
482 unsigned int logmask = 0;
485 unsigned int verb_level;
490 w = strchr(stringp,
'[');
492 char *
end = strchr(w + 1,
']');
494 fprintf(stderr,
"Logger Warning: bad formatter definition for %s in logger.conf\n", chan->
filename);
496 char *formatter_name = w + 1;
501 if (!strcasecmp(formatter_name,
"json")) {
503 }
else if (!strcasecmp(formatter_name,
"default")) {
505 }
else if (!strcasecmp(formatter_name,
"plain")) {
508 fprintf(stderr,
"Logger Warning: Unknown formatter definition %s for %s in logger.conf; using 'default'\n",
519 while ((w =
strsep(&stringp,
","))) {
524 if (!strcmp(w,
"*")) {
525 logmask = 0xFFFFFFFF;
526 }
else if (!strncasecmp(w,
"verbose(", 8)) {
527 if (levels[
__LOG_VERBOSE] && sscanf(w + 8,
"%30u)", &verb_level) == 1) {
531 for (x = 0; x <
ARRAY_LEN(levels); ++x) {
532 if (levels[x] && !strcasecmp(w, levels[x])) {
562 const char *log_dir_prefix =
"";
563 const char *log_dir_separator =
"";
567 if (!strcasecmp(channel,
"console")) {
571 if (!strncasecmp(channel,
"syslog", 6)) {
578 if (channel[0] !=
'/') {
580 log_dir_separator =
"/";
584 snprintf(filename, size,
"%s%s%s.%s",
585 log_dir_prefix, log_dir_separator, channel,
hostname);
587 snprintf(filename, size,
"%s%s%s",
588 log_dir_prefix, log_dir_separator, channel);
609 if (!strcmp(chan->
filename, filename)) {
623 char datestring[256];
634 if (!strcasecmp(channel,
"console")) {
636 }
else if (!strncasecmp(channel,
"syslog", 6)) {
641 facility = strchr(channel,
'.');
642 if (!facility++ || !facility) {
649 fprintf(stderr,
"Logger Warning: bad syslog facility in logger.conf\n");
655 openlog(
"asterisk", LOG_PID, chan->
facility);
672 fprintf(chan->
fileptr,
"[%s] Asterisk %s built by %s @ %s on a %s running %s on %s\n",
744 chan =
make_logchannel(
"console",
"error,warning,notice,verbose", 0, 0);
746 fprintf(stderr,
"ERROR: Failed to initialize default logging\n");
760 fprintf(stderr,
"What box has no hostname???\n");
786 if (strcasecmp(s,
"timestamp") == 0) {
788 }
else if (strcasecmp(s,
"rotate") == 0) {
790 }
else if (strcasecmp(s,
"sequential") == 0) {
792 }
else if (strcasecmp(s,
"none") == 0) {
795 fprintf(stderr,
"Unknown rotatestrategy: %s\n", s);
800 fprintf(stderr,
"rotatetimestamp option has been deprecated. Please use rotatestrategy instead.\n");
805 fprintf(stderr,
"logger_queue_limit has an invalid value. Leaving at default of %d.\n",
809 fprintf(stderr,
"logger_queue_limit must be >= 10. Setting to 10.\n");
818 while ((logfile =
strsep(&customlogs,
","))) {
852 char *msg =
NULL, *emsg =
NULL, *sptr, *eptr;
858 if ((size = vsnprintf(msg, 0, fmt, ap)) < 0) {
870 vsnprintf(msg, size + 1, fmt, aq);
878 for (sptr = msg, eptr = emsg; ; sptr++) {
889 fprintf(stdout,
"verbose \"%s\" %d\n", emsg, level);
894 void ast_queue_log(
const char *queuename,
const char *callid,
const char *agent,
const char *
event,
const char *fmt, ...)
915 ast_strftime(time_str,
sizeof(time_str),
"%F %T.%6q", &tm);
917 vsnprintf(qlog_msg,
sizeof(qlog_msg), fmt, ap);
919 if (
logfiles.queue_adaptive_realtime) {
936 "queuename", queuename,
948 "queuename", queuename,
962 qlog_len = snprintf(qlog_msg,
sizeof(qlog_msg),
"%ld|%s|%s|%s|%s|", (
long)time(
NULL), callid, queuename, agent, event);
963 vsnprintf(qlog_msg + qlog_len,
sizeof(qlog_msg) - qlog_len, fmt, ap);
967 fprintf(qlog,
"%s\n", qlog_msg);
978 int x, y, which, found, res = 0, fd;
979 char *suffixes[4] = {
"",
".gz",
".bz2",
".Z" };
987 snprintf(
new,
sizeof(
new),
"%s.%d", filename, x);
988 fd = open(
new, O_RDONLY);
994 if (rename(filename,
new)) {
995 fprintf(stderr,
"Unable to rename file '%s' to '%s'\n", filename,
new);
1002 snprintf(
new,
sizeof(
new),
"%s.%ld", filename, (
long)time(
NULL));
1003 if (rename(filename,
new)) {
1004 fprintf(stderr,
"Unable to rename file '%s' to '%s'\n", filename,
new);
1012 for (x = 0; ; x++) {
1014 for (which = 0; which <
ARRAY_LEN(suffixes); which++) {
1015 snprintf(
new,
sizeof(
new),
"%s.%d%s", filename, x, suffixes[which]);
1016 fd = open(
new, O_RDONLY);
1029 for (y = x; y > 0; y--) {
1030 for (which = 0; which <
ARRAY_LEN(suffixes); which++) {
1031 snprintf(old,
sizeof(old),
"%s.%d%s", filename, y - 1, suffixes[which]);
1032 fd = open(old, O_RDONLY);
1036 snprintf(
new,
sizeof(
new),
"%s.%d%s", filename, y, suffixes[which]);
1037 if (rename(old,
new)) {
1038 fprintf(stderr,
"Unable to rename file '%s' to '%s'\n", old,
new);
1047 snprintf(
new,
sizeof(
new),
"%s.0", filename);
1048 if (rename(filename,
new)) {
1049 fprintf(stderr,
"Unable to rename file '%s' to '%s'\n", filename,
new);
1089 logfiles.queue_adaptive_realtime = 1;
1091 logfiles.queue_adaptive_realtime = 0;
1133 qlog = fopen(qfname,
"a");
1143 int queue_rotate = rotate;
1152 if (ftello(qlog) > 0x40000000) {
1184 int rotate_this = 0;
1191 if (rotate || rotate_this) {
1206 ast_queue_log(
"NONE",
"NONE",
"NONE",
"CONFIGRELOAD",
"%s",
"");
1207 ast_verb(1,
"Asterisk Queue Logger restarted\n");
1222 "Usage: logger reload [<alt-conf>]\n" 1223 " Reloads the logger subsystem state. Use after restarting syslogd(8) if you are using syslog logging.\n";
1229 ast_cli(a->
fd,
"Failed to reload the logger\n");
1241 "Usage: logger rotate\n" 1242 " Rotates and Reopens the log files.\n";
1248 ast_cli(a->
fd,
"Failed to reload the logger and rotate log files\n");
1280 if (strcmp(filename, f->
filename) == 0) {
1302 e->
command =
"logger set level {DEBUG|TRACE|NOTICE|WARNING|ERROR|VERBOSE|DTMF} {on|off}";
1304 "Usage: logger set level {DEBUG|TRACE|NOTICE|WARNING|ERROR|VERBOSE|DTMF} {on|off}\n" 1305 " Set a specific log level to enabled/disabled for this console.\n";
1316 for (x = 0; x <
ARRAY_LEN(levels); x++) {
1317 if (levels[x] && !strcasecmp(a->
argv[3], levels[x])) {
1329 ast_cli(a->
fd,
"Logger status for '%s' has been set to '%s'.\n", levels[level], state ?
"on" :
"off");
1337 const char *
status,
const char *configuration,
void *data),
void *data)
1353 for (level = 0; level <
ARRAY_LEN(levels); level++) {
1354 if ((chan->
logmask & (1 << level)) && levels[level]) {
1381 #define FORMATL "%-35.35s %-8.8s %-10.10s %-9.9s " 1385 e->
command =
"logger show channels";
1387 "Usage: logger show channels\n" 1388 " List configured logger channels.\n";
1404 chan->
disabled ?
"Disabled" :
"Enabled");
1406 for (level = 0; level <
ARRAY_LEN(levels); level++) {
1407 if ((chan->
logmask & (1 << level)) && levels[level]) {
1453 e->
command =
"logger add channel";
1455 "Usage: logger add channel <name> <levels>\n" 1456 " Adds a temporary logger channel. This logger channel\n" 1457 " will exist until removed or until Asterisk is restarted.\n" 1458 " <levels> is a comma-separated list of desired logger\n" 1459 " levels such as: verbose,warning,error\n" 1460 " An optional formatter may be specified with the levels;\n" 1461 " valid values are '[json]' and '[default]'.\n";
1475 ast_cli(a->
fd,
"Logger channel '%s' already exists\n", a->
argv[3]);
1480 ast_cli(a->
fd,
"ERROR: Unable to create log channel '%s'\n", a->
argv[3]);
1514 char *gen_ret =
NULL;
1518 e->
command =
"logger remove channel";
1520 "Usage: logger remove channel <name>\n" 1521 " Removes a temporary logger channel.\n";
1524 if (a->
argc > 4 || (a->
argc == 4 && a->
pos > 3)) {
1531 if (gen_count == a->
n) {
1548 ast_cli(a->
fd,
"Removed dynamic logger channel '%s'\n", a->
argv[3]);
1551 ast_cli(a->
fd,
"Unable to find dynamic logger channel '%s'\n", a->
argv[3]);
1554 ast_cli(a->
fd,
"Internal failure attempting to delete dynamic logger channel '%s'\n", a->
argv[3]);
1576 .sa_flags = SA_RESTART,
1603 switch (chan->
type) {
1608 if (syslog_level < 0) {
1610 fprintf(stderr,
"ast_log_vsyslog called with bogus level: %d\n", logmsg->
level);
1615 syslog_level = chan->
facility | syslog_level;
1617 syslog(syslog_level,
"%s", buf);
1639 res = fprintf(chan->
fileptr,
"%s", buf);
1643 fprintf(stderr,
"**** Asterisk Logging Error: ***********\n");
1645 fprintf(stderr,
"Asterisk logging error: Out of disk space, can't log to log file %s\n", chan->
filename);
1647 fprintf(stderr,
"Logger Warning: Unable to write to log file '%s': %s (disabled)\n", chan->
filename, strerror(
errno));
1668 fputs(logmsg->
message, stdout);
1676 ast_verb(1,
"Rotated Logs Per SIGXFSZ (Exceeded file size limit)\n");
1684 const
char *fmt, va_list ap)
1691 char datestring[256];
1735 logmsg->
level = level;
1737 logmsg->
line = line;
1748 const
char *fmt, ...)
1769 if (close_logger_thread) {
1779 "Logging resumed. %d message%s discarded.\n",
1794 while ((msg = next)) {
1834 qlog = fopen(qfname,
"a");
1864 ast_queue_log(
"NONE",
"NONE",
"NONE",
"QUEUESTART",
"%s",
"");
1874 sigaction(SIGXFSZ, &handle_SIGXFSZ,
NULL);
1904 ast_log(
LOG_ERROR,
"Errors detected in logger.conf. Default console logging is being used.\n");
1924 close_logger_thread = 1;
1929 pthread_join(logthread,
NULL);
1954 snprintf(buffer, buffer_size,
"[C-%08x]", callid);
1968 return callid ? *callid : 0;
1995 "already associated with callid [C-%08x].\n", callid, *pointing);
2044 if (callid && callid_created) {
2054 const
char *
file,
int line, const
char *function,
ast_callid callid,
2055 const
char *fmt, va_list ap)
2068 "Log queue threshold (%d) exceeded. Discarding new messages.\n",
logger_queue_limit);
2086 if (close_logger_thread) {
2101 void ast_log(
int level,
const char *
file,
int line,
const char *
function,
const char *fmt, ...)
2106 ast_log_ap(level, file, line,
function, fmt, ap);
2110 void ast_log_ap(
int level,
const char *
file,
int line,
const char *
function,
const char *fmt, va_list ap)
2119 ast_log_full(level, -1, file, line,
function, callid, fmt, ap);
2123 void ast_log_safe(
int level,
const char *
file,
int line,
const char *
function,
const char *fmt, ...)
2142 ast_log_full(level, -1, file, line,
function, callid, fmt, ap);
2153 ast_log_full(level, -1, file, line,
function, callid, fmt, ap);
2163 struct ast_vector_string *strings;
2175 ast_str_append(&buf, 0,
"Got %d backtrace record%c\n", count - 3, count - 3 != 1 ?
's' :
' ');
2189 ast_log(
LOG_WARNING,
"Must run configure with '--with-execinfo' for stack backtraces.\n");
2247 if (verb_level < *console->level) {
2248 verb_level = *console->
level;
2256 if (verb_level < log->verbosity) {
2301 if (!console || !level) {
2332 }
else if (console->
level) {
2333 verb_level = *console->
level;
2351 if (console->
level) {
2352 *console->
level = verb_level;
2375 #define LOTS_O_SPACES " " 2406 unsigned long new_indent,
const char*
format, ...)
2418 indent = new_indent;
2428 switch(indent_type) {
2456 va_start(ap, format);
2469 for (level = 0; level <
ARRAY_LEN(levels); level++) {
2470 if ((level >= 16) && !available && !levels[level]) {
2475 if (levels[level] && !strcasecmp(levels[level], name)) {
2477 "Unable to register dynamic logger level '%s': a standard logger level uses that name.\n",
2487 "Unable to register dynamic logger level '%s'; maximum number of levels registered.\n",
2496 ast_debug(1,
"Registered dynamic logger level '%s' with index %u.\n", name, available);
2521 for (x = 16; x <
ARRAY_LEN(levels); x++) {
2525 if (!strcasecmp(levels[x], name)) {
2538 unsigned int found = 0;
2543 for (x = 16; x <
ARRAY_LEN(levels); x++) {
2548 if (strcasecmp(levels[x], name)) {
2567 ast_debug(1,
"Unregistered dynamic logger level '%s' with index %u.\n", name, x);
struct ast_variable * next
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
void _ast_trace_set_indent(unsigned long indent)
Set the current indent level.
enum sip_cc_notify_state state
static void logger_print_normal(struct logmsg *logmsg)
Print a normal log message to the channels.
static int unload_module(void)
static struct ast_cli_entry cli_logger[]
Main Channel structure associated with a channel.
static char * handle_logger_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define AST_CLI_DEFINE(fn, txt,...)
void ast_verb_console_unregister(void)
Unregister this thread's console verbosity level.
struct logformatter formatter
static int init_logger_chain(const char *altconf)
Read config, setup channels.
#define AST_LIST_LOCK(head)
Locks a list.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
const char * ast_logger_get_dateformat(void)
Get the logger configured date format.
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
static struct ast_threadstorage my_verb_console
void __ast_trace(const char *file, int line, const char *func, enum ast_trace_indent_type indent_type, unsigned long new_indent, const char *format,...)
const char * ast_build_user
static ast_mutex_t verb_update_lock
int ast_logger_remove_channel(const char *log_channel)
Delete the specified log channel.
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
void ast_console_puts_mutable_full(const char *message, int level, int sublevel)
log the string to the console, and all attached console clients
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized...
Asterisk backtrace generation.
static unsigned int global_logmask
String manipulation functions.
static int logger_add_verbose_magic(struct logmsg *logmsg, char *buf, size_t size)
static struct sigaction handle_SIGXFSZ
static const int colors[NUMLOGLEVELS]
Colors used in the console for logging.
Asterisk version information.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
#define ast_bt_free_symbols(string_vector)
unsigned int queue_log_realtime_use_gmt
#define ast_channel_unref(c)
Decrease channel reference count.
static pthread_t logthread
int ast_verb_console_get(void)
Get this thread's console verbosity level.
unsigned long _ast_trace_inc_indent(void)
Increment the indent level.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
static int format_log_json(struct logchannel *channel, struct logmsg *msg, char *buf, size_t size)
static int rotate_file(const char *filename)
Time-related functions and macros.
static void logmsg_free(struct logmsg *msg)
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
static int force_inline attribute_pure ast_ends_with(const char *str, const char *suffix)
static void make_filename(const char *channel, char *filename, size_t size)
create the filename that will be used for a logger channel.
const char * ast_get_version(void)
Retrieve the Asterisk version string.
void ast_verb_console_register(int *level)
Register this thread's console verbosity level pointer.
void ast_verb_update(void)
Re-evaluate the system max verbosity level (ast_verb_sys_level).
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
static void verb_console_free(void *v_console)
descriptor for a cli entry.
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
int ast_unload_realtime(const char *family)
Release any resources cached for a realtime family.
#define CONFIG_STATUS_FILEINVALID
void ast_json_free(void *p)
Asterisk's custom JSON allocator. Exposed for use by unit tests.
void ast_log_ap(int level, const char *file, int line, const char *function, const char *fmt, va_list ap)
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
const char * ast_build_date
#define LOG_BUF_INIT_SIZE
int ast_check_realtime(const char *family)
Check if realtime engine is configured for family.
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
Structure for variables, used for configurations and for channel variables.
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 ast_bt_get_symbols(addresses, num_frames)
const char * ast_build_os
#define ast_json_dump_string(root)
Encode a JSON value to a compact string.
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
void ast_verb_console_set(int verb_level)
Set this thread's console verbosity level.
int ast_logger_category_unload(void)
Unload system wide logger category functionality.
void ast_log_backtrace(void)
Log a backtrace of the current thread's execution stack to the Asterisk log.
char * term_strip(char *outbuf, const char *inbuf, int maxout)
Remove colorings from a specified string.
int ast_logger_rotate_channel(const char *log_channel)
Rotate the specified log channel.
#define ast_calloc_with_stringfields(n, type, size)
Allocate a structure with embedded stringfields in a single allocation.
void ast_init_logger_for_socket_console(void)
load logger.conf configuration for console socket connections
static char * levels[NUMLOGLEVELS]
Logging channels used in the Asterisk logging system.
#define ast_cond_wait(cond, mutex)
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#define ast_cond_init(cond, attr)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
void logger_queue_start(void)
Start the ast_queue_log() logger.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
unsigned int queue_log_to_file
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
AST_THREADSTORAGE_RAW(in_safe_log)
#define ast_mutex_lock(a)
#define ast_bt_destroy(bt)
#define ast_strdup(str)
A wrapper for strdup()
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...
int ast_logger_register_level(const char *name)
Register a new logger level.
Definitions to aid in the use of thread local storage.
static int reload_logger(int rotate, const char *altconf)
static struct ast_threadstorage unique_callid
void ast_cli(int fd, const char *fmt,...)
int ast_syslog_priority_from_loglevel(int level)
Maps an Asterisk log level (i.e. LOG_ERROR) to a syslog priority constant.
static void make_components(struct logchannel *chan)
#define ast_cond_signal(cond)
#define ast_verb(level,...)
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
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.
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.
void ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt,...)
const char * ast_build_hostname
#define VERBOSE_BUF_INIT_SIZE
static int reload_module(void)
static char * handle_logger_remove_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define COLORIZE(fg, bg, str)
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 update_logchannels(void)
void ast_logger_set_queue_limit(int queue_limit)
Set the maximum number of messages allowed in the processing queue.
pthread_cond_t ast_cond_t
#define ast_strlen_zero(foo)
static struct ast_threadstorage log_buf
static struct logformatter logformatter_json
const char * ast_config_AST_SYSTEM_NAME
static int logger_initialized
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.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
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 int filesize_reload_needed
Configuration File Parser.
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
const char * ast_build_machine
ast_trace_indent_type
Controls if and when indenting is applied.
static int logger_queue_rt_start(void)
#define AST_RWLIST_INSERT_HEAD
#define EVENT_FLAG_SYSTEM
#define ast_debug(level,...)
Log a DEBUG message.
struct logchannel::@404 list
int ast_store_realtime(const char *family,...) attribute_sentinel
Create realtime configuration.
void ast_child_verbose(int level, const char *fmt,...)
static unsigned int high_water_alert
General Asterisk PBX channel definitions.
Asterisk JSON abstraction layer.
int ast_realtime_require_field(const char *family,...) attribute_sentinel
Inform realtime what fields that may be stored.
Asterisk file paths, configured in asterisk.conf.
int ast_threadstorage_set_ptr(struct ast_threadstorage *ts, void *ptr)
Set a raw pointer from threadstorage.
int ast_get_tid(void)
Get current thread ID.
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.
int ast_logger_rotate()
Reload logger while rotating log files.
static struct logformatter logformatter_plain
#define AST_PTHREADT_NULL
#define ast_dummy_channel_alloc()
Create a fake channel structure.
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.
#define AST_RWLIST_TRAVERSE
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
#define AST_STRING_FIELD(name)
Declare a string field.
void ast_config_destroy(struct ast_config *config)
Destroys a config.
#define COLORIZE_FMT
Shortcut macros for coloring a set of text.
static int logger_register_level(const char *name)
#define ast_strdupa(s)
duplicate a string in memory from the stack
const ast_string_field function
static char queue_log_name[256]
#define ast_malloc(len)
A wrapper for malloc()
static volatile int next_unique_callid
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
static char exec_after_rotate[256]
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 char * handle_logger_add_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void _handle_SIGXFSZ(int sig)
Syslog support functions for Asterisk logging.
Core PBX routines and definitions.
#define AST_LIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
void __ast_verbose_ap(const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt, va_list ap)
int ast_callid_threadassoc_remove(void)
Removes callid from thread storage of the calling thread.
ast_callid ast_read_threadstorage_callid(void)
extracts the callerid from the thread
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
int ast_is_logger_initialized(void)
Test if logger is initialized.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
int ast_safe_system(const char *s)
Safely spawn an OS shell command while closing file descriptors.
static struct ast_threadstorage verbose_build_buf
void __ast_verbose(const char *file, int line, const char *func, int level, const char *fmt,...)
Send a verbose message (based on verbose level)
int ast_callid_threadassoc_add(ast_callid callid)
Adds a known callid to thread storage of the calling thread.
const ast_string_field date
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
static struct logchannel * make_logchannel(const char *channel, const char *components, int lineno, int dynamic)
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
ast_callid ast_create_callid(void)
factory function to create a new uniquely identifying callid.
#define ast_cond_destroy(cond)
const char * ast_config_AST_LOG_DIR
static struct logchannel * find_logchannel(const char *channel)
Find a particular logger channel by name.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
static void * logger_thread(void *data)
Actual logging thread.
int ast_logger_create_channel(const char *log_channel, const char *components)
Create a log channel.
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_pthread_create(a, b, c, d)
static void logger_queue_init(void)
static int load_module(void)
#define AST_RWLIST_REMOVE_HEAD
Prototypes for public functions only of internal interest,.
void ast_console_puts_mutable(const char *string, int level)
log the string to the console, and all attached console clients
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...
void * ast_threadstorage_get_ptr(struct ast_threadstorage *ts)
Retrieve a raw pointer from threadstorage.
void * addresses[AST_MAX_BT_FRAMES]
static int format_log_plain(struct logchannel *chan, struct logmsg *msg, char *buf, size_t size)
Structure used to handle boolean flags.
static struct logformatter logformatter_default
Support for logging to various files, console and syslog Configuration in file logger.conf.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
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_THREADSTORAGE_CUSTOM(a, b, c)
Define a thread storage variable, with custom initialization and cleanup.
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)
const ast_string_field level_name
static int available(struct dahdi_pvt **pvt, int is_specific_channel)
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
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...
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
static char dateformat[256]
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
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...
char * strsep(char **str, const char *delims)
Standard Command Line Interface.
static int display_callids
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
static void verb_console_unregister(struct verb_console *console)
int ast_syslog_facility(const char *facility)
Maps a syslog facility name from a string to a syslog facility constant.
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
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
const ast_string_field message
int ast_logger_get_queue_limit(void)
Get the maximum number of messages allowed in the processing queue.
Abstract JSON element (object, array, string, int, ...).
static struct ast_threadstorage verbose_buf
#define AST_RWLIST_REMOVE
Handy terminal functions for vt* terms.
static int logger_queue_size
#define ast_mutex_init(pmutex)
unsigned long _ast_trace_get_indent(void)
Get the current indent level.
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
const ast_string_field file
#define ast_mutex_destroy(a)
static int close_logger_thread
#define ASTERISK_GPL_KEY
The text the key() function should return.
int ast_dynamic_logger_level(const char *name)
Checks if a dynamic logger level exists.
static int logger_queue_restart(int queue_rotate)
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
Asterisk module definitions.
static snd_pcm_format_t format
unsigned long _ast_trace_dec_indent(void)
Decrement the indent level.
static int logger_queue_limit
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
static struct @403 logfiles
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...
static char * handle_logger_set_level(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int logger_messages_discarded
static ast_cond_t logcond
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...
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_MUTEX_DEFINE_STATIC(mutex)
static char * handle_logger_rotate(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
void ast_logger_unregister_level(const char *name)
Unregister a previously registered logger level.
#define ast_mutex_unlock(a)
static char hostname[MAXHOSTNAMELEN]
static int format_log_default(struct logchannel *chan, struct logmsg *msg, char *buf, size_t size)
#define AST_APP_ARG(name)
Define an application argument.
int ast_mkdir(const char *path, int mode)
Recursively create directory path.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
int ast_logger_category_load(void)
Load/Initialize system wide logger category functionality.
unsigned int queue_adaptive_realtime