logger.h File Reference

#include <stdarg.h>

Include dependency graph for logger.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define EVENTLOG   "event_log"
#define DEBUG_M(a)
#define _A_   __FILE__, __LINE__, __PRETTY_FUNCTION__
#define __LOG_DEBUG   0
#define LOG_DEBUG   __LOG_DEBUG, _A_
#define __LOG_EVENT   1
#define LOG_EVENT   __LOG_EVENT, _A_
#define __LOG_NOTICE   2
#define LOG_NOTICE   __LOG_NOTICE, _A_
#define __LOG_WARNING   3
#define LOG_WARNING   __LOG_WARNING, _A_
#define __LOG_ERROR   4
#define LOG_ERROR   __LOG_ERROR, _A_
#define __LOG_VERBOSE   5
#define LOG_VERBOSE   __LOG_VERBOSE, _A_

Functions

void ast_log (int level, const char *file, int line, const char *function, const char *fmt,...) __attribute__((format(printf
 Used for sending a log message.
void void ast_queue_log (const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt,...) __attribute__((format(printf
void void void ast_verbose (const char *fmt,...) __attribute__((format(printf
 Send a verbose message (based on verbose level).
void void void int ast_register_verbose (void(*verboser)(const char *string, int opos, int replacelast, int complete))
int ast_unregister_verbose (void(*verboser)(const char *string, int opos, int replacelast, int complete))
int ast_verbose_dmesg (void(*verboser)(const char *string, int opos, int replacelast, int complete))
void ast_console_puts (const char *string)


Define Documentation

#define __LOG_DEBUG   0

Definition at line 67 of file logger.h.

#define __LOG_ERROR   4

Definition at line 91 of file logger.h.

#define __LOG_EVENT   1

Definition at line 73 of file logger.h.

#define __LOG_NOTICE   2

Definition at line 79 of file logger.h.

#define __LOG_VERBOSE   5

Definition at line 97 of file logger.h.

#define __LOG_WARNING   3

Definition at line 85 of file logger.h.

#define _A_   __FILE__, __LINE__, __PRETTY_FUNCTION__

Definition at line 62 of file logger.h.

#define DEBUG_M (  ) 

Value:

{ \
   a; \
}

Definition at line 25 of file logger.h.

#define EVENTLOG   "event_log"

Definition at line 23 of file logger.h.

#define LOG_DEBUG   __LOG_DEBUG, _A_

Definition at line 68 of file logger.h.

#define LOG_ERROR   __LOG_ERROR, _A_

Definition at line 92 of file logger.h.

#define LOG_EVENT   __LOG_EVENT, _A_

Definition at line 74 of file logger.h.

#define LOG_NOTICE   __LOG_NOTICE, _A_

Definition at line 80 of file logger.h.

#define LOG_VERBOSE   __LOG_VERBOSE, _A_

Definition at line 98 of file logger.h.

#define LOG_WARNING   __LOG_WARNING, _A_

Definition at line 86 of file logger.h.


Function Documentation

void ast_console_puts ( const char *  string  ) 

Definition at line 236 of file asterisk.c.

00237 {
00238    fputs(string, stdout);
00239    fflush(stdout);
00240    ast_network_puts(string);
00241 }

void ast_log ( int  level,
const char *  file,
int  line,
const char *  function,
const char *  fmt,
  ... 
)

Used for sending a log message.

Parameters:
level don't need to worry about it
file ditto
line ditto
function ditto
fmt this is what is important. The format is the same as your favorite breed of printf. You know how that works, right? :-) This is the standard logger function. Probably the only way you will invoke it would be something like this: ast_log(LOG_WHATEVER, "Problem with the %s Captain. We should get some more. Will %d be enough?", "flux capacitor", 10); where WHATEVER is one of ERROR, DEBUG, EVENT, NOTICE, or WARNING depending on which log you wish to output to.

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

void void void int ast_register_verbose ( void(*)(const char *string, int opos, int replacelast, int complete)  verboser  ) 

Definition at line 712 of file logger.c.

00713 {
00714    struct msglist *m;
00715    struct verb *tmp;
00716    /* XXX Should be more flexible here, taking > 1 verboser XXX */
00717    if ((tmp = malloc(sizeof (struct verb)))) {
00718       tmp->verboser = v;
00719       ast_mutex_lock(&msglist_lock);
00720       tmp->next = verboser;
00721       verboser = tmp;
00722       m = list;
00723       while(m) {
00724          /* Send all the existing entries that we have queued (i.e. they're likely to have missed) */
00725          v(m->msg, 0, 0, 1);
00726          m = m->next;
00727       }
00728       ast_mutex_unlock(&msglist_lock);
00729       return 0;
00730    }
00731    return -1;
00732 }

int ast_unregister_verbose ( void(*)(const char *string, int opos, int replacelast, int complete)  verboser  ) 

Definition at line 734 of file logger.c.

00735 {
00736    int res = -1;
00737    struct verb *tmp, *tmpl=NULL;
00738    ast_mutex_lock(&msglist_lock);
00739    tmp = verboser;
00740    while(tmp) {
00741       if (tmp->verboser == v) {
00742          if (tmpl)
00743             tmpl->next = tmp->next;
00744          else
00745             verboser = tmp->next;
00746          free(tmp);
00747          break;
00748       }
00749       tmpl = tmp;
00750       tmp = tmp->next;
00751    }
00752    if (tmp)
00753       res = 0;
00754    ast_mutex_unlock(&msglist_lock);
00755    return res;
00756 }

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

Send a verbose message (based on verbose level).

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 abscence of a comma after the VERBOSE_PREFIX_3. This is important. VERBOSE_PREFIX_1 through VERBOSE_PREFIX_3 are defined.

int ast_verbose_dmesg ( void(*)(const char *string, int opos, int replacelast, int complete)  verboser  ) 

Definition at line 698 of file logger.c.

00699 {
00700    struct msglist *m;
00701    ast_mutex_lock(&msglist_lock);
00702    m = list;
00703    while(m) {
00704       /* Send all the existing entries that we have queued (i.e. they're likely to have missed) */
00705       v(m->msg, 0, 0, 1);
00706       m = m->next;
00707    }
00708    ast_mutex_unlock(&msglist_lock);
00709    return 0;
00710 }


Generated on Wed Oct 28 17:00:58 2009 for Asterisk by  doxygen 1.5.6