Thu Oct 11 06:36:37 2012

Asterisk developer's documentation


logger.c File Reference

Asterisk Logger. More...

#include "asterisk.h"
#include <syslog.h>
#include "asterisk/_private.h"
#include "asterisk/paths.h"
#include "asterisk/logger.h"
#include "asterisk/lock.h"
#include "asterisk/channel.h"
#include "asterisk/config.h"
#include "asterisk/term.h"
#include "asterisk/cli.h"
#include "asterisk/utils.h"
#include "asterisk/manager.h"
#include "asterisk/astobj2.h"
#include "asterisk/threadstorage.h"
#include "asterisk/strings.h"
#include "asterisk/pbx.h"
#include "asterisk/app.h"
#include "asterisk/buildinfo.h"
#include "asterisk/ast_version.h"
#include <signal.h>
#include <time.h>
#include <sys/stat.h>
#include <fcntl.h>

Include dependency graph for logger.c:

Go to the source code of this file.

Data Structures

struct  ast_callid
struct  logchannel
struct  logchannels
struct  logmsg
struct  logmsgs
struct  verb
struct  verbosers

Defines

#define FORMATL   "%-35.35s %-8.8s %-9.9s "
#define LOG_BUF_INIT_SIZE   256
#define VERBOSE_BUF_INIT_SIZE   256
#define VERBOSE_HASMAGIC(x)   (*(signed char *) (x) < 0)
#define VERBOSE_MAGIC2LEVEL(x)   (((char) -*(signed char *) (x)) - 1)

Enumerations

enum  logmsgtypes { LOGMSG_NORMAL = 0, LOGMSG_VERBOSE }
enum  logtypes { LOGTYPE_SYSLOG, LOGTYPE_FILE, LOGTYPE_CONSOLE }
enum  rotatestrategy { NONE = 0, SEQUENTIAL = 1 << 0, ROTATE = 1 << 1, TIMESTAMP = 1 << 2 }

Functions

void __ast_verbose (const char *file, int line, const char *func, int level, const char *fmt,...)
 This works like ast_log, but prints verbose messages to the console depending on verbosity level set. ast_verbose(VERBOSE_PREFIX_3 "Whatever %s is happening\n", "nothing"); This will print the message to the console if the verbose level is set to a level >= 3 Note the absence of a comma after the VERBOSE_PREFIX_3. This is important. VERBOSE_PREFIX_1 through VERBOSE_PREFIX_4 are defined.
void __ast_verbose_ap (const char *file, int line, const char *func, int level, struct ast_callid *callid, const char *fmt, va_list ap)
void __ast_verbose_callid (const char *file, int line, const char *func, int level, struct ast_callid *callid, const char *fmt,...)
 just like __ast_verbose, only __ast_verbose_callid allows you to specify which callid is being used for the log without needing to bind it to a thread. NULL is a valid argument for this function and will allow you to specify that a log will never display a call id even when there is a call id bound to the thread.
static void __fini_logchannels (void)
static void __fini_verbosers (void)
static void __init_log_buf (void)
static void __init_logchannels (void)
static void __init_unique_callid (void)
static void __init_verbose_buf (void)
static void __init_verbosers (void)
static void _handle_SIGXFSZ (int sig)
void ast_backtrace (void)
void ast_callid_strnprint (char *buffer, size_t buffer_size, struct ast_callid *callid)
 copy a string representation of the callid into a target string
int ast_callid_threadassoc_add (struct ast_callid *callid)
 Adds a known callid to thread storage of the calling thread.
int ast_callid_threadassoc_remove ()
 Removes callid from thread storage of the calling thread.
int ast_callid_threadstorage_auto (struct ast_callid **callid)
 Checks thread storage for a callid and stores a reference if it exists. If not, then a new one will be created, bound to the thread, and a reference to it will be stored.
void ast_callid_threadstorage_auto_clean (struct ast_callid *callid, int callid_created)
 Use in conjunction with ast_callid_threadstorage_auto. Cleans up the references and if the callid was created by threadstorage_auto, unbinds the callid from the threadstorage.
void ast_child_verbose (int level, const char *fmt,...)
struct ast_callidast_create_callid (void)
 factory function to create a new uniquely identifying callid.
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 invoke it would be something like this: ast_log(AST_LOG_WHATEVER, "Problem with the %s Captain. We should get some more. Will %d be enough?\n", "flux capacitor", 10); where WHATEVER is one of ERROR, DEBUG, EVENT, NOTICE, or WARNING depending on which log you wish to output to. These are implemented as macros, that will provide the function with the needed arguments.
void ast_log_callid (int level, const char *file, int line, const char *function, struct 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 functionally identical to the above logger function, it just include a call_id argument as well. If NULL is specified here, no attempt will be made to join the log message with a call_id.
static void ast_log_full (int level, const char *file, int line, const char *function, struct ast_callid *callid, const char *fmt, va_list ap)
 send log messages to syslog and/or the console
static void ast_log_vsyslog (struct logmsg *msg)
int ast_logger_register_level (const char *name)
 Register a new logger level.
void ast_logger_unregister_level (const char *name)
 Unregister a previously registered logger level.
void ast_queue_log (const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt,...)
struct ast_callidast_read_threadstorage_callid (void)
 extracts the callerid from the thread
int ast_register_verbose (void(*v)(const char *string))
int ast_unregister_verbose (void(*v)(const char *string))
void ast_verbose (const char *fmt,...)
void close_logger (void)
static char * handle_logger_reload (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_logger_rotate (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_logger_set_level (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
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 init_logger (void)
static void init_logger_chain (int locked, const char *altconf)
static void logger_print_normal (struct logmsg *logmsg)
 Print a normal log message to the channels.
static void logger_queue_init (void)
static int logger_queue_restart (int queue_rotate)
static int logger_queue_rt_start (void)
int logger_reload (void)
 Reload the logger module without rotating log files (also used from loader.c during a full Asterisk reload).
static void * logger_thread (void *data)
 Actual logging thread.
static void logmsg_free (struct logmsg *msg)
static unsigned int make_components (const char *s, int lineno, int *verbosity)
static struct logchannelmake_logchannel (const char *channel, const char *components, int lineno)
static int reload_logger (int rotate, const char *altconf)
static int rotate_file (const char *filename)
static void unique_callid_cleanup (void *data)
static void update_logchannels (void)

Variables

static struct ast_cli_entry cli_logger []
static int close_logger_thread = 0
static const int colors [NUMLOGLEVELS]
 Colors used in the console for logging.
static char dateformat [256] = "%b %e %T"
static int display_callids
static char exec_after_rotate [256] = ""
static int filesize_reload_needed
static unsigned int global_logmask = 0xFFFF
static struct sigaction handle_SIGXFSZ
static char hostname [MAXHOSTNAMELEN]
static char * levels [NUMLOGLEVELS]
 Logging channels used in the Asterisk logging system.
static struct ast_threadstorage log_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_log_buf , .custom_init = NULL , }
static ast_cond_t logcond
struct {
   unsigned int   queue_adaptive_realtime:1
   unsigned int   queue_log:1
   unsigned int   queue_log_to_file:1
logfiles
static int logger_initialized
static pthread_t logthread = AST_PTHREADT_NULL
static volatile int next_unique_callid
static FILE * qlog
static char queue_log_name [256] = QUEUELOG
static int queuelog_init
static struct ast_threadstorage unique_callid = { .once = PTHREAD_ONCE_INIT , .key_init = __init_unique_callid , .custom_init = NULL , }
static struct ast_threadstorage verbose_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_verbose_buf , .custom_init = NULL , }


Detailed Description

Asterisk Logger.

Logging routines

Author:
Mark Spencer <markster@digium.com>

Definition in file logger.c.


Define Documentation

#define FORMATL   "%-35.35s %-8.8s %-9.9s "

#define LOG_BUF_INIT_SIZE   256

Definition at line 237 of file logger.c.

Referenced by ast_log_full().

#define VERBOSE_BUF_INIT_SIZE   256

Definition at line 234 of file logger.c.

Referenced by __ast_verbose_ap().

#define VERBOSE_HASMAGIC (  )     (*(signed char *) (x) < 0)

Definition at line 1024 of file logger.c.

#define VERBOSE_MAGIC2LEVEL (  )     (((char) -*(signed char *) (x)) - 1)

Definition at line 1023 of file logger.c.


Enumeration Type Documentation

Enumerator:
LOGMSG_NORMAL 
LOGMSG_VERBOSE 

Definition at line 140 of file logger.c.

00140                  {
00141    LOGMSG_NORMAL = 0,
00142    LOGMSG_VERBOSE,
00143 };

enum logtypes

Enumerator:
LOGTYPE_SYSLOG 
LOGTYPE_FILE 
LOGTYPE_CONSOLE 

Definition at line 109 of file logger.c.

00109               {
00110    LOGTYPE_SYSLOG,
00111    LOGTYPE_FILE,
00112    LOGTYPE_CONSOLE,
00113 };

Enumerator:
NONE 
SEQUENTIAL 
ROTATE 
TIMESTAMP 

Definition at line 94 of file logger.c.

00094                            {
00095    NONE = 0,                /* Do not rotate log files at all, instead rely on external mechanisms */
00096    SEQUENTIAL = 1 << 0,     /* Original method - create a new file, in order */
00097    ROTATE = 1 << 1,         /* Rotate all files, such that the oldest file has the highest suffix */
00098    TIMESTAMP = 1 << 2,      /* Append the epoch timestamp onto the end of the archived file */
00099 } rotatestrategy = SEQUENTIAL;


Function Documentation

void __ast_verbose ( const char *  file,
int  line,
const char *  func,
int  level,
const char *  fmt,
  ... 
)

This works like ast_log, but prints verbose messages to the console depending on verbosity level set. ast_verbose(VERBOSE_PREFIX_3 "Whatever %s is happening\n", "nothing"); This will print the message to the console if the verbose level is set to a level >= 3 Note the absence of a comma after the VERBOSE_PREFIX_3. This is important. VERBOSE_PREFIX_1 through VERBOSE_PREFIX_4 are defined.

Send a verbose message (based on verbose level)

Version:
11 added level parameter

Definition at line 1778 of file logger.c.

References __ast_verbose_ap(), ast_callid_unref, and ast_read_threadstorage_callid().

01779 {
01780    struct ast_callid *callid;
01781    va_list ap;
01782 
01783    callid = ast_read_threadstorage_callid();
01784 
01785    va_start(ap, fmt);
01786    __ast_verbose_ap(file, line, func, level, callid, fmt, ap);
01787    va_end(ap);
01788 
01789    if (callid) {
01790       ast_callid_unref(callid);
01791    }
01792 }

void __ast_verbose_ap ( const char *  file,
int  line,
const char *  func,
int  level,
struct ast_callid callid,
const char *  fmt,
va_list  ap 
)

Definition at line 1723 of file logger.c.

References __LOG_VERBOSE, ast_alloca, AST_DYNSTR_BUILD_FAILED, ast_localtime(), ast_log_callid(), ast_opt_timestamp, ast_str_buffer(), ast_str_set_va(), ast_str_thread_get(), ast_strftime(), ast_tvnow(), prefix, verbose_buf, VERBOSE_BUF_INIT_SIZE, VERBOSE_PREFIX_1, VERBOSE_PREFIX_2, VERBOSE_PREFIX_3, and VERBOSE_PREFIX_4.

Referenced by __ast_verbose(), __ast_verbose_callid(), and ast_verbose().

01724 {
01725    struct ast_str *buf = NULL;
01726    int res = 0;
01727    const char *prefix = level >= 4 ? VERBOSE_PREFIX_4 : level == 3 ? VERBOSE_PREFIX_3 : level == 2 ? VERBOSE_PREFIX_2 : level == 1 ? VERBOSE_PREFIX_1 : "";
01728    signed char magic = level > 127 ? -128 : -level - 1; /* 0 => -1, 1 => -2, etc.  Can't pass NUL, as it is EOS-delimiter */
01729 
01730    /* For compatibility with modules still calling ast_verbose() directly instead of using ast_verb() */
01731    if (level < 0) {
01732       if (!strncmp(fmt, VERBOSE_PREFIX_4, strlen(VERBOSE_PREFIX_4))) {
01733          magic = -5;
01734       } else if (!strncmp(fmt, VERBOSE_PREFIX_3, strlen(VERBOSE_PREFIX_3))) {
01735          magic = -4;
01736       } else if (!strncmp(fmt, VERBOSE_PREFIX_2, strlen(VERBOSE_PREFIX_2))) {
01737          magic = -3;
01738       } else if (!strncmp(fmt, VERBOSE_PREFIX_1, strlen(VERBOSE_PREFIX_1))) {
01739          magic = -2;
01740       } else {
01741          magic = -1;
01742       }
01743    }
01744 
01745    if (!(buf = ast_str_thread_get(&verbose_buf, VERBOSE_BUF_INIT_SIZE))) {
01746       return;
01747    }
01748 
01749    if (ast_opt_timestamp) {
01750       struct timeval now;
01751       struct ast_tm tm;
01752       char date[40];
01753       char *datefmt;
01754 
01755       now = ast_tvnow();
01756       ast_localtime(&now, &tm, NULL);
01757       ast_strftime(date, sizeof(date), dateformat, &tm);
01758       datefmt = ast_alloca(strlen(date) + 3 + strlen(prefix) + strlen(fmt) + 1);
01759       sprintf(datefmt, "%c[%s] %s%s", (char) magic, date, prefix, fmt);
01760       fmt = datefmt;
01761    } else {
01762       char *tmp = ast_alloca(strlen(prefix) + strlen(fmt) + 2);
01763       sprintf(tmp, "%c%s%s", (char) magic, prefix, fmt);
01764       fmt = tmp;
01765    }
01766 
01767    /* Build string */
01768    res = ast_str_set_va(&buf, 0, fmt, ap);
01769 
01770    /* If the build failed then we can drop this allocated message */
01771    if (res == AST_DYNSTR_BUILD_FAILED) {
01772       return;
01773    }
01774 
01775    ast_log_callid(__LOG_VERBOSE, file, line, func, callid, "%s", ast_str_buffer(buf));
01776 }

void __ast_verbose_callid ( const char *  file,
int  line,
const char *  func,
int  level,
struct ast_callid callid,
const char *  fmt,
  ... 
)

just like __ast_verbose, only __ast_verbose_callid allows you to specify which callid is being used for the log without needing to bind it to a thread. NULL is a valid argument for this function and will allow you to specify that a log will never display a call id even when there is a call id bound to the thread.

Send a verbose message (based on verbose level) with deliberately specified callid

Definition at line 1794 of file logger.c.

References __ast_verbose_ap().

01795 {
01796    va_list ap;
01797    va_start(ap, fmt);
01798    __ast_verbose_ap(file, line, func, level, callid, fmt, ap);
01799    va_end(ap);
01800 }

static void __fini_logchannels ( void   )  [static]

Definition at line 138 of file logger.c.

00140 {

static void __fini_verbosers ( void   )  [static]

Definition at line 982 of file logger.c.

00984 {

static void __init_log_buf ( void   )  [static]

Definition at line 236 of file logger.c.

00242 {

static void __init_logchannels ( void   )  [static]

Definition at line 138 of file logger.c.

00140 {

static void __init_unique_callid ( void   )  [static]

Definition at line 92 of file logger.c.

00094 {

static void __init_verbose_buf ( void   )  [static]

Definition at line 233 of file logger.c.

00242 {

static void __init_verbosers ( void   )  [static]

Definition at line 982 of file logger.c.

00984 {

static void _handle_SIGXFSZ ( int  sig  )  [static]

Definition at line 991 of file logger.c.

00992 {
00993    /* Indicate need to reload */
00994    filesize_reload_needed = 1;
00995 }

void ast_backtrace ( void   ) 

Definition at line 1693 of file logger.c.

References ast_debug, ast_log(), free, and LOG_WARNING.

01694 {
01695 #ifdef HAVE_BKTR
01696    struct ast_bt *bt;
01697    int i = 0;
01698    char **strings;
01699 
01700    if (!(bt = ast_bt_create())) {
01701       ast_log(LOG_WARNING, "Unable to allocate space for backtrace structure\n");
01702       return;
01703    }
01704 
01705    if ((strings = ast_bt_get_symbols(bt->addresses, bt->num_frames))) {
01706       ast_debug(1, "Got %d backtrace record%c\n", bt->num_frames, bt->num_frames != 1 ? 's' : ' ');
01707       for (i = 3; i < bt->num_frames - 2; i++) {
01708          ast_debug(1, "#%d: [%p] %s\n", i - 3, bt->addresses[i], strings[i]);
01709       }
01710 
01711       /* MALLOC_DEBUG will erroneously report an error here, unless we undef the macro. */
01712 #undef free
01713       free(strings);
01714    } else {
01715       ast_debug(1, "Could not allocate memory for backtrace\n");
01716    }
01717    ast_bt_destroy(bt);
01718 #else
01719    ast_log(LOG_WARNING, "Must run configure with '--with-execinfo' for stack backtraces.\n");
01720 #endif /* defined(HAVE_BKTR) */
01721 }

void ast_callid_strnprint ( char *  buffer,
size_t  buffer_size,
struct ast_callid callid 
)

copy a string representation of the callid into a target string

Parameters:
buffer destination of callid string (should be able to store 13 characters or more)
buffer_size maximum writable length of the string (Less than 13 will result in truncation)
callid Callid for which string is being requested

Definition at line 1273 of file logger.c.

References ast_callid::call_identifier.

Referenced by ast_channel_callid_set(), handle_showchan(), and iax_pvt_callid_new().

01274 {
01275    snprintf(buffer, buffer_size, "[C-%08x]", callid->call_identifier);
01276 }

int ast_callid_threadassoc_add ( struct ast_callid callid  ) 

Adds a known callid to thread storage of the calling thread.

Return values:
0 - success
non-zero - failure

Definition at line 1308 of file logger.c.

References ast_callid_ref, ast_debug, ast_log(), ast_threadstorage_get(), ast_callid::call_identifier, LOG_ERROR, LOG_WARNING, and unique_callid.

Referenced by __analog_ss_thread(), __ast_pbx_run(), ast_callid_threadstorage_auto(), async_dial(), async_wait(), autoservice_run(), bridge_call_thread(), bridge_channel_thread(), bridge_thread(), handle_request_do(), jingle_action_hook(), jingle_outgoing_hook(), mixmonitor_thread(), and socket_process_helper().

01309 {
01310    struct ast_callid **pointing;
01311    pointing = ast_threadstorage_get(&unique_callid, sizeof(struct ast_callid **));
01312    if (!(pointing)) {
01313       ast_log(LOG_ERROR, "Failed to allocate thread storage.\n");
01314       return -1;
01315    }
01316 
01317    if (!(*pointing)) {
01318       /* callid will be unreffed at thread destruction */
01319       ast_callid_ref(callid);
01320       *pointing = callid;
01321       ast_debug(3, "CALL_ID [C-%08x] bound to thread.\n", callid->call_identifier);
01322    } else {
01323       ast_log(LOG_WARNING, "Attempted to ast_callid_threadassoc_add on thread already associated with a callid.\n");
01324       return 1;
01325    }
01326 
01327    return 0;
01328 }

int ast_callid_threadassoc_remove ( void   ) 

Removes callid from thread storage of the calling thread.

Return values:
0 - success
non-zero - failure

Definition at line 1330 of file logger.c.

References ast_callid_unref, ast_debug, ast_log(), ast_threadstorage_get(), LOG_ERROR, and unique_callid.

Referenced by ast_callid_threadstorage_auto_clean(), autoservice_run(), handle_request_do(), jingle_action_hook(), jingle_outgoing_hook(), and socket_process().

01331 {
01332    struct ast_callid **pointing;
01333    pointing = ast_threadstorage_get(&unique_callid, sizeof(struct ast_callid **));
01334    if (!(pointing)) {
01335       ast_log(LOG_ERROR, "Failed to allocate thread storage.\n");
01336       return -1;
01337    }
01338 
01339    if (!(*pointing)) {
01340       ast_log(LOG_ERROR, "Tried to clean callid thread storage with no callid in thread storage.\n");
01341       return -1;
01342    } else {
01343       ast_debug(3, "CALL_ID [C-%08x] being removed from thread.\n", (*pointing)->call_identifier);
01344       *pointing = ast_callid_unref(*pointing);
01345       return 0;
01346    }
01347 }

int ast_callid_threadstorage_auto ( struct ast_callid **  callid  ) 

Checks thread storage for a callid and stores a reference if it exists. If not, then a new one will be created, bound to the thread, and a reference to it will be stored.

Parameters:
callid pointer to struct pointer used to store the referenced callid
Return values:
0 - callid was found
1 - callid was created
-1 - the function failed somehow (presumably memory problems)

Definition at line 1349 of file logger.c.

References ast_callid_threadassoc_add(), ast_create_callid(), and ast_read_threadstorage_callid().

Referenced by __analog_handle_event(), analog_handle_init_event(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), dahdi_handle_event(), dahdi_request(), do_monitor(), handle_init_event(), mwi_thread(), and my_new_analog_ast_channel().

01350 {
01351    struct ast_callid *tmp;
01352 
01353    /* Start by trying to see if a callid is available from thread storage */
01354    tmp = ast_read_threadstorage_callid();
01355    if (tmp) {
01356       *callid = tmp;
01357       return 0;
01358    }
01359 
01360    /* If that failed, try to create a new one and bind it. */
01361    tmp = ast_create_callid();
01362    if (tmp) {
01363       ast_callid_threadassoc_add(tmp);
01364       *callid = tmp;
01365       return 1;
01366    }
01367 
01368    /* If neither worked, then something must have gone wrong. */
01369    return -1;
01370 }

void ast_callid_threadstorage_auto_clean ( struct ast_callid callid,
int  callid_created 
)

Use in conjunction with ast_callid_threadstorage_auto. Cleans up the references and if the callid was created by threadstorage_auto, unbinds the callid from the threadstorage.

Parameters:
callid The callid set by ast_callid_threadstorage_auto
callid_created The integer returned through ast_callid_threadstorage_auto

Definition at line 1372 of file logger.c.

References ast_callid_threadassoc_remove(), and ast_callid_unref.

Referenced by __analog_handle_event(), analog_handle_init_event(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), dahdi_handle_event(), dahdi_new_callid_clean(), dahdi_request(), do_monitor(), handle_init_event(), and mwi_thread().

01373 {
01374    if (callid) {
01375       /* If the callid was created rather than simply grabbed from the thread storage, we need to unbind here. */
01376       if (callid_created == 1) {
01377          ast_callid_threadassoc_remove();
01378       }
01379       callid = ast_callid_unref(callid);
01380    }
01381 }

void ast_child_verbose ( int  level,
const char *  fmt,
  ... 
)

Definition at line 472 of file logger.c.

References ast_free, and ast_malloc.

Referenced by launch_script().

00473 {
00474    char *msg = NULL, *emsg = NULL, *sptr, *eptr;
00475    va_list ap, aq;
00476    int size;
00477 
00478    va_start(ap, fmt);
00479    va_copy(aq, ap);
00480    if ((size = vsnprintf(msg, 0, fmt, ap)) < 0) {
00481       va_end(ap);
00482       va_end(aq);
00483       return;
00484    }
00485    va_end(ap);
00486 
00487    if (!(msg = ast_malloc(size + 1))) {
00488       va_end(aq);
00489       return;
00490    }
00491 
00492    vsnprintf(msg, size + 1, fmt, aq);
00493    va_end(aq);
00494 
00495    if (!(emsg = ast_malloc(size * 2 + 1))) {
00496       ast_free(msg);
00497       return;
00498    }
00499 
00500    for (sptr = msg, eptr = emsg; ; sptr++) {
00501       if (*sptr == '"') {
00502          *eptr++ = '\\';
00503       }
00504       *eptr++ = *sptr;
00505       if (*sptr == '\0') {
00506          break;
00507       }
00508    }
00509    ast_free(msg);
00510 
00511    fprintf(stdout, "verbose \"%s\" %d\n", emsg, level);
00512    fflush(stdout);
00513    ast_free(emsg);
00514 }

struct ast_callid* ast_create_callid ( void   )  [read]

factory function to create a new uniquely identifying callid.

Return values:
ast_callid struct pointer containing the call id
Note:
The newly created callid will be referenced upon creation and this function should be paired with a call to ast_callid_unref()

Definition at line 1278 of file logger.c.

References ao2_alloc, ast_atomic_fetchadd_int(), ast_debug, ast_log(), ast_callid::call_identifier, and LOG_ERROR.

Referenced by __ast_pbx_run(), ast_callid_threadstorage_auto(), find_call(), iax_pvt_callid_new(), and jingle_alloc().

01279 {
01280    struct ast_callid *call;
01281    int using;
01282 
01283    if (!(call = ao2_alloc(sizeof(struct ast_callid), NULL))) {
01284       ast_log(LOG_ERROR, "Could not allocate callid struct.\n");
01285       return NULL;
01286    }
01287 
01288    using = ast_atomic_fetchadd_int(&next_unique_callid, +1);
01289 
01290    call->call_identifier = using;
01291    ast_debug(3, "CALL_ID [C-%08x] created by thread.\n", call->call_identifier);
01292    return call;
01293 }

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 invoke it would be something like this: ast_log(AST_LOG_WHATEVER, "Problem with the %s Captain. We should get some more. Will %d be enough?\n", "flux capacitor", 10); where WHATEVER is one of ERROR, DEBUG, EVENT, NOTICE, or WARNING depending on which log you wish to output to. These are implemented as macros, that will provide the function with the needed arguments.

Parameters:
level Type of log event
file Will be provided by the AST_LOG_* macro
line Will be provided by the AST_LOG_* macro
function Will be provided by the AST_LOG_* macro
fmt This is what is important. The format is the same as your favorite breed of printf. You know how that works, right? :-)

Definition at line 1487 of file logger.c.

References ast_callid_unref, ast_log_full(), and ast_read_threadstorage_callid().

Referenced by __aco_option_register(), __adsi_transmit_messages(), __agent_start_monitoring(), __analog_handle_event(), __analog_ss_thread(), __ao2_global_obj_ref(), __ao2_global_obj_release(), __ao2_global_obj_replace(), __ao2_lock(), __ao2_trylock(), __ao2_unlock(), __ast_answer(), __ast_bridge_technology_register(), __ast_channel_alloc_ap(), __ast_channel_masquerade(), __ast_cli_register(), __ast_cli_unregister(), __ast_custom_function_register(), __ast_data_register(), __ast_data_unregister(), __ast_dsp_call_progress(), __ast_format_def_register(), __ast_http_load(), __ast_pbx_run(), __ast_play_and_record(), __ast_queue_frame(), __ast_read(), __ast_register_translator(), __ast_request_and_dial(), __ast_smoother_feed(), __ast_string_field_init(), __ast_udptl_reload(), __attempt_transmit(), __auto_congest(), __dahdi_exception(), __find_callno(), __iax2_poke_noanswer(), __init_manager(), __mgcp_xmit(), __oh323_destroy(), __oh323_new(), __oh323_rtp_create(), __oh323_update_info(), __rtp_recvfrom(), __set_address_from_contact(), __sip_autodestruct(), __sip_pretend_ack(), __sip_reliable_xmit(), __sip_xmit(), __transmit_response(), __unload_module(), _analog_get_index(), _ast_event_queue(), _ast_odbc_request_obj2(), _ast_sockaddr_from_sin(), _ast_sockaddr_port(), _ast_sockaddr_set_port(), _ast_sockaddr_to_sin(), _dahdi_get_index(), _dsp_init(), _enum_array_map(), _extension_match_core(), _lookup_timer(), _macro_exec(), _moh_register(), _pgsql_exec(), _sip_show_peers(), _sip_tcp_helper_thread(), _while_exec(), accept_thread(), access_counter_file(), acf_channel_read(), acf_curl_helper(), acf_curlopt_helper(), acf_curlopt_write(), acf_cut_exec(), acf_cut_exec2(), acf_faxopt_read(), acf_faxopt_write(), acf_iaxvar_write(), acf_if(), acf_isexten_exec(), acf_jabberreceive_read(), acf_jabberstatus_read(), acf_mailbox_exists(), acf_meetme_info(), acf_odbc_read(), acf_odbc_write(), acf_sort_exec(), acf_sprintf(), acf_strftime(), acf_strptime(), acf_transaction_write(), acf_vm_info(), ack_trans(), acl_change_event_cb(), aco_option_find(), aco_pending_config(), aco_process_ast_config(), aco_process_config(), aco_process_var(), aco_set_defaults(), action_bridge(), action_command(), action_getvar(), action_hangup(), action_kick_last(), action_playback(), action_playback_and_continue(), actual_load_config(), add_agent(), add_agi_cmd(), add_calltoken_ignore(), add_cc_call_info_to_response(), add_cfg_entry(), add_codec_to_answer(), add_content(), add_email_attachment(), add_event_to_list(), add_exten_to_pattern_tree(), add_extensions(), add_features_datastore(), add_header(), add_ie(), add_in_calls(), add_line(), add_message_id(), add_out_calls(), add_priority(), add_realm_authentication(), add_redirect(), add_rt_multi_cfg_entry(), add_sdp(), add_sip_domain(), add_static_payload(), add_to_agi(), add_user_extension(), add_vm_recipients_from_string(), adjust_lock(), admin_exec(), adsi_begin(), adsi_careful_send(), adsi_get_cpeid(), adsi_get_cpeinfo(), adsi_load_session(), adsi_process(), adsi_prog(), adsi_transmit_message_full(), advanced_options(), ael2_print(), aes_helper(), agent_answer(), agent_call(), agent_fixup(), agent_get_base_channel(), agent_indicate(), agent_new(), agent_read(), agent_request(), agent_set_base_channel(), agentmonitoroutgoing_exec(), agi_exec_full(), aji_act_hook(), aji_client_connect(), aji_client_info_handler(), aji_create_buddy(), aji_create_client(), aji_delete_node_list(), aji_dinfo_handler(), aji_ditems_handler(), aji_find_version(), aji_handle_message(), aji_handle_presence(), aji_handle_pubsub_error(), aji_handle_pubsub_event(), aji_handle_subscribe(), aji_initialize(), aji_join_exec(), aji_leave_exec(), aji_load_config(), aji_pruneregister(), aji_recv(), aji_recv_loop(), aji_register_approve_handler(), aji_register_query_handler(), aji_reload(), aji_send_exec(), aji_send_raw_chat(), aji_sendgroup_exec(), aji_set_group_presence(), aji_set_presence(), aji_start_sasl(), aji_status_exec(), alarmreceiver_exec(), alloc_expr_node(), alloc_resampler(), alloc_sub(), alsa_card_init(), alsa_indicate(), alsa_new(), alsa_read(), alsa_request(), alsa_write(), analog_answer(), analog_attempt_transfer(), analog_call(), analog_exception(), analog_handle_init_event(), analog_hangup(), analog_request(), analog_ss_thread(), analogsub_to_dahdisub(), answer_call(), anti_injection(), aoc_append_ie(), aoc_parse_ie(), app_exec(), append_ie(), append_mailbox(), append_row_to_cfg(), apply_general_options(), apply_option(), apply_options_full(), apply_outgoing(), aqm_exec(), ast_add_extension2_lockopt(), ast_add_hint(), ast_adsi_install_funcs(), ast_agi_register(), ast_agi_send(), ast_agi_unregister(), ast_aji_create_chat(), ast_aji_invite_chat(), ast_alaw_init(), ast_aoc_create(), ast_aoc_decode(), ast_aoc_encode(), ast_app_dtget(), ast_app_exec_macro(), ast_app_exec_sub(), ast_app_expand_sub_args(), ast_app_group_match_get_count(), ast_append_acl(), ast_append_ha(), ast_apply_acl(), ast_apply_ha(), ast_async_goto(), ast_autoservice_start(), ast_backtrace(), ast_best_codec(), ast_bridge_call(), ast_bridge_timelimit(), ast_calendar_register(), ast_call_forward(), ast_callid_threadassoc_add(), ast_callid_threadassoc_remove(), ast_careful_fwrite(), ast_carefulwrite(), ast_cc_get_param(), ast_cc_set_param(), ast_cdr_alloc(), ast_cdr_congestion(), ast_cdr_end(), ast_cdr_engine_init(), ast_cdr_merge(), ast_cdr_register(), ast_cdr_serialize_variables(), ast_cdr_setvar(), ast_cdr_submit_batch(), ast_cel_check_retire_linkedid(), ast_cel_fill_record(), ast_cel_get_ama_flag_name(), ast_cel_linkedid_ref(), ast_change_hint(), ast_channel_bridge(), ast_channel_by_exten_cb(), ast_channel_by_name_cb(), ast_channel_by_uniqueid_cb(), ast_channel_cmp_cb(), ast_channel_connected_line_macro(), ast_channel_hangupcause_hash_set(), ast_channel_internal_alert_read(), ast_channel_internal_alertpipe_init(), ast_channel_log(), ast_channel_make_compatible_helper(), ast_channel_queryoption(), ast_channel_redirecting_macro(), ast_channel_register(), ast_channel_setoption(), ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_check_signature(), ast_check_signature_bin(), ast_check_timing2(), ast_cli_perms_init(), ast_codec_get_len(), ast_codec_get_samples(), ast_codec_pref_getsize(), ast_config_engine_register(), ast_config_internal_load(), ast_connected_line_build_data(), ast_connected_line_parse_data(), ast_context_find_or_create(), ast_context_remove_extension_callerid2(), ast_context_verify_includes(), ast_create_callid(), ast_data_get(), ast_data_retrieve(), ast_db_del(), ast_db_deltree(), ast_db_gettree(), ast_db_put(), ast_decrypt_bin(), ast_device_state_engine_init(), ast_do_masquerade(), ast_do_pickup(), ast_dsp_call_progress(), ast_dsp_process(), ast_dsp_silence_noise_with_energy(), ast_dtmf_stream(), ast_duplicate_acl_list(), ast_el_read_char(), ast_enable_distributed_devstate(), ast_enable_packet_fragmentation(), ast_encrypt_bin(), ast_event_cb(), ast_event_check_subscriber(), ast_event_get_cached(), ast_event_get_ie_pltype(), ast_event_get_ie_type_name(), ast_event_get_type_name(), ast_event_new(), ast_event_subscribe_new(), ast_extension_close(), ast_fax_log(), ast_fax_state_to_str(), ast_find_ourip(), ast_format_attr_reg_interface(), ast_format_def_unregister(), ast_format_str_reduce(), ast_framehook_attach(), ast_func_read(), ast_func_read2(), ast_func_write(), ast_get_encoded_char(), ast_get_enum(), ast_get_group(), ast_handle_cc_control_frame(), ast_hangup(), ast_heap_create(), ast_http_send(), ast_iax2_new(), ast_include_new(), ast_indicate_data(), ast_io_remove(), ast_ivr_menu_run_internal(), ast_jb_put(), ast_linear_stream(), ast_lock_path_flock(), ast_lock_path_lockfile(), ast_logger_register_level(), ast_makesocket(), ast_manager_register_struct(), ast_module_reload(), ast_moh_files_next(), ast_monitor_change_fname(), ast_monitor_start(), ast_monitor_stop(), ast_msg_tech_register(), ast_msg_tech_unregister(), ast_named_acl_find(), ast_named_acl_reload(), ast_netsock_bind(), ast_netsock_bindaddr(), ast_odbc_direct_execute(), ast_odbc_find_table(), ast_odbc_prepare_and_execute(), ast_odbc_sanity_check(), ast_odbc_smart_execute(), ast_openstream_full(), ast_openvstream(), ast_ouraddrfor(), ast_parse_allow_disallow(), ast_parse_digest(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_pbx_run_app(), ast_pbx_run_args(), ast_pbx_start(), ast_pickup_call(), ast_pktccops_gate_alloc(), ast_playtones_start(), ast_presence_state_engine_init(), ast_presence_state_helper(), ast_process_pending_reloads(), ast_prod(), ast_pthread_create_detached_stack(), ast_pthread_create_stack(), ast_queue_cc_frame(), ast_read_image(), ast_read_textfile(), ast_readaudio_callback(), ast_readconfig(), ast_readfile(), ast_readvideo_callback(), ast_record_review(), ast_redirecting_build_data(), ast_redirecting_parse_data(), ast_register_application2(), ast_register_feature(), ast_register_switch(), ast_remotecontrol(), ast_request(), ast_rtcp_read(), ast_rtcp_write_rr(), ast_rtcp_write_sr(), ast_rtp_dtmf_begin(), ast_rtp_dtmf_continuation(), ast_rtp_dtmf_end_with_duration(), ast_rtp_engine_register2(), ast_rtp_glue_register2(), ast_rtp_instance_bridge(), ast_rtp_instance_early_bridge(), ast_rtp_instance_early_bridge_make_compatible(), ast_rtp_instance_new(), ast_rtp_new(), ast_rtp_raw_write(), ast_rtp_read(), ast_rtp_sendcng(), ast_rtp_write(), ast_safe_fork(), ast_safe_system(), ast_say_date_with_format_da(), ast_say_date_with_format_de(), ast_say_date_with_format_en(), ast_say_date_with_format_es(), ast_say_date_with_format_fr(), ast_say_date_with_format_gr(), ast_say_date_with_format_he(), ast_say_date_with_format_it(), ast_say_date_with_format_nl(), ast_say_date_with_format_pl(), ast_say_date_with_format_pt(), ast_say_date_with_format_th(), ast_say_date_with_format_vi(), ast_say_date_with_format_zh(), ast_say_number_full_pt(), ast_sched_del(), ast_sched_runq(), ast_sched_start_thread(), ast_search_dns(), ast_security_event_report(), ast_set_cc_callback_macro(), ast_set_cc_offer_timer(), ast_set_cc_recall_timer(), ast_set_ccbs_available_timer(), ast_set_ccnr_available_timer(), ast_set_priority(), ast_set_qos(), ast_sign_bin(), ast_sip_ouraddrfor(), ast_sipinfo_send(), ast_slinfactory_feed(), ast_smoother_read(), ast_sockaddr_hash(), ast_sockaddr_parse(), ast_sockaddr_resolve(), ast_sockaddr_split_hostport(), ast_sockaddr_stringify_fmt(), ast_speech_register(), ast_srtp_add_stream(), ast_srtp_change_source(), ast_srtp_policy_alloc(), ast_srtp_protect(), ast_srtp_unprotect(), ast_stopstream(), ast_str_substitute_variables_full(), ast_streamfile(), ast_taskprocessor_get(), ast_taskprocessor_name(), ast_taskprocessor_push(), ast_tcptls_client_create(), ast_tcptls_client_start(), ast_tcptls_close_session_file(), ast_tcptls_server_read(), ast_tcptls_server_root(), ast_tcptls_server_start(), ast_tcptls_server_write(), ast_tls_read_conf(), ast_tps_init(), ast_translate_path_steps(), ast_translator_build_path(), ast_tryconnect(), ast_udptl_bridge(), ast_udptl_new_with_bindaddr(), ast_udptl_proto_register(), ast_udptl_read(), ast_udptl_write(), ast_ulaw_init(), ast_unload_resource(), ast_unlock_path_lockfile(), ast_wait_for_output(), ast_waitfordigit_full(), ast_write(), ast_writefile(), ast_writestream(), ast_yyerror(), async_wait(), asyncgoto_exec(), attempt_thread(), attempt_transfer(), au_seek(), au_trunc(), auth_credentials(), auth_exec(), auth_http_callback(), authenticate(), authenticate_reply(), authenticate_verify(), autoservice_run(), background_detect_exec(), balance_stack(), base64_helper(), base_encode(), blr_ebl(), blr_txt(), bridge_array_add(), bridge_call_thread(), bridge_call_thread_launch(), bridge_exec(), bridge_make_compatible(), bridge_p2p_rtp_write(), build_alias(), build_calendar(), build_callno_limits(), build_cc_interfaces_chanvar(), build_channels(), build_conf(), build_device(), build_gateway(), build_mapping(), build_parkinglot(), build_peer(), build_regex(), build_route(), build_user(), builtin_atxfer(), builtin_automixmonitor(), builtin_automonitor(), builtin_blindtransfer(), bump_gains(), cache_get_callno_locked(), calc_metric(), calculate_far_max_ifp(), calculate_local_max_datagram(), caldav_add_event(), caldav_get_events_between(), caldav_load_calendar(), caldav_request(), caldav_write_event(), calendar_busy_exec(), calendar_devstate_change(), calendar_event_notify(), calendar_event_read(), calendar_join_attendees(), calendar_query_exec(), calendar_query_result_exec(), calendar_write_exec(), callerid_feed(), callerid_feed_jp(), callerid_get_dtmf(), callerid_read(), callerid_write(), callerpres_read(), callerpres_write(), canary_thread(), canmatch(), careful_write(), cb_events(), cc_available(), cc_caller_requested(), cc_handle_publish_error(), cccancel_exec(), cdata(), cdr_handler(), cdr_merge_vars(), celt_get_val(), celt_isset(), celt_set(), chan_misdn_log(), chan_ringing(), chanavail_exec(), channel_admin_exec(), channel_spy(), channel_to_session(), chanspy_exec(), check_abstract_reference(), check_access(), check_app_args(), check_auth(), check_break(), check_compat(), check_context_names(), check_continue(), check_day(), check_dow(), check_event_type(), check_expr2_input(), check_for_conference(), check_goto(), check_header(), check_header_fmt(), check_includes(), check_key(), check_label(), check_macro_returns(), check_month(), check_password(), check_post(), check_pval_item(), check_rtp_timeout(), check_srcaddr(), check_switch_expr(), check_timerange(), check_user_full(), check_vars(), check_via(), cleanup_connection(), cleanup_module(), clear_caller(), clear_dialed_interfaces(), clearcbone(), cleardisplay(), clearflag(), cleartimer(), cli_display_named_acl(), cli_fax_show_session(), close_call(), close_client(), close_mailbox(), commit_exec(), compile_script(), complete_dialplan_add_extension(), complete_dialplan_add_ignorepat(), complete_dialplan_add_include(), complete_dialplan_remove_context(), complete_dialplan_remove_extension(), complete_dialplan_remove_ignorepat(), complete_dialplan_remove_include(), complete_transfer(), compose_func_args(), compress_subclass(), conf_add(), conf_del(), conf_exec(), conf_flush(), conf_queue_dtmf(), conf_rec_name(), conf_run(), conf_start_record(), confbridge_exec(), config_curl(), config_device(), config_function_read(), config_handler(), config_ldap(), config_line(), config_load(), config_module(), config_odbc(), config_parse_variables(), config_pgsql(), config_text_file_load(), connectedline_read(), connectedline_write(), connection_made(), console_autoanswer(), console_cmd(), console_indicate(), console_request(), console_video_start(), context_merge(), controlplayback_exec(), cops_connect(), cops_gate_cmd(), cops_sendmsg(), copy(), copy_header(), copy_message(), copy_rules(), copy_to_voicemail(), copy_via_headers(), corosync_show_members(), count_exec(), count_lines(), cpg_deliver_cb(), create_addr(), create_dirpath(), create_dynamic_parkinglot(), create_jb(), create_match_char_tree(), create_new_socket(), create_queue_member(), create_video_frame(), create_vmaccount(), crement_function_read(), crypto_load(), csv_log(), csv_quote(), custom_celt_format(), custom_connection_handler(), custom_log(), custom_prepare(), custom_presence_callback(), custom_silk_format(), custom_transport_handler(), cut_internal(), dahdi_answer(), dahdi_bridge(), dahdi_call(), dahdi_callwait(), dahdi_confmute(), dahdi_decoder_framein(), dahdi_decoder_frameout(), dahdi_dial_str(), dahdi_disable_ec(), dahdi_enable_ec(), dahdi_encoder_framein(), dahdi_encoder_frameout(), dahdi_fake_event(), dahdi_func_write(), dahdi_handle_dtmf(), dahdi_handle_event(), dahdi_hangup(), dahdi_indicate(), dahdi_link(), dahdi_new(), dahdi_open(), dahdi_read(), dahdi_request(), dahdi_restart(), dahdi_ring_phone(), dahdi_sendtext(), dahdi_set_hook(), dahdi_setoption(), dahdi_show_channel(), dahdi_status_data_provider_get(), dahdi_test_timer(), dahdi_timer_set_rate(), dahdi_train_ec(), dahdi_translate(), dahdi_version_data_provider_get(), dahdi_write(), dahdi_write_frame(), dahdiras_exec(), dahdiscan_exec(), data_channels_provider_handler(), data_result_generate(), data_result_generate_node(), data_search_generate(), data_structure_compatible(), db_create_astdb(), db_execute_sql(), db_get_common(), db_open(), deadagi_exec(), dec_init(), DEFINE_SQL_STATEMENT(), del_exec(), delete_old_messages(), destroy_curl(), destroy_odbc(), destroy_pgsql(), destroy_pval_item(), destroy_trans(), determine_starting_point(), device2chan(), device_state_cb(), devstate_cache_cb(), devstate_change_collector_cb(), devstate_write(), dial_exec_full(), dial_handle_playtones(), dialgroup_read(), dialgroup_write(), dialog_initialize_dtls_srtp(), dialog_ref_debug(), dictate_exec(), digitcollect(), digitdirect(), directory_exec(), disa_exec(), disable_jack_hook(), disable_t38(), dispatch_thread_handler(), display_last_error(), display_nat_warning(), dns_parse_answer(), dnsmgr_init(), dnsmgr_refresh(), do_autokill(), do_forward(), do_magic_pickup(), do_message(), do_message_auth(), do_monitor(), do_notify(), do_pktccops(), do_register(), do_reload(), do_say(), do_waiting(), dump_queue(), dump_queue_members(), dumpsub(), dundi_answer_entity(), dundi_answer_query(), dundi_discover(), dundi_encrypt(), dundi_error_output(), dundi_exec(), dundi_helper(), dundi_lookup_internal(), dundi_precache_full(), dundi_precache_internal(), dundi_prop_precache(), dundi_query(), dundi_query_read(), dundi_result_read(), dundi_rexmit(), dundi_send(), dundi_xmit(), dundifunc_read(), duplicate_pseudo(), eagi_exec(), ebl_callback(), enable_jack_hook(), encode_open_type(), endelm(), enum_callback(), enum_query_read(), enum_result_read(), ewscal_load_calendar(), exchangecal_get_events_between(), exchangecal_load_calendar(), exchangecal_request(), exchangecal_write_event(), exec(), exec_exec(), execif_exec(), exists(), expand_gosub_args(), ext_cmp1(), extension_matches(), extenspy_exec(), external_rtp_create(), extstate_read(), fax_detect_attach(), fax_detect_framehook(), fax_gateway_detect_t38(), fax_gateway_framehook(), fax_gateway_new(), fax_gateway_request_t38(), fax_gateway_start(), fax_generator_generate(), fax_rate_str_to_int(), fax_session_new(), fax_session_reserve(), fbuf_append(), feature_exec_app(), feature_read(), feature_request_and_dial(), feature_write(), featuremap_read(), featuremap_write(), festival_exec(), fetch_icalendar(), ffmpeg_decode(), ffmpeg_encode(), file2format(), file_read(), file_write(), filehelper(), filename_parse(), filestream_close(), filter(), finalize_content(), find_account(), find_cache(), find_call_locked(), find_conf(), find_conf_realtime(), find_desc(), find_details(), find_engine(), find_line_by_instance(), find_line_by_name(), find_matching_endwhile(), find_option_cb(), find_or_create(), find_or_create_details(), find_pval_goto_item(), find_queue_by_name_rt(), find_sdp(), find_speeddial_by_instance(), find_subchannel_and_lock(), find_subchannel_by_instance_reference(), find_subchannel_by_name(), find_subchannel_by_reference(), find_table(), find_transaction(), find_transcoders(), findmeexec(), finish_bookmark(), flash_exec(), fn_wrapper(), forkcdr_exec(), format_set_helper(), forward_message(), framein(), func_args(), func_channel_read(), func_channel_write_real(), func_channels_read(), func_check_sipdomain(), func_confbridge_info(), func_header_read(), func_inheritance_write(), function_agent(), function_amiclient(), function_db_delete(), function_db_exists(), function_db_read(), function_db_write(), function_enum(), function_eval(), function_eval2(), function_fieldnum_helper(), function_realtime_read(), function_realtime_readdestroy(), function_realtime_store(), function_realtime_write(), function_sipchaninfo_read(), function_sippeer(), function_txtcidname(), g719read(), g719seek(), g719trunc(), g719write(), g723_len(), g723_read(), g723_trunc(), g723_write(), g726_read(), g726_write(), g729_read(), g729_trunc(), g729_write(), generate_computational_cost(), generic_execute(), generic_fax_exec(), generic_http_callback(), generic_prepare(), generic_read(), generic_write(), get_agi_cmd(), get_alarms(), get_also_info(), get_button_template(), get_calleridname(), get_canmatch_exten(), get_comma(), get_crypto_attrib(), get_destination(), get_domain(), get_ewscal_ids_for(), get_in_brackets_full(), get_input(), get_ip_and_port_from_sdp(), get_lock(), get_member_penalty(), get_name_and_number(), get_params(), get_pattern_node(), get_range(), get_rdnis(), get_refer_info(), get_timerange(), get_to_address(), get_token(), get_unused_callno(), getdisplaybyname(), getflagbyname(), getkeybyname(), getstatebyname(), getsubbyname(), gosub_exec(), gosub_run(), gosubif_exec(), goto_exten(), goto_line(), goto_line_rel(), group_count_function_read(), group_function_write(), gsm_read(), gsm_seek(), gsm_tell(), gsm_trunc(), gsm_write(), gsmtolin_framein(), gtalk_alloc(), gtalk_call(), gtalk_create_candidates(), gtalk_create_member(), gtalk_free_pvt(), gtalk_handle_dtmf(), gtalk_hangup_farend(), gtalk_invite(), gtalk_is_accepted(), gtalk_is_answered(), gtalk_load_config(), gtalk_new(), gtalk_newcall(), gtalk_parser(), gtalk_request(), gtalk_sendhtml(), gtalk_sendtext(), gtalk_show_channels(), gtalk_update_externip(), gtalk_update_stun(), gtalk_write(), h261_decap(), h263_decap(), h263_encap(), h263_open(), h263_read(), h263_trunc(), h263_write(), h263p_decap(), h263p_encap(), h264_decap(), h264_encap(), h264_open(), h264_read(), h264_trunc(), h264_write(), handle_alarms(), handle_call_incoming(), handle_call_outgoing(), handle_call_token(), handle_callforward_button(), handle_capabilities_res_message(), handle_cc_subscribe(), handle_clear_alarms(), handle_cli_database_show(), handle_cli_database_showkey(), handle_cli_h323_cycle_gk(), handle_cli_indication_add(), handle_cli_indication_remove(), handle_cli_presencestate_list(), handle_command_response(), handle_common_options(), handle_devstate_change(), handle_enbloc_call_message(), handle_error(), handle_event(), handle_exec(), handle_getoption(), handle_gosub(), handle_hd_hf(), handle_incoming(), handle_init_event(), handle_input(), handle_invite_replaces(), handle_jack_audio(), handle_keypad_button_message(), handle_message(), handle_missing_column(), handle_offhook_message(), handle_open_receive_channel_ack_message(), handle_options(), handle_playtones(), handle_recordfile(), handle_request(), handle_request_bye(), handle_request_info(), handle_request_invite(), handle_request_notify(), handle_request_options(), handle_request_publish(), handle_request_register(), handle_request_subscribe(), handle_response(), handle_response_info(), handle_response_invite(), handle_response_message(), handle_response_notify(), handle_response_peerpoke(), handle_response_publish(), handle_response_refer(), handle_response_register(), handle_response_subscribe(), handle_response_update(), handle_soft_key_event_message(), handle_stimulus_message(), handle_t38_options(), handle_tcptls_connection(), handle_transfer_button(), handle_updates(), hangupcause_read(), hash_ao2_destroy(), hint_read(), http_post_callback(), iax2_ack_registry(), iax2_bridge(), iax2_call(), iax2_canmatch(), iax2_devicestate(), iax2_do_register(), iax2_dup_variable_datastore(), iax2_exec(), iax2_exists(), iax2_fixup(), iax2_hangup(), iax2_matchmore(), iax2_poke_peer(), iax2_prov_app(), iax2_register(), iax2_request(), iax2_send(), iax2_trunk_queue(), iax_error_output(), iax_frame_wrap(), iax_park_thread(), iax_process_template(), iax_provision_reload(), iax_provision_version(), iax_pvt_callid_new(), iax_template_parse(), ical_load_calendar(), icalendar_add_event(), icalendar_update_events(), ices_exec(), icesencode(), iconv_read(), iftime(), ilbc_read(), ilbc_trunc(), ilbc_write(), ilbctolin_framein(), import_ch(), in_band_indication(), increase_call_count(), init_acf_query(), init_app_class(), init_jack_data(), init_req(), init_resp(), init_timing_thread(), initialize_cc_devstate_map(), initialize_cc_max_requests(), initialize_udptl(), inprocess_count(), insert_penaltychange(), inspect_module(), int_handler_fn(), internal_aco_type_find(), internal_ao2_alloc(), internal_ao2_ref(), INTERNAL_OBJ(), invent_message(), is_valid_dtmf(), isAnsweringMachine(), isexten_function_read(), ivr_dispatch(), jack_hook_callback(), jack_hook_write(), jb_error_output(), jb_framedata_init(), jb_get_and_deliver(), jb_warning_output(), jingle_action_hook(), jingle_action_session_initiate(), jingle_add_google_candidates_to_transport(), jingle_add_ice_udp_candidates_to_transport(), jingle_alloc(), jingle_call(), jingle_create_candidates(), jingle_create_member(), jingle_digit(), jingle_free_pvt(), jingle_handle_dtmf(), jingle_hangup_farend(), jingle_indicate(), jingle_interpret_content(), jingle_interpret_description(), jingle_interpret_google_transport(), jingle_interpret_ice_udp_transport(), jingle_is_answered(), jingle_load_config(), jingle_new(), jingle_newcall(), jingle_parser(), jingle_request(), jingle_send_error_response(), jingle_send_response(), jingle_send_session_action(), jingle_send_session_info(), jingle_send_session_terminate(), jingle_send_transport_info(), jingle_sendhtml(), jingle_sendtext(), jingle_show_channels(), jingle_write(), join_conference_bridge(), join_queue(), jpeg_read_image(), jpeg_write_image(), key_call(), key_favorite(), kqueue_timer_open(), launch_asyncagi(), launch_ha_netscript(), launch_monitor_thread(), launch_netscript(), launch_script(), launch_service(), ldap_loadentry(), ldap_reconnect(), leave_voicemail(), linear_alloc(), linear_generator(), linear_release(), link_option_to_types(), lintogsm_framein(), lintolpc10_framein(), lintoulaw(), listener(), listfilter(), load_column_config(), load_config(), load_config_meetme(), load_format_config(), load_general_config(), load_indications(), load_module(), load_modules(), load_moh_classes(), load_odbc_config(), load_or_reload_lua_stuff(), load_pbx(), load_pktccops_config(), load_resource(), load_resource_list(), load_tech_calendars(), load_values_config(), local_alloc(), local_answer(), local_ast_moh_cleanup(), local_ast_moh_start(), local_call(), local_devicestate(), local_fixup(), local_new(), local_setoption(), local_write(), log_exec(), log_jack_status(), logger_queue_init(), logger_queue_restart(), login_exec(), lookup_iface(), lpc10tolin_framein(), lua_find_extension(), lua_get_state(), macroif_exec(), main(), make_email_file(), make_number(), make_str(), make_trunk(), manage_parked_call(), manage_parkinglot(), manager_log(), manager_show_dialplan_helper(), manager_sipnotify(), map_video_codec(), masq_park_call(), matchmore(), math(), md5(), measurenoise(), meetmemute(), memcpy_decrypt(), memcpy_encrypt(), message_template_build(), message_template_parse_emailbody(), message_template_parse_filebody(), mgcp_call(), mgcp_fixup(), mgcp_indicate(), mgcp_new(), mgcp_reload(), mgcp_request(), mgcp_rtp_read(), mgcp_senddigit_begin(), mgcp_senddigit_end(), mgcp_ss(), mgcp_write(), mgcpsock_read(), milliwatt_generate(), minivm_accmess_exec(), minivm_account_func_read(), minivm_counter_func_read(), minivm_counter_func_write(), minivm_delete_exec(), minivm_greet_exec(), minivm_mwi_exec(), minivm_notify_exec(), minivm_record_exec(), misdn_answer(), misdn_bridge(), misdn_call(), misdn_cfg_get(), misdn_cfg_get_config_string(), misdn_cfg_init(), misdn_cfg_is_msn_valid(), misdn_cfg_update_ptp(), misdn_check_l2l1(), misdn_digit_end(), misdn_facility_exec(), misdn_hangup(), misdn_indication(), misdn_new(), misdn_request(), misdn_send_text(), misdn_set_opt_exec(), misdn_write(), mixmonitor_exec(), mixmonitor_save_prep(), mixmonitor_thread(), mkif(), mkintf(), moh_alloc(), moh_class_destructor(), moh_files_alloc(), moh_files_generator(), moh_files_release(), moh_generate(), moh_release(), moh_scan_files(), mohalloc(), monmp3thread(), morsecode_exec(), mp3_exec(), mp3play(), mpeg4_decode(), msg_create_from_file(), msg_data_func_read(), msg_func_read(), msg_func_write(), msg_send_cb(), msg_send_exec(), mssql_connect(), multicast_rtp_write(), multicast_send_control_packet(), multiplexed_bridge_create(), multiplexed_nudge(), multiplexed_thread_function(), mute_add_audiohook(), mute_fragment(), mwi_send_init(), mwi_send_process_buffer(), mwi_send_process_event(), mwi_sub_event_cb(), mwi_thread(), mwi_unsub_event_cb(), my_all_subchannels_hungup(), my_callwait(), my_dial_digits(), my_distinctive_ring(), my_dsp_set_digitmode(), my_get_callerid(), my_handle_dtmf(), my_handle_notify_message(), my_is_off_hook(), my_send_callerid(), my_set_cadence(), my_start_cid_detect(), my_wink(), named_acl_find_realtime(), nbs_alloc(), nbs_call(), nbs_hangup(), nbs_new(), nbs_request(), nbs_xwrite(), NBScat_exec(), NBScatplay(), netconsole(), new_find_extension(), new_realtime_sqlite3_db(), notify_daemon(), notify_new_message(), odbc_load_module(), odbc_log(), odbc_obj_connect(), odbc_obj_disconnect(), odbc_register_class(), odbc_release_obj2(), ogg_vorbis_open(), ogg_vorbis_read(), ogg_vorbis_rewrite(), ogg_vorbis_seek(), ogg_vorbis_trunc(), ogg_vorbis_write(), oh323_alloc(), oh323_call(), oh323_digit_begin(), oh323_digit_end(), oh323_fixup(), oh323_hangup(), oh323_indicate(), oh323_read(), oh323_request(), oh323_rtp_read(), oh323_set_rtp_peer(), oh323_write(), old_milliwatt_exec(), onevent(), op_colon(), op_div(), op_eq(), op_eqtilde(), op_func(), op_minus(), op_negate(), op_plus(), op_rem(), op_times(), open_history(), open_mailbox(), open_stream(), originate_exec(), osp_auth(), osp_check_destination(), osp_create_callid(), osp_create_provider(), osp_create_transaction(), osp_create_uuid(), osp_load(), osp_lookup(), osp_next(), osp_uuid2str(), osp_validate_token(), osplookup_exec(), ospnext_exec(), oss_indicate(), oss_new(), oss_request(), page_exec(), park_call_exec(), park_call_full(), park_space_reserve(), parkandannounce_exec(), parked_call_exec(), parkinglot_activate(), parkinglot_activate_cb(), parkinglot_config_read(), parkinglot_is_marked_cb(), parse(), parse_apps(), parse_args(), parse_bookmark(), parse_buffers_policy(), parse_busy_pattern(), parse_config(), parse_data(), parse_empty_options(), parse_events(), parse_gain_value(), parse_ie(), parse_minse(), parse_moved_contact(), parse_naptr(), parse_options(), parse_register_contact(), parse_request(), parse_session_expires(), parse_srv(), parse_tag(), parse_tone_zone(), parse_via(), parsing(), party_id_build_data(), party_id_write(), party_name_build_data(), party_name_write(), party_number_build_data(), party_number_write(), party_subaddress_build_data(), pbx_builtin_background(), pbx_builtin_execiftime(), pbx_builtin_gotoif(), pbx_builtin_gotoiftime(), pbx_builtin_hangup(), pbx_builtin_importvar(), pbx_builtin_pushvar_helper(), pbx_builtin_saynumber(), pbx_builtin_serialize_variables(), pbx_builtin_setvar(), pbx_builtin_setvar_multiple(), pbx_builtin_waitexten(), pbx_exec(), pbx_extension_helper(), pbx_find_extension(), pbx_load_config(), pbx_load_module(), pbx_load_users(), pbx_parseable_goto(), pbx_substitute_variables_helper_full(), pcm_read(), pcm_seek(), pcm_trunc(), pcm_write(), peek_read(), peer_iphash_cb(), peer_set_srcaddr(), peercnt_add(), pgsql_exec(), pgsql_log(), pgsql_reconnect(), phase_e_handler(), phone_call(), phone_digit_end(), phone_exception(), phone_hangup(), phone_indicate(), phone_mini_packet(), phone_new(), phone_read(), phone_request(), phone_setup(), phone_write(), phone_write_buf(), phoneprov_callback(), pickup_by_exten(), pickup_by_group(), pickup_exec(), pickupchan_exec(), pitchshift_helper(), pj_thread_register_check(), pktccops_add_ippool(), play_message(), play_message_by_id(), play_message_by_id_helper(), play_message_category(), play_message_datetime(), play_message_on_chan(), play_moh_exec(), play_record_review(), play_sound_helper(), playback_exec(), playtones_alloc(), playtones_generator(), policy_set_suite(), pop_exec(), post_raw(), pp_each_extension_helper(), pqm_exec(), precache_trans(), precache_transactions(), prep_email_sub_vars(), presence_read(), presence_state_cb(), presence_write(), privacy_exec(), private_enum_init(), proc_422_rsp(), proc_session_timer(), process_applicationmap_line(), process_ast_dsp(), process_category(), process_cn_rfc3389(), process_config(), process_crypto(), process_dahdi(), process_echocancel(), process_message_callback(), process_opcode(), process_output(), process_request(), process_returncode(), process_sdp(), process_sdp_a_audio(), process_sdp_a_dtls(), process_sdp_c(), process_sdp_o(), process_text_line(), process_via(), profile_set_param(), progress(), proxy_from_config(), proxy_update(), pthread_timer_set_rate(), purge_old_messages(), push_acl_change_event(), pvalCheckType(), pvalGlobalsAddStatement(), pvalTopLevAddObject(), pw_cb(), ql_exec(), queue_exec(), queue_function_exists(), queue_function_mem_read(), queue_function_mem_write(), queue_function_memberpenalty_read(), queue_function_memberpenalty_write(), queue_function_qac_dep(), queue_function_queuememberlist(), queue_function_queuewaitingcount(), queue_function_var(), queue_reload_request(), queue_set_param(), queue_transfer_fixup(), queue_voice_frame(), quote(), radius_log(), rcv_mac_addr(), rcvfax_exec(), read_agent_config(), read_config(), read_config_maps(), read_exec(), read_password_from_file(), read_pipe(), readexten_exec(), readfile_exec(), readmimefile(), realtime_curl(), realtime_destroy_handler(), realtime_directory(), realtime_exec(), realtime_handler(), realtime_ldap_base_ap(), realtime_multi_curl(), realtime_multi_handler(), realtime_multi_ldap(), realtime_multi_odbc(), realtime_multi_pgsql(), realtime_odbc(), realtime_peer(), realtime_peer_by_addr(), realtime_peer_get_sippeer_helper(), realtime_pgsql(), realtime_require_handler(), realtime_sqlite3_destroy(), realtime_sqlite3_execute(), realtime_sqlite3_execute_handle(), realtime_sqlite3_helper(), realtime_sqlite3_load(), realtime_sqlite3_require(), realtime_sqlite3_store(), realtime_sqlite3_update(), realtime_sqlite3_update2(), realtime_store_handler(), realtime_update2_handler(), realtime_update_handler(), realtime_user(), realtimefield_read(), receive_digit(), receive_message(), receivefax_exec(), receivefax_t38_init(), record_exec(), record_thread(), redirecting_read(), redirecting_reason_build_data(), redirecting_write(), refresh_list(), reg_source_db(), regex(), register_exten(), register_group(), register_group_feature(), register_peer_exten(), register_realtime_peers_with_callbackextens(), register_verify(), registry_rerequest(), reload(), reload_config(), reload_firmware(), reload_followme(), reload_module(), reload_queue_members(), reload_queue_rules(), reload_queues(), reload_single_member(), reload_single_queue(), remote_bridge_loop(), remove_by_peercallno(), remove_by_transfercallno(), remove_from_queue(), removed_options_handler(), replace(), replace_callno(), reply_digest(), require_curl(), require_odbc(), require_pgsql(), res_srtp_init(), res_srtp_new(), reset_conf(), resolve_first(), respprep(), restart_monitor(), restart_pktc_thread(), restart_session_timer(), restore_conference(), restore_gains(), retrans_pkt(), retrydial_exec(), return_exec(), revert_fax_buffers(), ring_entry(), rollback_exec(), rotate_file(), rqm_exec(), rt_handle_member_record(), rtp_reload(), run_agi(), run_externnotify(), run_ras(), s_streamwait3(), safe_append(), save_conference(), save_to_folder(), say_date(), say_date_with_format(), say_datetime(), say_datetime_from_now(), say_init_mode(), say_number_full(), say_time(), saycountedadj_exec(), saycountednoun_exec(), scan_service(), scan_thread(), schedule(), sdp_crypto_activate(), sdp_crypto_process(), sdp_crypto_setup(), select_entry(), send_callerid(), send_client(), send_delay(), send_dtmf(), send_ews_request_and_parse(), send_request(), send_retransmit(), send_select_output(), send_start_rtp(), send_text(), send_waveform_to_channel(), send_waveform_to_fd(), senddtmf_exec(), sendfax_exec(), sendfax_t38_init(), sendimage_exec(), sendmail(), sendpage(), sendtext_exec(), sendurl_exec(), session_do(), set(), set_active(), set_bridge_features_on_config(), set_config(), set_crypto_policy(), set_destination(), set_fax_t38_caps(), set_format(), set_full_cmd(), set_insecure_flags(), set_member_paused(), set_member_value(), set_member_value_help_members(), set_moh_exec(), set_state(), set_ulimit(), set_var(), setcallerid_pres_exec(), setflag(), setformat(), setsubstate(), setup_dahdi_int(), setup_incoming_call(), setup_mixmonitor_ds(), setup_privacy_args(), setup_rtp_connection(), setup_srtp(), setup_stunaddr(), setup_transfer_datastore(), sha1(), shared_read(), shared_write(), shell_helper(), shift_pop(), show_chanstats_cb(), show_dialplan_helper(), showdisplay(), showkeys(), silk_get_val(), silk_isset(), silk_set(), sip_acf_channel_read(), sip_addheader(), sip_call(), sip_cc_monitor_suspend(), sip_check_authtimeout(), sip_cli_notify(), sip_dtmfmode(), sip_dump_history(), sip_fixup(), sip_hangup(), sip_indicate(), sip_msg_send(), sip_new(), sip_parse_host(), sip_parse_nat_option(), sip_parse_register_line(), sip_poke_noanswer(), sip_poke_peer(), sip_queryoption(), sip_read(), sip_reg_timeout(), sip_register(), sip_request_call(), sip_reregister(), sip_scheddestroy(), sip_send_keepalive(), sip_sendhtml(), sip_setoption(), sip_sipredirect(), sip_st_alloc(), sip_subscribe_mwi(), sip_tcptls_write(), sip_threadinfo_create(), sip_write(), sipsock_read(), siren14read(), siren14seek(), siren14trunc(), siren14write(), siren7read(), siren7seek(), siren7trunc(), siren7write(), skel_exec(), skinny_call(), skinny_extensionstate_cb(), skinny_fixup(), skinny_indicate(), skinny_new(), skinny_newcall(), skinny_register(), skinny_req_parse(), skinny_request(), skinny_ss(), skinny_transfer(), skinny_write(), sla_add_trunk_to_station(), sla_build_station(), sla_build_trunk(), sla_load_config(), sla_queue_event_conf(), sla_state(), sla_station_exec(), sla_trunk_exec(), slinear_seek(), slinear_trunc(), smdi_load(), smdi_msg_read(), smdi_msg_retrieve_read(), smdi_read(), smdi_toggle_mwi(), smoother_frame_feed(), sms_exec(), sms_generate(), sms_handleincoming(), sms_log(), sms_messagerx2(), sms_process(), sms_readfile(), sms_writefile(), sndfax_exec(), socket_process_helper(), socket_process_meta(), socket_read(), softhangup_exec(), softmix_bridge_thread(), softmix_mixing_array_grow(), softmix_mixing_array_init(), soundcard_init(), soundcard_writeframe(), span_message(), spandsp_fax_new(), spandsp_fax_start(), spandsp_fax_write(), spandsp_log(), spandsp_modems(), spawn_dp_lookup(), spawn_mp3(), speex_get_wb_sz_at(), speex_read(), speex_samples(), speex_write(), speextolin_framein(), spy_generate(), sqlite_log(), srv_datastore_setup(), srv_query_read(), srv_result_read(), ssl_verify(), stackpeek_read(), start_conf_record_thread(), start_moh_exec(), start_monitor_exec(), start_network_thread(), start_poll_thread(), start_rtp(), start_session_timer(), start_spying(), start_stream(), startelm(), starttimer(), static_realtime_cb(), stop_session_timer(), store_boost(), store_by_peercallno(), store_by_transfercallno(), store_config(), store_config_core(), store_curl(), store_digit(), store_mixer(), store_odbc(), store_pgsql(), store_tone_zone_ring_cadence(), str_to_agent_policy(), str_to_monitor_policy(), strreplace(), stun_monitor_request(), stun_start_monitor(), stun_stop_monitor(), sub_start_silence(), sub_stop_silence(), subscript(), substitute_escapes(), swap_subs(), sysinfo_helper(), syslog_log(), system_exec_helper(), t38_tx_packet_handler(), tdd_feed(), tdd_new(), tds_error_handler(), tds_load_module(), tds_log(), tds_message_handler(), testclient_exec(), testserver_exec(), timed_read(), timeout_read(), timeout_write(), timerfd_timer_ack(), timerfd_timer_close(), timerfd_timer_disable_continuous(), timerfd_timer_enable_continuous(), timerfd_timer_get_event(), timerfd_timer_open(), timerfd_timer_set_rate(), timezone_add(), to_number(), to_string(), tonepair_alloc(), tonepair_generator(), tps_processing_function(), tps_taskprocessor_destroy(), tps_taskprocessor_pop(), transfer_call_step1(), transfer_cancel_step2(), transfer_exec(), transmit(), transmit_audio(), transmit_cc_notify(), transmit_invite(), transmit_refer(), transmit_register(), transmit_request_with_auth(), transmit_response_bysession(), transmit_response_using_temp(), transmit_response_with_auth(), transmit_response_with_sdp(), transmit_response_with_t38_sdp(), transmit_state_notify(), transmit_t38(), try_calling(), try_firmware(), try_load_key(), try_suggested_sip_codec(), try_transfer(), tryexec_exec(), tvfix(), txt_callback(), udptl_pre_apply_config(), uint_handler_fn(), unalloc_sub(), unistim_answer(), unistim_call(), unistim_do_senddigit(), unistim_fixup(), unistim_indicate(), unistim_new(), unistim_request(), unistim_rtp_read(), unistim_senddigit_end(), unistim_sendtext(), unistim_ss(), unistim_write(), unistimsock_read(), unload_module(), unlock_read(), unregister_exten(), unshift_push(), update2_curl(), update2_ldap(), update2_odbc(), update2_pgsql(), update2_prepare(), update_call_counter(), update_common_options(), update_config(), update_curl(), update_header(), update_key(), update_ldap(), update_modem_bits(), update_odbc(), update_pgsql(), update_registry(), update_scoreboard(), update_stats(), upqm_exec(), uridecode(), uriencode(), usage_context_add_ramp(), usage_context_add_spaces(), used_blocks(), userevent_exec(), ustmtext(), verbose_exec(), vm_authenticate(), vm_box_exists(), vm_change_password(), vm_check_password_shell(), vm_exec(), vm_execmain(), vm_intro(), vm_mailbox_snapshot_create(), vm_msg_forward(), vm_msg_move(), vm_msg_play(), vm_msg_remove(), vm_msg_snapshot_create(), vm_newuser(), vm_options(), vmsayname_exec(), volume_write(), vox_read(), vox_seek(), vox_trunc(), vox_write(), wait_file(), wait_file2(), wait_for_answer(), wait_for_winner(), wait_moh_exec(), waitfor_exec(), waitforring_exec(), waitstream_core(), waituntil_exec(), wav_close(), wav_read(), wav_seek(), wav_trunc(), wav_write(), websocket_callback(), write_byte(), write_cdr(), write_header(), write_history(), write_password_to_file(), write_stream(), writefile(), xmpp_action_hook(), xmpp_client_alloc(), xmpp_client_authenticate_digest(), xmpp_client_authenticate_sasl(), xmpp_client_authenticating(), xmpp_client_config_post_apply(), xmpp_client_receive(), xmpp_client_reconnect(), xmpp_client_request_tls(), xmpp_client_requested_tls(), xmpp_client_service_discovery_get_hook(), xmpp_client_set_presence(), xmpp_client_subscribe_user(), xmpp_client_thread(), xmpp_client_unsubscribe_user(), xmpp_component_authenticate(), xmpp_component_authenticating(), xmpp_component_register_get_hook(), xmpp_component_register_set_hook(), xmpp_component_service_discovery_get_hook(), xmpp_component_service_discovery_items_hook(), xmpp_config_prelink(), xmpp_connect_hook(), xmpp_join_exec(), xmpp_leave_exec(), xmpp_pak_presence(), xmpp_pak_s10n(), xmpp_pubsub_create_affiliations(), xmpp_pubsub_delete_node_list(), xmpp_pubsub_handle_error(), xmpp_pubsub_handle_event(), xmpp_pubsub_request_nodes(), xmpp_pubsub_subscribe(), xmpp_pubsub_unsubscribe(), xmpp_roster_hook(), xmpp_send_cb(), xmpp_send_exec(), xmpp_sendgroup_exec(), xmpp_status_exec(), yyerror(), and yyparse().

01488 {
01489    struct ast_callid *callid;
01490    va_list ap;
01491 
01492    callid = ast_read_threadstorage_callid();
01493 
01494    va_start(ap, fmt);
01495    ast_log_full(level, file, line, function, callid, fmt, ap);
01496    va_end(ap);
01497 
01498    if (callid) {
01499       ast_callid_unref(callid);
01500    }
01501 }

void ast_log_callid ( int  level,
const char *  file,
int  line,
const char *  function,
struct 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 functionally identical to the above logger function, it just include a call_id argument as well. If NULL is specified here, no attempt will be made to join the log message with a call_id.

Parameters:
level Type of log event
file Will be provided by the AST_LOG_* macro
line Will be provided by the AST_LOG_* macro
function Will be provided by the AST_LOG_* macro
callid This is the ast_callid that is associated with the log message. May be NULL.
fmt This is what is important. The format is the same as your favorite breed of printf. You know how that works, right? :-)

Definition at line 1503 of file logger.c.

References ast_log_full().

Referenced by __ast_verbose_ap(), and ast_channel_destructor().

01504 {
01505    va_list ap;
01506    va_start(ap, fmt);
01507    ast_log_full(level, file, line, function, callid, fmt, ap);
01508    va_end(ap);
01509 }

static void ast_log_full ( int  level,
const char *  file,
int  line,
const char *  function,
struct ast_callid callid,
const char *  fmt,
va_list  ap 
) [static]

send log messages to syslog and/or the console

Definition at line 1401 of file logger.c.

References __LOG_VERBOSE, ast_callid_ref, ast_calloc_with_stringfields, ast_cond_signal, AST_DYNSTR_BUILD_FAILED, ast_free, ast_get_tid(), AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_localtime(), AST_PTHREADT_NULL, AST_RWLIST_EMPTY, ast_str_buffer(), ast_str_set_va(), ast_str_thread_get(), ast_strftime(), ast_string_field_set, ast_tvnow(), logmsg::callid, close_logger_thread, logmsg::level, levels, logmsg::line, logchannel::list, log_buf, LOG_BUF_INIT_SIZE, logcond, logger_print_normal(), logmsg_free(), LOGMSG_NORMAL, LOGMSG_VERBOSE, logthread, logmsg::lwp, term_filter_escapes(), and logmsg::type.

Referenced by ast_log(), and ast_log_callid().

01402 {
01403    struct logmsg *logmsg = NULL;
01404    struct ast_str *buf = NULL;
01405    struct ast_tm tm;
01406    struct timeval now = ast_tvnow();
01407    int res = 0;
01408    char datestring[256];
01409 
01410    if (!(buf = ast_str_thread_get(&log_buf, LOG_BUF_INIT_SIZE)))
01411       return;
01412 
01413    if (level != __LOG_VERBOSE && AST_RWLIST_EMPTY(&logchannels)) {
01414       /*
01415        * we don't have the logger chain configured yet,
01416        * so just log to stdout
01417        */
01418       int result;
01419       result = ast_str_set_va(&buf, BUFSIZ, fmt, ap); /* XXX BUFSIZ ? */
01420       if (result != AST_DYNSTR_BUILD_FAILED) {
01421          term_filter_escapes(ast_str_buffer(buf));
01422          fputs(ast_str_buffer(buf), stdout);
01423       }
01424       return;
01425    }
01426 
01427    /* Ignore anything that never gets logged anywhere */
01428    if (level != __LOG_VERBOSE && !(global_logmask & (1 << level)))
01429       return;
01430 
01431    /* Build string */
01432    res = ast_str_set_va(&buf, BUFSIZ, fmt, ap);
01433 
01434    /* If the build failed, then abort and free this structure */
01435    if (res == AST_DYNSTR_BUILD_FAILED)
01436       return;
01437 
01438    /* Create a new logging message */
01439    if (!(logmsg = ast_calloc_with_stringfields(1, struct logmsg, res + 128)))
01440       return;
01441 
01442    /* Copy string over */
01443    ast_string_field_set(logmsg, message, ast_str_buffer(buf));
01444 
01445    /* Set type */
01446    if (level == __LOG_VERBOSE) {
01447       logmsg->type = LOGMSG_VERBOSE;
01448    } else {
01449       logmsg->type = LOGMSG_NORMAL;
01450    }
01451 
01452    if (display_callids && callid) {
01453       logmsg->callid = ast_callid_ref(callid);
01454       /* callid will be unreffed at logmsg destruction */
01455    }
01456 
01457    /* Create our date/time */
01458    ast_localtime(&now, &tm, NULL);
01459    ast_strftime(datestring, sizeof(datestring), dateformat, &tm);
01460    ast_string_field_set(logmsg, date, datestring);
01461 
01462    /* Copy over data */
01463    logmsg->level = level;
01464    logmsg->line = line;
01465    ast_string_field_set(logmsg, level_name, levels[level]);
01466    ast_string_field_set(logmsg, file, file);
01467    ast_string_field_set(logmsg, function, function);
01468    logmsg->lwp = ast_get_tid();
01469 
01470    /* If the logger thread is active, append it to the tail end of the list - otherwise skip that step */
01471    if (logthread != AST_PTHREADT_NULL) {
01472       AST_LIST_LOCK(&logmsgs);
01473       if (close_logger_thread) {
01474          /* Logger is either closing or closed.  We cannot log this message. */
01475          ast_free(logmsg);
01476       } else {
01477          AST_LIST_INSERT_TAIL(&logmsgs, logmsg, list);
01478          ast_cond_signal(&logcond);
01479       }
01480       AST_LIST_UNLOCK(&logmsgs);
01481    } else {
01482       logger_print_normal(logmsg);
01483       logmsg_free(logmsg);
01484    }
01485 }

static void ast_log_vsyslog ( struct logmsg msg  )  [static]

Definition at line 1002 of file logger.c.

References ast_syslog_priority_from_loglevel(), logmsg::file, logmsg::function, logmsg::level, levels, logmsg::line, logmsg::lwp, logmsg::message, and term_strip().

Referenced by logger_print_normal().

01003 {
01004    char buf[BUFSIZ];
01005    int syslog_level = ast_syslog_priority_from_loglevel(msg->level);
01006 
01007    if (syslog_level < 0) {
01008       /* we are locked here, so cannot ast_log() */
01009       fprintf(stderr, "ast_log_vsyslog called with bogus level: %d\n", msg->level);
01010       return;
01011    }
01012 
01013    snprintf(buf, sizeof(buf), "%s[%d]: %s:%d in %s: %s",
01014        levels[msg->level], msg->lwp, msg->file, msg->line, msg->function, msg->message);
01015 
01016    term_strip(buf, buf, strlen(buf) + 1);
01017    syslog(syslog_level, "%s", buf);
01018 }

int ast_logger_register_level ( const char *  name  ) 

Register a new logger level.

Parameters:
name The name of the level to be registered
Return values:
-1 if an error occurs
non-zero level to be used with ast_log for sending messages to this level
Since:
1.8

Definition at line 1871 of file logger.c.

References ARRAY_LEN, ast_debug, ast_log(), AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strdup, available(), levels, LOG_WARNING, and update_logchannels().

Referenced by ast_cc_init(), and load_module().

01872 {
01873    unsigned int level;
01874    unsigned int available = 0;
01875 
01876    AST_RWLIST_WRLOCK(&logchannels);
01877 
01878    for (level = 0; level < ARRAY_LEN(levels); level++) {
01879       if ((level >= 16) && !available && !levels[level]) {
01880          available = level;
01881          continue;
01882       }
01883 
01884       if (levels[level] && !strcasecmp(levels[level], name)) {
01885          ast_log(LOG_WARNING,
01886             "Unable to register dynamic logger level '%s': a standard logger level uses that name.\n",
01887             name);
01888          AST_RWLIST_UNLOCK(&logchannels);
01889 
01890          return -1;
01891       }
01892    }
01893 
01894    if (!available) {
01895       ast_log(LOG_WARNING,
01896          "Unable to register dynamic logger level '%s'; maximum number of levels registered.\n",
01897          name);
01898       AST_RWLIST_UNLOCK(&logchannels);
01899 
01900       return -1;
01901    }
01902 
01903    levels[available] = ast_strdup(name);
01904 
01905    AST_RWLIST_UNLOCK(&logchannels);
01906 
01907    ast_debug(1, "Registered dynamic logger level '%s' with index %d.\n", name, available);
01908 
01909    update_logchannels();
01910 
01911    return available;
01912 }

void ast_logger_unregister_level ( const char *  name  ) 

Unregister a previously registered logger level.

Parameters:
name The name of the level to be unregistered
Returns:
nothing
Since:
1.8

Definition at line 1914 of file logger.c.

References ARRAY_LEN, ast_debug, ast_free, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, levels, and update_logchannels().

Referenced by load_module(), and unload_module().

01915 {
01916    unsigned int found = 0;
01917    unsigned int x;
01918 
01919    AST_RWLIST_WRLOCK(&logchannels);
01920 
01921    for (x = 16; x < ARRAY_LEN(levels); x++) {
01922       if (!levels[x]) {
01923          continue;
01924       }
01925 
01926       if (strcasecmp(levels[x], name)) {
01927          continue;
01928       }
01929 
01930       found = 1;
01931       break;
01932    }
01933 
01934    if (found) {
01935       /* take this level out of the global_logmask, to ensure that no new log messages
01936        * will be queued for it
01937        */
01938 
01939       global_logmask &= ~(1 << x);
01940 
01941       ast_free(levels[x]);
01942       levels[x] = NULL;
01943       AST_RWLIST_UNLOCK(&logchannels);
01944 
01945       ast_debug(1, "Unregistered dynamic logger level '%s' with index %d.\n", name, x);
01946 
01947       update_logchannels();
01948    } else {
01949       AST_RWLIST_UNLOCK(&logchannels);
01950    }
01951 }

void ast_queue_log ( const char *  queuename,
const char *  callid,
const char *  agent,
const char *  event,
const char *  fmt,
  ... 
)

Definition at line 516 of file logger.c.

References args, AST_APP_ARG, ast_check_realtime(), AST_DECLARE_APP_ARGS, ast_localtime(), AST_NONSTANDARD_APP_ARGS, ast_queue_log(), ast_realtime_require_field(), AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_store_realtime(), ast_strftime(), ast_tvnow(), logfiles, logger_queue_init(), qlog, RQ_CHAR, S_OR, and SENTINEL.

Referenced by aqm_exec(), ast_queue_log(), find_queue_by_name_rt(), handle_queue_add_member(), handle_queue_remove_member(), login_exec(), manager_add_queue_member(), manager_queue_log_custom(), manager_remove_queue_member(), ql_exec(), queue_exec(), queue_transfer_fixup(), reload_logger(), rna(), rqm_exec(), rt_handle_member_record(), set_member_paused(), set_member_penalty_help_members(), set_member_ringinuse_help_members(), try_calling(), update_realtime_members(), and wait_our_turn().

00517 {
00518    va_list ap;
00519    struct timeval tv;
00520    struct ast_tm tm;
00521    char qlog_msg[8192];
00522    int qlog_len;
00523    char time_str[30];
00524 
00525    if (!logger_initialized) {
00526       /* You are too early.  We are not open yet! */
00527       return;
00528    }
00529    if (!queuelog_init) {
00530       AST_RWLIST_WRLOCK(&logchannels);
00531       if (!queuelog_init) {
00532          /*
00533           * We have delayed initializing the queue logging system so
00534           * preloaded realtime modules can get up.  We must initialize
00535           * now since someone is trying to log something.
00536           */
00537          logger_queue_init();
00538          queuelog_init = 1;
00539          AST_RWLIST_UNLOCK(&logchannels);
00540          ast_queue_log("NONE", "NONE", "NONE", "QUEUESTART", "%s", "");
00541       } else {
00542          AST_RWLIST_UNLOCK(&logchannels);
00543       }
00544    }
00545 
00546    if (ast_check_realtime("queue_log")) {
00547       tv = ast_tvnow();
00548       ast_localtime(&tv, &tm, NULL);
00549       ast_strftime(time_str, sizeof(time_str), "%F %T.%6q", &tm);
00550       va_start(ap, fmt);
00551       vsnprintf(qlog_msg, sizeof(qlog_msg), fmt, ap);
00552       va_end(ap);
00553       if (logfiles.queue_adaptive_realtime) {
00554          AST_DECLARE_APP_ARGS(args,
00555             AST_APP_ARG(data)[5];
00556          );
00557          AST_NONSTANDARD_APP_ARGS(args, qlog_msg, '|');
00558          /* Ensure fields are large enough to receive data */
00559          ast_realtime_require_field("queue_log",
00560             "data1", RQ_CHAR, strlen(S_OR(args.data[0], "")),
00561             "data2", RQ_CHAR, strlen(S_OR(args.data[1], "")),
00562             "data3", RQ_CHAR, strlen(S_OR(args.data[2], "")),
00563             "data4", RQ_CHAR, strlen(S_OR(args.data[3], "")),
00564             "data5", RQ_CHAR, strlen(S_OR(args.data[4], "")),
00565             SENTINEL);
00566 
00567          /* Store the log */
00568          ast_store_realtime("queue_log", "time", time_str,
00569             "callid", callid,
00570             "queuename", queuename,
00571             "agent", agent,
00572             "event", event,
00573             "data1", S_OR(args.data[0], ""),
00574             "data2", S_OR(args.data[1], ""),
00575             "data3", S_OR(args.data[2], ""),
00576             "data4", S_OR(args.data[3], ""),
00577             "data5", S_OR(args.data[4], ""),
00578             SENTINEL);
00579       } else {
00580          ast_store_realtime("queue_log", "time", time_str,
00581             "callid", callid,
00582             "queuename", queuename,
00583             "agent", agent,
00584             "event", event,
00585             "data", qlog_msg,
00586             SENTINEL);
00587       }
00588 
00589       if (!logfiles.queue_log_to_file) {
00590          return;
00591       }
00592    }
00593 
00594    if (qlog) {
00595       va_start(ap, fmt);
00596       qlog_len = snprintf(qlog_msg, sizeof(qlog_msg), "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event);
00597       vsnprintf(qlog_msg + qlog_len, sizeof(qlog_msg) - qlog_len, fmt, ap);
00598       va_end(ap);
00599       AST_RWLIST_RDLOCK(&logchannels);
00600       if (qlog) {
00601          fprintf(qlog, "%s\n", qlog_msg);
00602          fflush(qlog);
00603       }
00604       AST_RWLIST_UNLOCK(&logchannels);
00605    }
00606 }

struct ast_callid* ast_read_threadstorage_callid ( void   )  [read]

extracts the callerid from the thread

Return values:
ast_callid reference to call_id related to the thread
NULL if no call_id is present in the thread
This reference must be unreffed before it loses scope to prevent memory leaks.

Definition at line 1295 of file logger.c.

References ast_callid_ref, ast_threadstorage_get(), and unique_callid.

Referenced by __ast_pbx_run(), __ast_verbose(), agent_request(), ast_bridge_impart(), ast_callid_threadstorage_auto(), ast_dial_run(), ast_log(), ast_verbose(), bridge_call_thread_launch(), bridge_channel_join(), iax2_request(), jingle_alloc(), launch_monitor_thread(), local_request(), parked_call_exec(), sip_request_call(), and socket_process().

01296 {
01297    struct ast_callid **callid;
01298    callid = ast_threadstorage_get(&unique_callid, sizeof(struct ast_callid **));
01299    if (callid && *callid) {
01300       ast_callid_ref(*callid);
01301       return *callid;
01302    }
01303 
01304    return NULL;
01305 
01306 }

int ast_register_verbose ( void(*)(const char *string v  ) 

Definition at line 1821 of file logger.c.

References ast_malloc, AST_RWLIST_INSERT_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, logchannel::list, and verb::verboser.

Referenced by ast_makesocket(), and main().

01822 {
01823    struct verb *verb;
01824 
01825    if (!(verb = ast_malloc(sizeof(*verb))))
01826       return -1;
01827 
01828    verb->verboser = v;
01829 
01830    AST_RWLIST_WRLOCK(&verbosers);
01831    AST_RWLIST_INSERT_HEAD(&verbosers, verb, list);
01832    AST_RWLIST_UNLOCK(&verbosers);
01833 
01834    return 0;
01835 }

int ast_unregister_verbose ( void(*)(const char *string v  ) 

Definition at line 1837 of file logger.c.

References ast_free, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, logchannel::list, and verb::verboser.

01838 {
01839    struct verb *cur;
01840 
01841    AST_RWLIST_WRLOCK(&verbosers);
01842    AST_RWLIST_TRAVERSE_SAFE_BEGIN(&verbosers, cur, list) {
01843       if (cur->verboser == v) {
01844          AST_RWLIST_REMOVE_CURRENT(list);
01845          ast_free(cur);
01846          break;
01847       }
01848    }
01849    AST_RWLIST_TRAVERSE_SAFE_END;
01850    AST_RWLIST_UNLOCK(&verbosers);
01851 
01852    return cur ? 0 : -1;
01853 }

void ast_verbose ( const char *  fmt,
  ... 
)

Definition at line 1805 of file logger.c.

References __ast_verbose_ap(), ast_callid_unref, and ast_read_threadstorage_callid().

01806 {
01807    struct ast_callid *callid;
01808    va_list ap;
01809 
01810    callid = ast_read_threadstorage_callid();
01811 
01812    va_start(ap, fmt);
01813    __ast_verbose_ap("", 0, "", 0, callid, fmt, ap);
01814    va_end(ap);
01815 
01816    if (callid) {
01817       ast_callid_unref(callid);
01818    }
01819 }

void close_logger ( void   ) 

Provided by logger.c

Definition at line 1239 of file logger.c.

References ast_cond_signal, AST_LIST_LOCK, AST_LIST_UNLOCK, AST_PTHREADT_NULL, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, close_logger_thread, f, logchannel::fileptr, logchannel::list, logcond, logthread, and qlog.

Referenced by really_quit().

01240 {
01241    struct logchannel *f = NULL;
01242 
01243    logger_initialized = 0;
01244 
01245    /* Stop logger thread */
01246    AST_LIST_LOCK(&logmsgs);
01247    close_logger_thread = 1;
01248    ast_cond_signal(&logcond);
01249    AST_LIST_UNLOCK(&logmsgs);
01250 
01251    if (logthread != AST_PTHREADT_NULL)
01252       pthread_join(logthread, NULL);
01253 
01254    AST_RWLIST_WRLOCK(&logchannels);
01255 
01256    if (qlog) {
01257       fclose(qlog);
01258       qlog = NULL;
01259    }
01260 
01261    AST_RWLIST_TRAVERSE(&logchannels, f, list) {
01262       if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
01263          fclose(f->fileptr);
01264          f->fileptr = NULL;
01265       }
01266    }
01267 
01268    closelog(); /* syslog */
01269 
01270    AST_RWLIST_UNLOCK(&logchannels);
01271 }

static char* handle_logger_reload ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 858 of file logger.c.

References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, reload_logger(), and ast_cli_entry::usage.

00859 {
00860    switch (cmd) {
00861    case CLI_INIT:
00862       e->command = "logger reload";
00863       e->usage =
00864          "Usage: logger reload [<alt-conf>]\n"
00865          "       Reloads the logger subsystem state.  Use after restarting syslogd(8) if you are using syslog logging.\n";
00866       return NULL;
00867    case CLI_GENERATE:
00868       return NULL;
00869    }
00870    if (reload_logger(0, a->argc == 3 ? a->argv[2] : NULL)) {
00871       ast_cli(a->fd, "Failed to reload the logger\n");
00872       return CLI_FAILURE;
00873    }
00874    return CLI_SUCCESS;
00875 }

static char* handle_logger_rotate ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 877 of file logger.c.

References ast_cli(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, reload_logger(), and ast_cli_entry::usage.

00878 {
00879    switch (cmd) {
00880    case CLI_INIT:
00881       e->command = "logger rotate";
00882       e->usage =
00883          "Usage: logger rotate\n"
00884          "       Rotates and Reopens the log files.\n";
00885       return NULL;
00886    case CLI_GENERATE:
00887       return NULL;
00888    }
00889    if (reload_logger(1, NULL)) {
00890       ast_cli(a->fd, "Failed to reload the logger and rotate log files\n");
00891       return CLI_FAILURE;
00892    }
00893    return CLI_SUCCESS;
00894 }

static char* handle_logger_set_level ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 896 of file logger.c.

References ast_cli_args::argc, ast_cli_args::argv, ARRAY_LEN, ast_cli(), ast_console_toggle_loglevel(), AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_true(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, levels, and ast_cli_entry::usage.

00897 {
00898    int x;
00899    int state;
00900    int level = -1;
00901 
00902    switch (cmd) {
00903    case CLI_INIT:
00904       e->command = "logger set level {DEBUG|NOTICE|WARNING|ERROR|VERBOSE|DTMF} {on|off}";
00905       e->usage =
00906          "Usage: logger set level {DEBUG|NOTICE|WARNING|ERROR|VERBOSE|DTMF} {on|off}\n"
00907          "       Set a specific log level to enabled/disabled for this console.\n";
00908       return NULL;
00909    case CLI_GENERATE:
00910       return NULL;
00911    }
00912 
00913    if (a->argc < 5)
00914       return CLI_SHOWUSAGE;
00915 
00916    AST_RWLIST_WRLOCK(&logchannels);
00917 
00918    for (x = 0; x < ARRAY_LEN(levels); x++) {
00919       if (levels[x] && !strcasecmp(a->argv[3], levels[x])) {
00920          level = x;
00921          break;
00922       }
00923    }
00924 
00925    AST_RWLIST_UNLOCK(&logchannels);
00926 
00927    state = ast_true(a->argv[4]) ? 1 : 0;
00928 
00929    if (level != -1) {
00930       ast_console_toggle_loglevel(a->fd, level, state);
00931       ast_cli(a->fd, "Logger status for '%s' has been set to '%s'.\n", levels[level], state ? "on" : "off");
00932    } else
00933       return CLI_SHOWUSAGE;
00934 
00935    return CLI_SUCCESS;
00936 }

static char* handle_logger_show_channels ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

CLI command to show logging system configuration.

Definition at line 939 of file logger.c.

References ARRAY_LEN, ast_cli(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, logchannel::disabled, ast_cli_args::fd, logchannel::filename, FORMATL, levels, logchannel::list, logchannel::logmask, LOGTYPE_CONSOLE, LOGTYPE_SYSLOG, logchannel::type, and ast_cli_entry::usage.

00940 {
00941 #define FORMATL   "%-35.35s %-8.8s %-9.9s "
00942    struct logchannel *chan;
00943    switch (cmd) {
00944    case CLI_INIT:
00945       e->command = "logger show channels";
00946       e->usage =
00947          "Usage: logger show channels\n"
00948          "       List configured logger channels.\n";
00949       return NULL;
00950    case CLI_GENERATE:
00951       return NULL;
00952    }
00953    ast_cli(a->fd, FORMATL, "Channel", "Type", "Status");
00954    ast_cli(a->fd, "Configuration\n");
00955    ast_cli(a->fd, FORMATL, "-------", "----", "------");
00956    ast_cli(a->fd, "-------------\n");
00957    AST_RWLIST_RDLOCK(&logchannels);
00958    AST_RWLIST_TRAVERSE(&logchannels, chan, list) {
00959       unsigned int level;
00960 
00961       ast_cli(a->fd, FORMATL, chan->filename, chan->type == LOGTYPE_CONSOLE ? "Console" : (chan->type == LOGTYPE_SYSLOG ? "Syslog" : "File"),
00962          chan->disabled ? "Disabled" : "Enabled");
00963       ast_cli(a->fd, " - ");
00964       for (level = 0; level < ARRAY_LEN(levels); level++) {
00965          if ((chan->logmask & (1 << level)) && levels[level]) {
00966             ast_cli(a->fd, "%s ", levels[level]);
00967          }
00968       }
00969       ast_cli(a->fd, "\n");
00970    }
00971    AST_RWLIST_UNLOCK(&logchannels);
00972    ast_cli(a->fd, "\n");
00973 
00974    return CLI_SUCCESS;
00975 }

int init_logger ( void   ) 

Provided by logger.c

Definition at line 1215 of file logger.c.

References ARRAY_LEN, ast_cli_register_multiple(), ast_cond_destroy, ast_cond_init, ast_config_AST_LOG_DIR, ast_mkdir(), ast_pthread_create, cli_logger, handle_SIGXFSZ, init_logger_chain(), logcond, logger_thread(), and logthread.

Referenced by main().

01216 {
01217    /* auto rotate if sig SIGXFSZ comes a-knockin */
01218    sigaction(SIGXFSZ, &handle_SIGXFSZ, NULL);
01219 
01220    /* start logger thread */
01221    ast_cond_init(&logcond, NULL);
01222    if (ast_pthread_create(&logthread, NULL, logger_thread, NULL) < 0) {
01223       ast_cond_destroy(&logcond);
01224       return -1;
01225    }
01226 
01227    /* register the logger cli commands */
01228    ast_cli_register_multiple(cli_logger, ARRAY_LEN(cli_logger));
01229 
01230    ast_mkdir(ast_config_AST_LOG_DIR, 0777);
01231 
01232    /* create log channels */
01233    init_logger_chain(0 /* locked */, NULL);
01234    logger_initialized = 1;
01235 
01236    return 0;
01237 }

static void init_logger_chain ( int  locked,
const char *  altconf 
) [static]

Definition at line 342 of file logger.c.

References __LOG_ERROR, __LOG_NOTICE, __LOG_WARNING, ast_calloc, ast_config_destroy(), ast_config_load2(), ast_console_puts_mutable(), ast_copy_string(), ast_free, AST_RWLIST_INSERT_HEAD, AST_RWLIST_REMOVE_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_true(), ast_variable_browse(), ast_variable_retrieve(), CONFIG_STATUS_FILEINVALID, errno, ast_variable::lineno, logchannel::list, logfiles, logchannel::logmask, LOGTYPE_CONSOLE, make_logchannel(), ast_variable::name, ast_variable::next, NONE, qlog, ROTATE, S_OR, SEQUENTIAL, TIMESTAMP, logchannel::type, ast_variable::value, and var.

Referenced by init_logger(), and reload_logger().

00343 {
00344    struct logchannel *chan;
00345    struct ast_config *cfg;
00346    struct ast_variable *var;
00347    const char *s;
00348    struct ast_flags config_flags = { 0 };
00349 
00350    display_callids = 1;
00351 
00352    if (!(cfg = ast_config_load2(S_OR(altconf, "logger.conf"), "logger", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
00353       return;
00354    }
00355 
00356    /* delete our list of log channels */
00357    if (!locked) {
00358       AST_RWLIST_WRLOCK(&logchannels);
00359    }
00360    while ((chan = AST_RWLIST_REMOVE_HEAD(&logchannels, list))) {
00361       ast_free(chan);
00362    }
00363    global_logmask = 0;
00364    if (!locked) {
00365       AST_RWLIST_UNLOCK(&logchannels);
00366    }
00367 
00368    errno = 0;
00369    /* close syslog */
00370    closelog();
00371 
00372    /* If no config file, we're fine, set default options. */
00373    if (!cfg) {
00374       if (errno) {
00375          fprintf(stderr, "Unable to open logger.conf: %s; default settings will be used.\n", strerror(errno));
00376       } else {
00377          fprintf(stderr, "Errors detected in logger.conf: see above; default settings will be used.\n");
00378       }
00379       if (!(chan = ast_calloc(1, sizeof(*chan)))) {
00380          return;
00381       }
00382       chan->type = LOGTYPE_CONSOLE;
00383       chan->logmask = __LOG_WARNING | __LOG_NOTICE | __LOG_ERROR;
00384       if (!locked) {
00385          AST_RWLIST_WRLOCK(&logchannels);
00386       }
00387       AST_RWLIST_INSERT_HEAD(&logchannels, chan, list);
00388       global_logmask |= chan->logmask;
00389       if (!locked) {
00390          AST_RWLIST_UNLOCK(&logchannels);
00391       }
00392       return;
00393    }
00394 
00395    if ((s = ast_variable_retrieve(cfg, "general", "appendhostname"))) {
00396       if (ast_true(s)) {
00397          if (gethostname(hostname, sizeof(hostname) - 1)) {
00398             ast_copy_string(hostname, "unknown", sizeof(hostname));
00399             fprintf(stderr, "What box has no hostname???\n");
00400          }
00401       } else
00402          hostname[0] = '\0';
00403    } else
00404       hostname[0] = '\0';
00405    if ((s = ast_variable_retrieve(cfg, "general", "display_callids"))) {
00406       display_callids = ast_true(s);
00407    }
00408    if ((s = ast_variable_retrieve(cfg, "general", "dateformat")))
00409       ast_copy_string(dateformat, s, sizeof(dateformat));
00410    else
00411       ast_copy_string(dateformat, "%b %e %T", sizeof(dateformat));
00412    if ((s = ast_variable_retrieve(cfg, "general", "queue_log"))) {
00413       logfiles.queue_log = ast_true(s);
00414    }
00415    if ((s = ast_variable_retrieve(cfg, "general", "queue_log_to_file"))) {
00416       logfiles.queue_log_to_file = ast_true(s);
00417    }
00418    if ((s = ast_variable_retrieve(cfg, "general", "queue_log_name"))) {
00419       ast_copy_string(queue_log_name, s, sizeof(queue_log_name));
00420    }
00421    if ((s = ast_variable_retrieve(cfg, "general", "exec_after_rotate"))) {
00422       ast_copy_string(exec_after_rotate, s, sizeof(exec_after_rotate));
00423    }
00424    if ((s = ast_variable_retrieve(cfg, "general", "rotatestrategy"))) {
00425       if (strcasecmp(s, "timestamp") == 0) {
00426          rotatestrategy = TIMESTAMP;
00427       } else if (strcasecmp(s, "rotate") == 0) {
00428          rotatestrategy = ROTATE;
00429       } else if (strcasecmp(s, "sequential") == 0) {
00430          rotatestrategy = SEQUENTIAL;
00431       } else if (strcasecmp(s, "none") == 0) {
00432          rotatestrategy = NONE;
00433       } else {
00434          fprintf(stderr, "Unknown rotatestrategy: %s\n", s);
00435       }
00436    } else {
00437       if ((s = ast_variable_retrieve(cfg, "general", "rotatetimestamp"))) {
00438          rotatestrategy = ast_true(s) ? TIMESTAMP : SEQUENTIAL;
00439          fprintf(stderr, "rotatetimestamp option has been deprecated.  Please use rotatestrategy instead.\n");
00440       }
00441    }
00442 
00443    if (!locked) {
00444       AST_RWLIST_WRLOCK(&logchannels);
00445    }
00446    var = ast_variable_browse(cfg, "logfiles");
00447    for (; var; var = var->next) {
00448       if (!(chan = make_logchannel(var->name, var->value, var->lineno))) {
00449          /* Print error message directly to the consoles since the lock is held
00450           * and we don't want to unlock with the list partially built */
00451          ast_console_puts_mutable("ERROR: Unable to create log channel '", __LOG_ERROR);
00452          ast_console_puts_mutable(var->name, __LOG_ERROR);
00453          ast_console_puts_mutable("'\n", __LOG_ERROR);
00454          continue;
00455       }
00456       AST_RWLIST_INSERT_HEAD(&logchannels, chan, list);
00457       global_logmask |= chan->logmask;
00458    }
00459 
00460    if (qlog) {
00461       fclose(qlog);
00462       qlog = NULL;
00463    }
00464 
00465    if (!locked) {
00466       AST_RWLIST_UNLOCK(&logchannels);
00467    }
00468 
00469    ast_config_destroy(cfg);
00470 }

static void logger_print_normal ( struct logmsg logmsg  )  [static]

Print a normal log message to the channels.

Definition at line 1027 of file logger.c.

References __LOG_VERBOSE, ast_console_puts_mutable(), ast_log_vsyslog(), AST_RWLIST_EMPTY, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_strdupa, ast_string_field_set, ast_strlen_zero(), ast_verb, ast_callid::call_identifier, logmsg::callid, COLOR_BRWHITE, colors, logmsg::date, logchannel::disabled, errno, EVENT_FLAG_SYSTEM, logmsg::file, logchannel::filename, logchannel::fileptr, logmsg::function, logmsg::level, logmsg::level_name, logmsg::line, logchannel::list, logchannel::logmask, LOGTYPE_CONSOLE, LOGTYPE_FILE, LOGTYPE_SYSLOG, logmsg::lwp, manager_event, logmsg::message, reload_logger(), term_color(), term_strip(), logchannel::type, VERBOSE_MAGIC2LEVEL, verb::verboser, and logchannel::verbosity.

Referenced by ast_log_full(), and logger_thread().

01028 {
01029    struct logchannel *chan = NULL;
01030    char buf[BUFSIZ];
01031    struct verb *v = NULL;
01032    int level = 0;
01033 
01034    if (logmsg->level == __LOG_VERBOSE) {
01035       char *tmpmsg = ast_strdupa(logmsg->message + 1);
01036       level = VERBOSE_MAGIC2LEVEL(logmsg->message);
01037       /* Iterate through the list of verbosers and pass them the log message string */
01038       AST_RWLIST_RDLOCK(&verbosers);
01039       AST_RWLIST_TRAVERSE(&verbosers, v, list)
01040          v->verboser(logmsg->message);
01041       AST_RWLIST_UNLOCK(&verbosers);
01042       ast_string_field_set(logmsg, message, tmpmsg);
01043    }
01044 
01045    AST_RWLIST_RDLOCK(&logchannels);
01046 
01047    if (!AST_RWLIST_EMPTY(&logchannels)) {
01048       AST_RWLIST_TRAVERSE(&logchannels, chan, list) {
01049          char call_identifier_str[13];
01050 
01051          if (logmsg->callid) {
01052             snprintf(call_identifier_str, sizeof(call_identifier_str), "[C-%08x]", logmsg->callid->call_identifier);
01053          } else {
01054             call_identifier_str[0] = '\0';
01055          }
01056 
01057 
01058          /* If the channel is disabled, then move on to the next one */
01059          if (chan->disabled) {
01060             continue;
01061          }
01062          if (logmsg->level == __LOG_VERBOSE && level > chan->verbosity) {
01063             continue;
01064          }
01065 
01066          /* Check syslog channels */
01067          if (chan->type == LOGTYPE_SYSLOG && (chan->logmask & (1 << logmsg->level))) {
01068             ast_log_vsyslog(logmsg);
01069          /* Console channels */
01070          } else if (chan->type == LOGTYPE_CONSOLE && (chan->logmask & (1 << logmsg->level))) {
01071             char linestr[128];
01072             char tmp1[80], tmp2[80], tmp3[80], tmp4[80];
01073 
01074             /* If the level is verbose, then skip it */
01075             if (logmsg->level == __LOG_VERBOSE)
01076                continue;
01077 
01078             /* Turn the numerical line number into a string */
01079             snprintf(linestr, sizeof(linestr), "%d", logmsg->line);
01080             /* Build string to print out */
01081             snprintf(buf, sizeof(buf), "[%s] %s[%d]%s: %s:%s %s: %s",
01082                 logmsg->date,
01083                 term_color(tmp1, logmsg->level_name, colors[logmsg->level], 0, sizeof(tmp1)),
01084                 logmsg->lwp,
01085                 call_identifier_str,
01086                 term_color(tmp2, logmsg->file, COLOR_BRWHITE, 0, sizeof(tmp2)),
01087                 term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)),
01088                 term_color(tmp4, logmsg->function, COLOR_BRWHITE, 0, sizeof(tmp4)),
01089                 logmsg->message);
01090             /* Print out */
01091             ast_console_puts_mutable(buf, logmsg->level);
01092          /* File channels */
01093          } else if (chan->type == LOGTYPE_FILE && (chan->logmask & (1 << logmsg->level))) {
01094             int res = 0;
01095 
01096             /* If no file pointer exists, skip it */
01097             if (!chan->fileptr) {
01098                continue;
01099             }
01100 
01101             /* Print out to the file */
01102             res = fprintf(chan->fileptr, "[%s] %s[%d]%s %s: %s",
01103                      logmsg->date, logmsg->level_name, logmsg->lwp, call_identifier_str,
01104                      logmsg->file, term_strip(buf, logmsg->message, BUFSIZ));
01105             if (res <= 0 && !ast_strlen_zero(logmsg->message)) {
01106                fprintf(stderr, "**** Asterisk Logging Error: ***********\n");
01107                if (errno == ENOMEM || errno == ENOSPC)
01108                   fprintf(stderr, "Asterisk logging error: Out of disk space, can't log to log file %s\n", chan->filename);
01109                else
01110                   fprintf(stderr, "Logger Warning: Unable to write to log file '%s': %s (disabled)\n", chan->filename, strerror(errno));
01111                /*** DOCUMENTATION
01112                   <managerEventInstance>
01113                      <synopsis>Raised when a logging channel is disabled.</synopsis>
01114                      <syntax>
01115                         <parameter name="Channel">
01116                            <para>The name of the logging channel.</para>
01117                         </parameter>
01118                      </syntax>
01119                   </managerEventInstance>
01120                ***/
01121                manager_event(EVENT_FLAG_SYSTEM, "LogChannel", "Channel: %s\r\nEnabled: No\r\nReason: %d - %s\r\n", chan->filename, errno, strerror(errno));
01122                chan->disabled = 1;
01123             } else if (res > 0) {
01124                fflush(chan->fileptr);
01125             }
01126          }
01127       }
01128    } else if (logmsg->level != __LOG_VERBOSE) {
01129       fputs(logmsg->message, stdout);
01130    }
01131 
01132    AST_RWLIST_UNLOCK(&logchannels);
01133 
01134    /* If we need to reload because of the file size, then do so */
01135    if (filesize_reload_needed) {
01136       reload_logger(-1, NULL);
01137       ast_verb(1, "Rotated Logs Per SIGXFSZ (Exceeded file size limit)\n");
01138    }
01139 
01140    return;
01141 }

static void logger_queue_init ( void   )  [static]

Definition at line 1191 of file logger.c.

References ast_config_AST_LOG_DIR, ast_log(), ast_unload_realtime(), errno, LOG_ERROR, logfiles, logger_queue_rt_start(), and qlog.

Referenced by ast_queue_log().

01192 {
01193    ast_unload_realtime("queue_log");
01194    if (logfiles.queue_log) {
01195       char qfname[PATH_MAX];
01196 
01197       if (logger_queue_rt_start()) {
01198          return;
01199       }
01200 
01201       /* Open the log file. */
01202       snprintf(qfname, sizeof(qfname), "%s/%s", ast_config_AST_LOG_DIR,
01203          queue_log_name);
01204       if (qlog) {
01205          /* Just in case it was already open. */
01206          fclose(qlog);
01207       }
01208       qlog = fopen(qfname, "a");
01209       if (!qlog) {
01210          ast_log(LOG_ERROR, "Unable to create queue log: %s\n", strerror(errno));
01211       }
01212    }
01213 }

static int logger_queue_restart ( int  queue_rotate  )  [static]

Definition at line 747 of file logger.c.

References ast_config_AST_LOG_DIR, ast_log(), errno, LOG_ERROR, logger_queue_rt_start(), qlog, and rotate_file().

Referenced by reload_logger().

00748 {
00749    int res = 0;
00750    char qfname[PATH_MAX];
00751 
00752    if (logger_queue_rt_start()) {
00753       return res;
00754    }
00755 
00756    snprintf(qfname, sizeof(qfname), "%s/%s", ast_config_AST_LOG_DIR, queue_log_name);
00757    if (qlog) {
00758       /* Just in case it was still open. */
00759       fclose(qlog);
00760       qlog = NULL;
00761    }
00762    if (queue_rotate) {
00763       rotate_file(qfname);
00764    }
00765 
00766    /* Open the log file. */
00767    qlog = fopen(qfname, "a");
00768    if (!qlog) {
00769       ast_log(LOG_ERROR, "Unable to create queue log: %s\n", strerror(errno));
00770       res = -1;
00771    }
00772    return res;
00773 }

static int logger_queue_rt_start ( void   )  [static]

Definition at line 712 of file logger.c.

References ast_check_realtime(), ast_realtime_require_field(), logfiles, RQ_CHAR, RQ_DATETIME, and SENTINEL.

Referenced by logger_queue_init(), and logger_queue_restart().

00713 {
00714    if (ast_check_realtime("queue_log")) {
00715       if (!ast_realtime_require_field("queue_log",
00716          "time", RQ_DATETIME, 26,
00717          "data1", RQ_CHAR, 20,
00718          "data2", RQ_CHAR, 20,
00719          "data3", RQ_CHAR, 20,
00720          "data4", RQ_CHAR, 20,
00721          "data5", RQ_CHAR, 20,
00722          SENTINEL)) {
00723          logfiles.queue_adaptive_realtime = 1;
00724       } else {
00725          logfiles.queue_adaptive_realtime = 0;
00726       }
00727 
00728       if (!logfiles.queue_log_to_file) {
00729          /* Don't open the log file. */
00730          return 1;
00731       }
00732    }
00733    return 0;
00734 }

int logger_reload ( void   ) 

Reload the logger module without rotating log files (also used from loader.c during a full Asterisk reload).

Reload logger without rotating log files.

Definition at line 850 of file logger.c.

References reload_logger(), RESULT_FAILURE, and RESULT_SUCCESS.

00851 {
00852    if (reload_logger(0, NULL)) {
00853       return RESULT_FAILURE;
00854    }
00855    return RESULT_SUCCESS;
00856 }

static void* logger_thread ( void *  data  )  [static]

Actual logging thread.

Definition at line 1144 of file logger.c.

References ast_cond_wait, AST_LIST_EMPTY, AST_LIST_FIRST, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_LOCK, AST_LIST_NEXT, AST_LIST_UNLOCK, close_logger_thread, logchannel::list, logcond, logger_print_normal(), logmsg_free(), and logchannel::next.

Referenced by init_logger().

01145 {
01146    struct logmsg *next = NULL, *msg = NULL;
01147 
01148    for (;;) {
01149       /* We lock the message list, and see if any message exists... if not we wait on the condition to be signalled */
01150       AST_LIST_LOCK(&logmsgs);
01151       if (AST_LIST_EMPTY(&logmsgs)) {
01152          if (close_logger_thread) {
01153             AST_LIST_UNLOCK(&logmsgs);
01154             break;
01155          } else {
01156             ast_cond_wait(&logcond, &logmsgs.lock);
01157          }
01158       }
01159       next = AST_LIST_FIRST(&logmsgs);
01160       AST_LIST_HEAD_INIT_NOLOCK(&logmsgs);
01161       AST_LIST_UNLOCK(&logmsgs);
01162 
01163       /* Otherwise go through and process each message in the order added */
01164       while ((msg = next)) {
01165          /* Get the next entry now so that we can free our current structure later */
01166          next = AST_LIST_NEXT(msg, list);
01167 
01168          /* Depending on the type, send it to the proper function */
01169          logger_print_normal(msg);
01170 
01171          /* Free the data since we are done */
01172          logmsg_free(msg);
01173       }
01174 
01175       /* If we should stop, then stop */
01176       if (close_logger_thread)
01177          break;
01178    }
01179 
01180    return NULL;
01181 }

static void logmsg_free ( struct logmsg msg  )  [static]

Definition at line 161 of file logger.c.

References ast_callid_unref, and ast_free.

Referenced by ast_log_full(), and logger_thread().

00162 {
00163    if (msg->callid) {
00164       ast_callid_unref(msg->callid);
00165    }
00166    ast_free(msg);
00167 }

static unsigned int make_components ( const char *  s,
int  lineno,
int *  verbosity 
) [static]

Definition at line 241 of file logger.c.

References __LOG_VERBOSE, ARRAY_LEN, ast_skip_blanks(), ast_strdupa, levels, and strsep().

Referenced by make_logchannel(), and update_logchannels().

00242 {
00243    char *w;
00244    unsigned int res = 0;
00245    char *stringp = ast_strdupa(s);
00246    unsigned int x;
00247 
00248    *verbosity = 3;
00249 
00250    while ((w = strsep(&stringp, ","))) {
00251       w = ast_skip_blanks(w);
00252 
00253       if (!strcmp(w, "*")) {
00254          res = 0xFFFFFFFF;
00255          break;
00256       } else if (!strncasecmp(w, "verbose(", 8) && sscanf(w + 8, "%d)", verbosity) == 1) {
00257          res |= (1 << __LOG_VERBOSE);
00258          break;
00259       } else for (x = 0; x < ARRAY_LEN(levels); x++) {
00260          if (levels[x] && !strcasecmp(w, levels[x])) {
00261             res |= (1 << x);
00262             break;
00263          }
00264       }
00265    }
00266 
00267    return res;
00268 }

static struct logchannel* make_logchannel ( const char *  channel,
const char *  components,
int  lineno 
) [static, read]

Definition at line 270 of file logger.c.

References __LOG_ERROR, ast_build_date, ast_build_hostname, ast_build_machine, ast_build_os, ast_build_user, ast_calloc, ast_config_AST_LOG_DIR, ast_console_puts_mutable(), ast_copy_string(), ast_free, ast_get_version(), ast_localtime(), ast_strftime(), ast_strlen_zero(), ast_syslog_facility(), ast_tvnow(), logchannel::components, errno, logchannel::facility, logchannel::filename, logchannel::fileptr, logchannel::lineno, logchannel::logmask, LOGTYPE_CONSOLE, LOGTYPE_FILE, LOGTYPE_SYSLOG, make_components(), logchannel::type, and logchannel::verbosity.

Referenced by init_logger_chain().

00271 {
00272    struct logchannel *chan;
00273    char *facility;
00274    struct ast_tm tm;
00275    struct timeval now = ast_tvnow();
00276    char datestring[256];
00277 
00278    if (ast_strlen_zero(channel) || !(chan = ast_calloc(1, sizeof(*chan) + strlen(components) + 1)))
00279       return NULL;
00280 
00281    strcpy(chan->components, components);
00282    chan->lineno = lineno;
00283 
00284    if (!strcasecmp(channel, "console")) {
00285       chan->type = LOGTYPE_CONSOLE;
00286    } else if (!strncasecmp(channel, "syslog", 6)) {
00287       /*
00288       * syntax is:
00289       *  syslog.facility => level,level,level
00290       */
00291       facility = strchr(channel, '.');
00292       if (!facility++ || !facility) {
00293          facility = "local0";
00294       }
00295 
00296       chan->facility = ast_syslog_facility(facility);
00297 
00298       if (chan->facility < 0) {
00299          fprintf(stderr, "Logger Warning: bad syslog facility in logger.conf\n");
00300          ast_free(chan);
00301          return NULL;
00302       }
00303 
00304       chan->type = LOGTYPE_SYSLOG;
00305       ast_copy_string(chan->filename, channel, sizeof(chan->filename));
00306       openlog("asterisk", LOG_PID, chan->facility);
00307    } else {
00308       if (!ast_strlen_zero(hostname)) {
00309          snprintf(chan->filename, sizeof(chan->filename), "%s/%s.%s",
00310              channel[0] != '/' ? ast_config_AST_LOG_DIR : "", channel, hostname);
00311       } else {
00312          snprintf(chan->filename, sizeof(chan->filename), "%s/%s",
00313              channel[0] != '/' ? ast_config_AST_LOG_DIR : "", channel);
00314       }
00315       if (!(chan->fileptr = fopen(chan->filename, "a"))) {
00316          /* Can't do real logging here since we're called with a lock
00317           * so log to any attached consoles */
00318          ast_console_puts_mutable("ERROR: Unable to open log file '", __LOG_ERROR);
00319          ast_console_puts_mutable(chan->filename, __LOG_ERROR);
00320          ast_console_puts_mutable("': ", __LOG_ERROR);
00321          ast_console_puts_mutable(strerror(errno), __LOG_ERROR);
00322          ast_console_puts_mutable("'\n", __LOG_ERROR);
00323          ast_free(chan);
00324          return NULL;
00325       } else {
00326          /* Create our date/time */
00327          ast_localtime(&now, &tm, NULL);
00328          ast_strftime(datestring, sizeof(datestring), dateformat, &tm);
00329 
00330          fprintf(chan->fileptr, "[%s] Asterisk %s built by %s @ %s on a %s running %s on %s\n",
00331             datestring, ast_get_version(), ast_build_user, ast_build_hostname,
00332             ast_build_machine, ast_build_os, ast_build_date);
00333          fflush(chan->fileptr);
00334       }
00335       chan->type = LOGTYPE_FILE;
00336    }
00337    chan->logmask = make_components(chan->components, lineno, &chan->verbosity);
00338 
00339    return chan;
00340 }

static int reload_logger ( int  rotate,
const char *  altconf 
) [static]

Definition at line 775 of file logger.c.

References ast_config_AST_LOG_DIR, ast_mkdir(), ast_queue_log(), AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_unload_realtime(), ast_verb, logchannel::disabled, EVENT_FLAG_SYSTEM, f, logchannel::filename, logchannel::fileptr, init_logger_chain(), logchannel::list, logfiles, logger_queue_restart(), manager_event, NONE, qlog, and rotate_file().

Referenced by handle_logger_reload(), handle_logger_rotate(), logger_print_normal(), and logger_reload().

00776 {
00777    int queue_rotate = rotate;
00778    struct logchannel *f;
00779    int res = 0;
00780 
00781    AST_RWLIST_WRLOCK(&logchannels);
00782 
00783    if (qlog) {
00784       if (rotate < 0) {
00785          /* Check filesize - this one typically doesn't need an auto-rotate */
00786          if (ftello(qlog) > 0x40000000) { /* Arbitrarily, 1 GB */
00787             fclose(qlog);
00788             qlog = NULL;
00789          } else {
00790             queue_rotate = 0;
00791          }
00792       } else {
00793          fclose(qlog);
00794          qlog = NULL;
00795       }
00796    } else {
00797       queue_rotate = 0;
00798    }
00799 
00800    ast_mkdir(ast_config_AST_LOG_DIR, 0777);
00801 
00802    AST_RWLIST_TRAVERSE(&logchannels, f, list) {
00803       if (f->disabled) {
00804          f->disabled = 0;  /* Re-enable logging at reload */
00805          /*** DOCUMENTATION
00806             <managerEventInstance>
00807                <synopsis>Raised when a logging channel is re-enabled after a reload operation.</synopsis>
00808                <syntax>
00809                   <parameter name="Channel">
00810                      <para>The name of the logging channel.</para>
00811                   </parameter>
00812                </syntax>
00813             </managerEventInstance>
00814          ***/
00815          manager_event(EVENT_FLAG_SYSTEM, "LogChannel", "Channel: %s\r\nEnabled: Yes\r\n", f->filename);
00816       }
00817       if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
00818          int rotate_this = 0;
00819          if (rotatestrategy != NONE && ftello(f->fileptr) > 0x40000000) { /* Arbitrarily, 1 GB */
00820             /* Be more proactive about rotating massive log files */
00821             rotate_this = 1;
00822          }
00823          fclose(f->fileptr);  /* Close file */
00824          f->fileptr = NULL;
00825          if (rotate || rotate_this) {
00826             rotate_file(f->filename);
00827          }
00828       }
00829    }
00830 
00831    filesize_reload_needed = 0;
00832 
00833    init_logger_chain(1 /* locked */, altconf);
00834 
00835    ast_unload_realtime("queue_log");
00836    if (logfiles.queue_log) {
00837       res = logger_queue_restart(queue_rotate);
00838       AST_RWLIST_UNLOCK(&logchannels);
00839       ast_queue_log("NONE", "NONE", "NONE", "CONFIGRELOAD", "%s", "");
00840       ast_verb(1, "Asterisk Queue Logger restarted\n");
00841    } else {
00842       AST_RWLIST_UNLOCK(&logchannels);
00843    }
00844 
00845    return res;
00846 }

static int rotate_file ( const char *  filename  )  [static]

Definition at line 608 of file logger.c.

References ARRAY_LEN, ast_channel_unref, ast_dummy_channel_alloc(), ast_log(), ast_safe_system(), ast_strlen_zero(), LOG_WARNING, NONE, pbx_builtin_setvar_helper(), pbx_substitute_variables_helper(), ROTATE, SEQUENTIAL, and TIMESTAMP.

Referenced by logger_queue_restart(), and reload_logger().

00609 {
00610    char old[PATH_MAX];
00611    char new[PATH_MAX];
00612    int x, y, which, found, res = 0, fd;
00613    char *suffixes[4] = { "", ".gz", ".bz2", ".Z" };
00614 
00615    switch (rotatestrategy) {
00616    case NONE:
00617       /* No rotation */
00618       break;
00619    case SEQUENTIAL:
00620       for (x = 0; ; x++) {
00621          snprintf(new, sizeof(new), "%s.%d", filename, x);
00622          fd = open(new, O_RDONLY);
00623          if (fd > -1)
00624             close(fd);
00625          else
00626             break;
00627       }
00628       if (rename(filename, new)) {
00629          fprintf(stderr, "Unable to rename file '%s' to '%s'\n", filename, new);
00630          res = -1;
00631       } else {
00632          filename = new;
00633       }
00634       break;
00635    case TIMESTAMP:
00636       snprintf(new, sizeof(new), "%s.%ld", filename, (long)time(NULL));
00637       if (rename(filename, new)) {
00638          fprintf(stderr, "Unable to rename file '%s' to '%s'\n", filename, new);
00639          res = -1;
00640       } else {
00641          filename = new;
00642       }
00643       break;
00644    case ROTATE:
00645       /* Find the next empty slot, including a possible suffix */
00646       for (x = 0; ; x++) {
00647          found = 0;
00648          for (which = 0; which < ARRAY_LEN(suffixes); which++) {
00649             snprintf(new, sizeof(new), "%s.%d%s", filename, x, suffixes[which]);
00650             fd = open(new, O_RDONLY);
00651             if (fd > -1) {
00652                close(fd);
00653                found = 1;
00654                break;
00655             }
00656          }
00657          if (!found) {
00658             break;
00659          }
00660       }
00661 
00662       /* Found an empty slot */
00663       for (y = x; y > 0; y--) {
00664          for (which = 0; which < ARRAY_LEN(suffixes); which++) {
00665             snprintf(old, sizeof(old), "%s.%d%s", filename, y - 1, suffixes[which]);
00666             fd = open(old, O_RDONLY);
00667             if (fd > -1) {
00668                /* Found the right suffix */
00669                close(fd);
00670                snprintf(new, sizeof(new), "%s.%d%s", filename, y, suffixes[which]);
00671                if (rename(old, new)) {
00672                   fprintf(stderr, "Unable to rename file '%s' to '%s'\n", old, new);
00673                   res = -1;
00674                }
00675                break;
00676             }
00677          }
00678       }
00679 
00680       /* Finally, rename the current file */
00681       snprintf(new, sizeof(new), "%s.0", filename);
00682       if (rename(filename, new)) {
00683          fprintf(stderr, "Unable to rename file '%s' to '%s'\n", filename, new);
00684          res = -1;
00685       } else {
00686          filename = new;
00687       }
00688    }
00689 
00690    if (!ast_strlen_zero(exec_after_rotate)) {
00691       struct ast_channel *c = ast_dummy_channel_alloc();
00692       char buf[512];
00693 
00694       pbx_builtin_setvar_helper(c, "filename", filename);
00695       pbx_substitute_variables_helper(c, exec_after_rotate, buf, sizeof(buf));
00696       if (c) {
00697          c = ast_channel_unref(c);
00698       }
00699       if (ast_safe_system(buf) == -1) {
00700          ast_log(LOG_WARNING, "error executing '%s'\n", buf);
00701       }
00702    }
00703    return res;
00704 }

static void unique_callid_cleanup ( void *  data  )  [static]

Definition at line 1387 of file logger.c.

References ast_callid_unref, and ast_free.

01388 {
01389    struct ast_callid **callid = data;
01390 
01391    if (*callid) {
01392       ast_callid_unref(*callid);
01393    }
01394 
01395    ast_free(data);
01396 }

static void update_logchannels ( void   )  [static]


Variable Documentation

struct ast_cli_entry cli_logger[] [static]

Definition at line 984 of file logger.c.

Referenced by init_logger().

int close_logger_thread = 0 [static]

Definition at line 172 of file logger.c.

Referenced by ast_log_full(), close_logger(), and logger_thread().

const int colors[NUMLOGLEVELS] [static]

Colors used in the console for logging.

Definition at line 198 of file logger.c.

Referenced by logger_print_normal().

char dateformat[256] = "%b %e %T" [static]

Definition at line 75 of file logger.c.

Referenced by build_device().

int display_callids [static]

Definition at line 85 of file logger.c.

char exec_after_rotate[256] = "" [static]

Definition at line 78 of file logger.c.

int filesize_reload_needed [static]

Definition at line 80 of file logger.c.

unsigned int global_logmask = 0xFFFF [static]

Definition at line 81 of file logger.c.

struct sigaction handle_SIGXFSZ [static]

Initial value:

 {
   .sa_handler = _handle_SIGXFSZ,
   .sa_flags = SA_RESTART,
}

Definition at line 997 of file logger.c.

Referenced by init_logger().

char hostname[MAXHOSTNAMELEN] [static]

char* levels[NUMLOGLEVELS] [static]

Logging channels used in the Asterisk logging system.

The first 16 levels are reserved for system usage, and the remaining levels are reserved for usage by dynamic levels registered via ast_logger_register_level.

Definition at line 187 of file logger.c.

Referenced by ast_log_full(), ast_log_vsyslog(), ast_logger_register_level(), ast_logger_unregister_level(), ast_network_puts_mutable(), handle_logger_set_level(), handle_logger_show_channels(), and make_components().

struct ast_threadstorage log_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_log_buf , .custom_init = NULL , } [static]

Definition at line 236 of file logger.c.

Referenced by ast_log_full().

ast_cond_t logcond [static]

Definition at line 171 of file logger.c.

Referenced by ast_log_full(), close_logger(), init_logger(), and logger_thread().

struct { ... } logfiles [static]

int logger_initialized [static]

Definition at line 83 of file logger.c.

pthread_t logthread = AST_PTHREADT_NULL [static]

Definition at line 170 of file logger.c.

Referenced by ast_log_full(), close_logger(), and init_logger().

volatile int next_unique_callid [static]

Definition at line 84 of file logger.c.

FILE* qlog [static]

Definition at line 104 of file logger.c.

unsigned int queue_log

Definition at line 102 of file logger.c.

char queue_log_name[256] = QUEUELOG [static]

Definition at line 77 of file logger.c.

unsigned int queue_log_to_file

Definition at line 103 of file logger.c.

int queuelog_init [static]

Definition at line 82 of file logger.c.

struct ast_threadstorage unique_callid = { .once = PTHREAD_ONCE_INIT , .key_init = __init_unique_callid , .custom_init = NULL , } [static]

struct ast_threadstorage verbose_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_verbose_buf , .custom_init = NULL , } [static]

Definition at line 233 of file logger.c.

Referenced by __ast_verbose_ap().


Generated on Thu Oct 11 06:36:38 2012 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6