Asterisk - The Open Source Telephony Project  GIT-master-a24979a
Macros | Typedefs | Enumerations | Functions | Variables
include/asterisk/logger.h File Reference

Support for logging to various files, console and syslog Configuration in file logger.conf. More...

#include "asterisk/options.h"
Include dependency graph for include/asterisk/logger.h:

Go to the source code of this file.

Macros

#define __LOG_DEBUG   0
 
#define __LOG_DTMF   6
 
#define __LOG_ERROR   4
 
#define __LOG_NOTICE   2
 
#define __LOG_TRACE   1
 
#define __LOG_VERBOSE   5
 
#define __LOG_WARNING   3
 
#define _A_   __FILE__, __LINE__, __FUNCTION__
 
#define AST_CALLID_BUFFER_LENGTH   13
 
#define ast_debug(level, ...)
 Log a DEBUG message. More...
 
#define AST_LOG_DEBUG   __LOG_DEBUG, _A_
 
#define AST_LOG_DTMF   __LOG_DTMF, _A_
 
#define ast_log_dynamic_level(level, ...)   ast_log(level, _A_, __VA_ARGS__)
 Send a log message to a dynamically registered log level. More...
 
#define AST_LOG_ERROR   __LOG_ERROR, _A_
 
#define AST_LOG_NOTICE   __LOG_NOTICE, _A_
 
#define AST_LOG_TRACE   __LOG_TRACE, _A_
 
#define AST_LOG_VERBOSE   __LOG_VERBOSE, _A_
 
#define AST_LOG_WARNING   __LOG_WARNING, _A_
 
#define ast_trace(level, ...)    ast_debug(level < 0 ? __scope_level : level, " " __VA_ARGS__)
 
#define ast_trace_dec_indent()
 
#define ast_trace_get_indent()   (0)
 
#define ast_trace_inc_indent()
 
#define ast_trace_log(__level, __log_level, ...)
 
#define ast_trace_raw(level, indent_type, ...)    ast_debug(level < 0 ? __scope_level : level, " " __VA_ARGS__)
 
#define ast_trace_set_indent(indent)
 
#define ast_verb(level, ...)
 
#define ast_verb_callid(level, callid, ...)
 
#define ast_verbose(...)   __ast_verbose(_A_, -1, __VA_ARGS__)
 
#define ast_verbose_callid(callid, ...)   __ast_verbose_callid(_A_, -1, callid, __VA_ARGS__)
 
#define DEBUG_ATLEAST(level)
 
#define DEBUG_M(a)
 
#define EVENTLOG   "event_log"
 
#define LOG_DEBUG   __LOG_DEBUG, _A_
 
#define LOG_DTMF   __LOG_DTMF, _A_
 
#define LOG_ERROR   __LOG_ERROR, _A_
 
#define LOG_NOTICE   __LOG_NOTICE, _A_
 
#define LOG_TRACE   __LOG_TRACE, _A_
 
#define LOG_VERBOSE   __LOG_VERBOSE, _A_
 
#define LOG_WARNING   __LOG_WARNING, _A_
 
#define NUMLOGLEVELS   32
 
#define QUEUELOG   "queue_log"
 
#define SCOPE_ENTER(level, ...)
 
#define SCOPE_ENTER_TASK(level, indent, ...)
 
#define SCOPE_EXIT(...)    ast_debug(__scope_level, " " __VA_ARGS__)
 
#define SCOPE_EXIT_EXPR(__expr, ...)
 
#define SCOPE_EXIT_LOG(__log_level, ...)
 
#define SCOPE_EXIT_LOG_EXPR(__expr, __log_level, ...)
 
#define SCOPE_EXIT_LOG_RTN(__log_level, ...)
 
#define SCOPE_EXIT_LOG_RTN_VALUE(__value, __log_level, ...)
 
#define SCOPE_EXIT_RTN(...)
 
#define SCOPE_EXIT_RTN_VALUE(__return_value, ...)
 
#define SCOPE_TRACE(__level, ...)
 
#define TRACE_ATLEAST(level)
 
#define VERBOSE_HASMAGIC(x)   (*(signed char *) (x) < 0)
 
#define VERBOSE_MAGIC2LEVEL(x)   (((char) -*(signed char *) (x)) - 1)
 
#define VERBOSE_PREFIX_1   " "
 
#define VERBOSE_PREFIX_2   " == "
 
#define VERBOSE_PREFIX_3   " -- "
 
#define VERBOSE_PREFIX_4   " > "
 
#define VERBOSITY_ATLEAST(level)   ((level) <= ast_verb_sys_level)
 

Typedefs

typedef unsigned int ast_callid
 

Enumerations

enum  ast_logger_results { AST_LOGGER_SUCCESS = 0 , AST_LOGGER_FAILURE = 1 , AST_LOGGER_DECLINE = -1 , AST_LOGGER_ALLOC_ERROR = -2 }
 
enum  ast_trace_indent_type {
  AST_TRACE_INDENT_SAME = 0 , AST_TRACE_INDENT_INC_BEFORE , AST_TRACE_INDENT_INC_AFTER , AST_TRACE_INDENT_DEC_BEFORE ,
  AST_TRACE_INDENT_DEC_AFTER , AST_TRACE_INDENT_PROVIDED , AST_TRACE_INDENT_NONE
}
 Controls if and when indenting is applied. More...
 

Functions

void __ast_verbose (const char *file, int line, const char *func, int level, const char *fmt,...)
 Send a verbose message (based on verbose level) More...
 
void __ast_verbose_ap (const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt, va_list ap)
 
void __ast_verbose_callid (const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt,...)
 Send a verbose message (based on verbose level) with deliberately specified callid. More...
 
void ast_callid_strnprint (char *buffer, size_t buffer_size, ast_callid callid)
 copy a string representation of the callid into a target string More...
 
int ast_callid_threadassoc_add (ast_callid callid)
 Adds a known callid to thread storage of the calling thread. More...
 
int ast_callid_threadassoc_change (ast_callid callid)
 Sets what is stored in the thread storage to the given callid if it does not match what is already there. More...
 
int ast_callid_threadassoc_remove (void)
 Removes callid from thread storage of the calling thread. More...
 
int ast_callid_threadstorage_auto (ast_callid *callid)
 Checks thread storage for a callid and stores a reference if it exists. If not, then a new one will be created, bound to the thread, and a reference to it will be stored. More...
 
void ast_callid_threadstorage_auto_clean (ast_callid callid, int callid_created)
 Use in conjunction with ast_callid_threadstorage_auto. Cleans up the references and if the callid was created by threadstorage_auto, unbinds the callid from the threadstorage. More...
 
void ast_child_verbose (int level, const char *fmt,...)
 
void ast_console_puts (const char *string)
 write the string to the root console, and all attached network console clients More...
 
void ast_console_puts_mutable (const char *string, int level)
 log the string to the console, and all attached console clients More...
 
void ast_console_puts_mutable_full (const char *message, int level, int sublevel)
 log the string to the console, and all attached console clients More...
 
void ast_console_toggle_loglevel (int fd, int level, int state)
 enables or disables logging of a specified level to the console fd specifies the index of the console receiving the level change level specifies the index of the logging level being toggled state indicates whether logging will be on or off (0 for off, 1 for on) More...
 
void ast_console_toggle_mute (int fd, int silent)
 mute or unmute a console from logging More...
 
ast_callid ast_create_callid (void)
 factory function to create a new uniquely identifying callid. More...
 
unsigned int ast_debug_get_by_module (const char *module)
 Get the debug level for a module. More...
 
void ast_init_logger_for_socket_console (void)
 load logger.conf configuration for console socket connections More...
 
int ast_is_logger_initialized (void)
 Test if logger is initialized. More...
 
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. More...
 
void ast_log_ap (int level, const char *file, int line, const char *function, const char *fmt, va_list ap)
 
void ast_log_backtrace (void)
 Log a backtrace of the current thread's execution stack to the Asterisk log. More...
 
void ast_log_callid (int level, const char *file, int line, const char *function, ast_callid callid, const char *fmt,...)
 Used for sending a log message with a known call_id This is a modified logger function which is 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. More...
 
void ast_log_safe (int level, const char *file, int line, const char *function, const char *fmt,...)
 Used for sending a log message with protection against recursion. More...
 
int ast_logger_create_channel (const char *log_channel, const char *components)
 Create a log channel. More...
 
int ast_logger_get_channels (int(*logentry)(const char *channel, const char *type, const char *status, const char *configuration, void *data), void *data)
 Retrieve the existing log channels. More...
 
const char * ast_logger_get_dateformat (void)
 Get the logger configured date format. More...
 
int ast_logger_get_dynamic_level (const char *name)
 Retrieve dynamic logging level id. More...
 
int ast_logger_get_queue_limit (void)
 Get the maximum number of messages allowed in the processing queue. More...
 
int ast_logger_register_level (const char *name)
 Register a new logger level. More...
 
int ast_logger_remove_channel (const char *log_channel)
 Delete the specified log channel. More...
 
int ast_logger_rotate (void)
 Reload logger while rotating log files. More...
 
int ast_logger_rotate_channel (const char *log_channel)
 Rotate the specified log channel. More...
 
void ast_logger_set_queue_limit (int queue_limit)
 Set the maximum number of messages allowed in the processing queue. More...
 
void ast_logger_unregister_level (const char *name)
 Unregister a previously registered logger level. More...
 
void ast_queue_log (const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt,...)
 
ast_callid ast_read_threadstorage_callid (void)
 extracts the callerid from the thread More...
 
int ast_register_verbose (void(*verboser)(const char *string)) attribute_warn_unused_result
 
unsigned int ast_trace_get_by_module (const char *module)
 Get the trace level for a module. More...
 
int ast_unregister_verbose (void(*verboser)(const char *string)) attribute_warn_unused_result
 
int ast_verb_console_get (void)
 Get this thread's console verbosity level. More...
 
void ast_verb_console_register (int *level)
 Register this thread's console verbosity level pointer. More...
 
void ast_verb_console_set (int verb_level)
 Set this thread's console verbosity level. More...
 
void ast_verb_console_unregister (void)
 Unregister this thread's console verbosity level. More...
 
void ast_verb_update (void)
 Re-evaluate the system max verbosity level (ast_verb_sys_level). More...
 

Variables

int ast_verb_sys_level
 

Detailed Description

Support for logging to various files, console and syslog Configuration in file logger.conf.

Definition in file include/asterisk/logger.h.

Macro Definition Documentation

◆ __LOG_DEBUG

#define __LOG_DEBUG   0

Definition at line 241 of file include/asterisk/logger.h.

◆ __LOG_DTMF

#define __LOG_DTMF   6

Definition at line 307 of file include/asterisk/logger.h.

◆ __LOG_ERROR

#define __LOG_ERROR   4

Definition at line 285 of file include/asterisk/logger.h.

◆ __LOG_NOTICE

#define __LOG_NOTICE   2

Definition at line 263 of file include/asterisk/logger.h.

◆ __LOG_TRACE

#define __LOG_TRACE   1

Definition at line 252 of file include/asterisk/logger.h.

◆ __LOG_VERBOSE

#define __LOG_VERBOSE   5

Definition at line 296 of file include/asterisk/logger.h.

◆ __LOG_WARNING

#define __LOG_WARNING   3

Definition at line 274 of file include/asterisk/logger.h.

◆ _A_

#define _A_   __FILE__, __LINE__, __FUNCTION__

Definition at line 42 of file include/asterisk/logger.h.

◆ AST_CALLID_BUFFER_LENGTH

#define AST_CALLID_BUFFER_LENGTH   13

Definition at line 49 of file include/asterisk/logger.h.

◆ ast_debug

#define ast_debug (   level,
  ... 
)
Value:
do { \
if (DEBUG_ATLEAST(level)) { \
ast_log(AST_LOG_DEBUG, __VA_ARGS__); \
} \
} while (0)
#define DEBUG_ATLEAST(level)
#define AST_LOG_DEBUG

Log a DEBUG message.

Parameters
levelThe minimum value of option_debug for this message to get logged
Examples
app_skel.c.

Definition at line 451 of file include/asterisk/logger.h.

◆ AST_LOG_DEBUG

#define AST_LOG_DEBUG   __LOG_DEBUG, _A_

Definition at line 247 of file include/asterisk/logger.h.

◆ AST_LOG_DTMF

#define AST_LOG_DTMF   __LOG_DTMF, _A_

Definition at line 313 of file include/asterisk/logger.h.

◆ ast_log_dynamic_level

#define ast_log_dynamic_level (   level,
  ... 
)    ast_log(level, _A_, __VA_ARGS__)

Send a log message to a dynamically registered log level.

Parameters
levelThe log level to send the message to

Like ast_log, the log message may include printf-style formats, and the data for these must be provided as additional parameters after the log message.

Since
1.8

Definition at line 438 of file include/asterisk/logger.h.

◆ AST_LOG_ERROR

#define AST_LOG_ERROR   __LOG_ERROR, _A_

Definition at line 291 of file include/asterisk/logger.h.

◆ AST_LOG_NOTICE

#define AST_LOG_NOTICE   __LOG_NOTICE, _A_

Definition at line 269 of file include/asterisk/logger.h.

◆ AST_LOG_TRACE

#define AST_LOG_TRACE   __LOG_TRACE, _A_

Definition at line 258 of file include/asterisk/logger.h.

◆ AST_LOG_VERBOSE

#define AST_LOG_VERBOSE   __LOG_VERBOSE, _A_

Definition at line 302 of file include/asterisk/logger.h.

◆ AST_LOG_WARNING

#define AST_LOG_WARNING   __LOG_WARNING, _A_

Definition at line 280 of file include/asterisk/logger.h.

◆ ast_trace

#define ast_trace (   level,
  ... 
)     ast_debug(level < 0 ? __scope_level : level, " " __VA_ARGS__)

Definition at line 872 of file include/asterisk/logger.h.

◆ ast_trace_dec_indent

#define ast_trace_dec_indent ( )

Definition at line 878 of file include/asterisk/logger.h.

◆ ast_trace_get_indent

#define ast_trace_get_indent ( )    (0)

Definition at line 875 of file include/asterisk/logger.h.

◆ ast_trace_inc_indent

#define ast_trace_inc_indent ( )

Definition at line 877 of file include/asterisk/logger.h.

◆ ast_trace_log

#define ast_trace_log (   __level,
  __log_level,
  ... 
)
Value:
({ \
ast_log(__log_level, " " __VA_ARGS__); \
ast_trace(__level < 0 ? __scope_level : __level, " " __VA_ARGS__); \
})

Definition at line 935 of file include/asterisk/logger.h.

◆ ast_trace_raw

#define ast_trace_raw (   level,
  indent_type,
  ... 
)     ast_debug(level < 0 ? __scope_level : level, " " __VA_ARGS__)

Definition at line 869 of file include/asterisk/logger.h.

◆ ast_trace_set_indent

#define ast_trace_set_indent (   indent)

Definition at line 876 of file include/asterisk/logger.h.

◆ ast_verb

#define ast_verb (   level,
  ... 
)
Value:
do { \
if (VERBOSITY_ATLEAST(level) ) { \
__ast_verbose(_A_, level, __VA_ARGS__); \
} \
} while (0)
#define _A_
#define VERBOSITY_ATLEAST(level)

Definition at line 462 of file include/asterisk/logger.h.

◆ ast_verb_callid

#define ast_verb_callid (   level,
  callid,
  ... 
)
Value:
do { \
if (VERBOSITY_ATLEAST(level) ) { \
__ast_verbose_callid(_A_, level, callid, __VA_ARGS__); \
} \
} while (0)

Definition at line 469 of file include/asterisk/logger.h.

◆ ast_verbose

#define ast_verbose (   ...)    __ast_verbose(_A_, -1, __VA_ARGS__)

Definition at line 180 of file include/asterisk/logger.h.

◆ ast_verbose_callid

#define ast_verbose_callid (   callid,
  ... 
)    __ast_verbose_callid(_A_, -1, callid, __VA_ARGS__)

Definition at line 181 of file include/asterisk/logger.h.

◆ DEBUG_ATLEAST

#define DEBUG_ATLEAST (   level)
Value:
(option_debug >= (level) \
&& ((int)ast_debug_get_by_module(AST_MODULE) >= (level) \
|| (int)ast_debug_get_by_module(__FILE__) >= (level))))
#define AST_MODULE
int option_debug
Definition: options.c:69
unsigned int ast_debug_get_by_module(const char *module)
Get the debug level for a module.
Definition: main/cli.c:136
#define ast_opt_dbg_module
Definition: options.h:128

Definition at line 440 of file include/asterisk/logger.h.

◆ DEBUG_M

#define DEBUG_M (   a)
Value:
{ \
a; \
}

Definition at line 38 of file include/asterisk/logger.h.

◆ EVENTLOG

#define EVENTLOG   "event_log"

Definition at line 35 of file include/asterisk/logger.h.

◆ LOG_DEBUG

#define LOG_DEBUG   __LOG_DEBUG, _A_

Definition at line 242 of file include/asterisk/logger.h.

◆ LOG_DTMF

#define LOG_DTMF   __LOG_DTMF, _A_

Definition at line 308 of file include/asterisk/logger.h.

◆ LOG_ERROR

#define LOG_ERROR   __LOG_ERROR, _A_
Examples
app_skel.c.

Definition at line 286 of file include/asterisk/logger.h.

◆ LOG_NOTICE

#define LOG_NOTICE   __LOG_NOTICE, _A_

Definition at line 264 of file include/asterisk/logger.h.

◆ LOG_TRACE

#define LOG_TRACE   __LOG_TRACE, _A_

Definition at line 253 of file include/asterisk/logger.h.

◆ LOG_VERBOSE

#define LOG_VERBOSE   __LOG_VERBOSE, _A_

Definition at line 297 of file include/asterisk/logger.h.

◆ LOG_WARNING

#define LOG_WARNING   __LOG_WARNING, _A_
Examples
app_skel.c.

Definition at line 275 of file include/asterisk/logger.h.

◆ NUMLOGLEVELS

#define NUMLOGLEVELS   32

Definition at line 315 of file include/asterisk/logger.h.

◆ QUEUELOG

#define QUEUELOG   "queue_log"

Definition at line 36 of file include/asterisk/logger.h.

◆ SCOPE_ENTER

#define SCOPE_ENTER (   level,
  ... 
)
Value:
int __scope_level = level; \
ast_debug(level, " " __VA_ARGS__)

Definition at line 881 of file include/asterisk/logger.h.

◆ SCOPE_ENTER_TASK

#define SCOPE_ENTER_TASK (   level,
  indent,
  ... 
)
Value:
int __scope_level = level; \
ast_debug(level, " " __VA_ARGS__)

Definition at line 885 of file include/asterisk/logger.h.

◆ SCOPE_EXIT

#define SCOPE_EXIT (   ...)     ast_debug(__scope_level, " " __VA_ARGS__)

Definition at line 889 of file include/asterisk/logger.h.

◆ SCOPE_EXIT_EXPR

#define SCOPE_EXIT_EXPR (   __expr,
  ... 
)
Value:
ast_debug(__scope_level, " " __VA_ARGS__); \
__expr
#define ast_debug(level,...)
Log a DEBUG message.

Definition at line 892 of file include/asterisk/logger.h.

◆ SCOPE_EXIT_LOG

#define SCOPE_EXIT_LOG (   __log_level,
  ... 
)
Value:
({ \
ast_log(__log_level, " " __VA_ARGS__); \
SCOPE_EXIT(" " __VA_ARGS__); \
})

The following macros will print log messages before running the associated SCOPE_ macro.

Definition at line 911 of file include/asterisk/logger.h.

◆ SCOPE_EXIT_LOG_EXPR

#define SCOPE_EXIT_LOG_EXPR (   __expr,
  __log_level,
  ... 
)
Value:
({ \
ast_log(__log_level, " " __VA_ARGS__); \
SCOPE_EXIT_EXPR(__expr, " " __VA_ARGS__); \
})

Definition at line 929 of file include/asterisk/logger.h.

◆ SCOPE_EXIT_LOG_RTN

#define SCOPE_EXIT_LOG_RTN (   __log_level,
  ... 
)
Value:
({ \
ast_log(__log_level, " " __VA_ARGS__); \
SCOPE_EXIT_RTN(" " __VA_ARGS__); \
})

Definition at line 917 of file include/asterisk/logger.h.

◆ SCOPE_EXIT_LOG_RTN_VALUE

#define SCOPE_EXIT_LOG_RTN_VALUE (   __value,
  __log_level,
  ... 
)
Value:
({ \
ast_log(__log_level, " " __VA_ARGS__); \
SCOPE_EXIT_RTN_VALUE(__value, " " __VA_ARGS__); \
})

Definition at line 923 of file include/asterisk/logger.h.

◆ SCOPE_EXIT_RTN

#define SCOPE_EXIT_RTN (   ...)
Value:
ast_debug(__scope_level, " " __VA_ARGS__); \
return

Definition at line 896 of file include/asterisk/logger.h.

◆ SCOPE_EXIT_RTN_VALUE

#define SCOPE_EXIT_RTN_VALUE (   __return_value,
  ... 
)
Value:
ast_debug(__scope_level, " " __VA_ARGS__); \
return __return_value

Definition at line 900 of file include/asterisk/logger.h.

◆ SCOPE_TRACE

#define SCOPE_TRACE (   __level,
  ... 
)

Definition at line 879 of file include/asterisk/logger.h.

◆ TRACE_ATLEAST

#define TRACE_ATLEAST (   level)
Value:
(option_trace >= (level) \
&& ((int)ast_trace_get_by_module(AST_MODULE) >= (level) \
|| (int)ast_trace_get_by_module(__FILE__) >= (level))))
int option_trace
Definition: options.c:71
unsigned int ast_trace_get_by_module(const char *module)
Get the trace level for a module.
Definition: main/cli.c:153
#define ast_opt_trace_module
Definition: options.h:129

Definition at line 627 of file include/asterisk/logger.h.

◆ VERBOSE_HASMAGIC

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

Definition at line 196 of file include/asterisk/logger.h.

◆ VERBOSE_MAGIC2LEVEL

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

Definition at line 195 of file include/asterisk/logger.h.

◆ VERBOSE_PREFIX_1

#define VERBOSE_PREFIX_1   " "

Definition at line 44 of file include/asterisk/logger.h.

◆ VERBOSE_PREFIX_2

#define VERBOSE_PREFIX_2   " == "

Definition at line 45 of file include/asterisk/logger.h.

◆ VERBOSE_PREFIX_3

#define VERBOSE_PREFIX_3   " -- "

Definition at line 46 of file include/asterisk/logger.h.

◆ VERBOSE_PREFIX_4

#define VERBOSE_PREFIX_4   " > "

Definition at line 47 of file include/asterisk/logger.h.

◆ VERBOSITY_ATLEAST

#define VERBOSITY_ATLEAST (   level)    ((level) <= ast_verb_sys_level)

Definition at line 460 of file include/asterisk/logger.h.

Typedef Documentation

◆ ast_callid

typedef unsigned int ast_callid

Definition at line 90 of file include/asterisk/logger.h.

Enumeration Type Documentation

◆ ast_logger_results

Enumerator
AST_LOGGER_SUCCESS 

Log channel was created or deleted successfully

AST_LOGGER_FAILURE 

Log channel already exists for create or doesn't exist for deletion of log channel

AST_LOGGER_DECLINE 

Log channel request was not accepted

AST_LOGGER_ALLOC_ERROR 

filename allocation error

Definition at line 51 of file include/asterisk/logger.h.

51  {
52  AST_LOGGER_SUCCESS = 0, /*!< Log channel was created or deleted successfully*/
53  AST_LOGGER_FAILURE = 1, /*!< Log channel already exists for create or doesn't exist for deletion of log channel */
54  AST_LOGGER_DECLINE = -1, /*!< Log channel request was not accepted */
55  AST_LOGGER_ALLOC_ERROR = -2 /*!< filename allocation error */
56 };
@ AST_LOGGER_DECLINE
@ AST_LOGGER_FAILURE
@ AST_LOGGER_SUCCESS
@ AST_LOGGER_ALLOC_ERROR

◆ ast_trace_indent_type

Controls if and when indenting is applied.

Enumerator
AST_TRACE_INDENT_SAME 

Use the existing indent level

AST_TRACE_INDENT_INC_BEFORE 

Increment the indent before printing the message

AST_TRACE_INDENT_INC_AFTER 

Increment the indent after printing the message

AST_TRACE_INDENT_DEC_BEFORE 

Decrement the indent before printing the message

AST_TRACE_INDENT_DEC_AFTER 

Decrement the indent after printing the message

AST_TRACE_INDENT_PROVIDED 

Set the indent to the one provided

AST_TRACE_INDENT_NONE 

Don't use or alter the level

Definition at line 636 of file include/asterisk/logger.h.

636  {
637  /*! Use the existing indent level */
639  /*! Increment the indent before printing the message */
641  /*! Increment the indent after printing the message */
643  /*! Decrement the indent before printing the message */
645  /*! Decrement the indent after printing the message */
647  /*! Set the indent to the one provided */
649  /*! Don't use or alter the level */
651 };
@ AST_TRACE_INDENT_INC_BEFORE
@ AST_TRACE_INDENT_SAME
@ AST_TRACE_INDENT_PROVIDED
@ AST_TRACE_INDENT_NONE
@ AST_TRACE_INDENT_INC_AFTER
@ AST_TRACE_INDENT_DEC_BEFORE
@ AST_TRACE_INDENT_DEC_AFTER

Function Documentation

◆ __ast_verbose()

void __ast_verbose ( const char *  file,
int  line,
const char *  func,
int  level,
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 absence of a comma after the VERBOSE_PREFIX_3. This is important. VERBOSE_PREFIX_1 through VERBOSE_PREFIX_4 are defined.

Version
11 added level parameter

Definition at line 2284 of file logger.c.

2285 {
2286  ast_callid callid;
2287  va_list ap;
2288 
2289  callid = ast_read_threadstorage_callid();
2290 
2291  va_start(ap, fmt);
2292  __ast_verbose_ap(file, line, func, level, callid, fmt, ap);
2293  va_end(ap);
2294 }
unsigned int ast_callid
void __ast_verbose_ap(const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt, va_list ap)
Definition: logger.c:2279
ast_callid ast_read_threadstorage_callid(void)
extracts the callerid from the thread
Definition: logger.c:2048

References __ast_verbose_ap(), ast_read_threadstorage_callid(), and make_ari_stubs::file.

◆ __ast_verbose_ap()

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

Definition at line 2279 of file logger.c.

2280 {
2281  ast_log_full(__LOG_VERBOSE, level, file, line, func, callid, fmt, ap);
2282 }
#define __LOG_VERBOSE
static void ast_log_full(int level, int sublevel, const char *file, int line, const char *function, ast_callid callid, const char *fmt, va_list ap)
send log messages to syslog and/or the console
Definition: logger.c:2139

References __LOG_VERBOSE, ast_log_full(), and make_ari_stubs::file.

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

◆ __ast_verbose_callid()

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

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

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.

Definition at line 2296 of file logger.c.

2297 {
2298  va_list ap;
2299  va_start(ap, fmt);
2300  __ast_verbose_ap(file, line, func, level, callid, fmt, ap);
2301  va_end(ap);
2302 }

References __ast_verbose_ap(), and make_ari_stubs::file.

◆ ast_callid_strnprint()

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

copy a string representation of the callid into a target string

Parameters
bufferdestination of callid string (should be able to store 13 characters or more)
buffer_sizemaximum writable length of the string (Less than 13 will result in truncation)
callidCallid for which string is being requested

Definition at line 2038 of file logger.c.

2039 {
2040  snprintf(buffer, buffer_size, "[C-%08x]", callid);
2041 }

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

◆ ast_callid_threadassoc_add()

int ast_callid_threadassoc_add ( ast_callid  callid)

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

Return values
0- success
non-zero- failure

Definition at line 2070 of file logger.c.

2071 {
2072  ast_callid *pointing;
2073 
2074  pointing = ast_threadstorage_get(&unique_callid, sizeof(*pointing));
2075  if (!pointing) {
2076  return -1;
2077  }
2078 
2079  if (*pointing) {
2080  ast_log(LOG_ERROR, "ast_callid_threadassoc_add(C-%08x) on thread "
2081  "already associated with callid [C-%08x].\n", callid, *pointing);
2082  return 1;
2083  }
2084 
2085  *pointing = callid;
2086  return 0;
2087 }
#define LOG_ERROR
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:2187
static struct ast_threadstorage unique_callid
Definition: logger.c:93
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.

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

Referenced by __analog_ss_thread(), ast_callid_threadstorage_auto(), ast_dial_run(), attended_transfer_monitor_thread(), bridge_channel_control_thread(), bridge_channel_depart_thread(), bridge_channel_ind_thread(), handle_request_do(), jingle_action_hook(), jingle_outgoing_hook(), mixmonitor_thread(), socket_process_helper(), and softmix_mixing_thread().

◆ ast_callid_threadassoc_change()

int ast_callid_threadassoc_change ( ast_callid  callid)

Sets what is stored in the thread storage to the given callid if it does not match what is already there.

Return values
0- success
non-zero- failure

Definition at line 2057 of file logger.c.

2058 {
2059  ast_callid *id = ast_threadstorage_get(&unique_callid, sizeof(*id));
2060 
2061  if (!id) {
2062  return -1;
2063  }
2064 
2065  *id = callid;
2066 
2067  return 0;
2068 }

References ast_threadstorage_get(), and unique_callid.

Referenced by autoservice_run(), and bridge_manager_service().

◆ ast_callid_threadassoc_remove()

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 2089 of file logger.c.

2090 {
2091  ast_callid *pointing;
2092 
2093  pointing = ast_threadstorage_get(&unique_callid, sizeof(*pointing));
2094  if (!pointing) {
2095  return -1;
2096  }
2097 
2098  if (*pointing) {
2099  *pointing = 0;
2100  return 0;
2101  }
2102 
2103  return -1;
2104 }

References ast_threadstorage_get(), and unique_callid.

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

◆ ast_callid_threadstorage_auto()

int ast_callid_threadstorage_auto ( ast_callid callid)

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

Parameters
callidpointer to store the callid
Return values
0- callid was found
1- callid was created
-1- the function failed somehow (presumably memory problems)

Definition at line 2106 of file logger.c.

2107 {
2108  ast_callid tmp;
2109 
2110  /* Start by trying to see if a callid is available from thread storage */
2112  if (tmp) {
2113  *callid = tmp;
2114  return 0;
2115  }
2116 
2117  /* If that failed, try to create a new one and bind it. */
2118  *callid = ast_create_callid();
2119  if (*callid) {
2120  ast_callid_threadassoc_add(*callid);
2121  return 1;
2122  }
2123 
2124  /* If neither worked, then something must have gone wrong. */
2125  return -1;
2126 }
static int tmp()
Definition: bt_open.c:389
int ast_callid_threadassoc_add(ast_callid callid)
Adds a known callid to thread storage of the calling thread.
Definition: logger.c:2070
ast_callid ast_create_callid(void)
factory function to create a new uniquely identifying callid.
Definition: logger.c:2043

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

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

◆ ast_callid_threadstorage_auto_clean()

void ast_callid_threadstorage_auto_clean ( ast_callid  callid,
int  callid_created 
)

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

Parameters
callidThe callid set by ast_callid_threadstorage_auto
callid_createdThe integer returned through ast_callid_threadstorage_auto

Definition at line 2128 of file logger.c.

2129 {
2130  if (callid && callid_created) {
2131  /* If the callid was created rather than simply grabbed from the thread storage, we need to unbind here. */
2133  }
2134 }
int ast_callid_threadassoc_remove(void)
Removes callid from thread storage of the calling thread.
Definition: logger.c:2089

References ast_callid_threadassoc_remove().

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

◆ ast_child_verbose()

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

Definition at line 908 of file logger.c.

909 {
910  char *msg = NULL, *emsg = NULL, *sptr, *eptr;
911  va_list ap, aq;
912  int size;
913 
914  va_start(ap, fmt);
915  va_copy(aq, ap);
916  if ((size = vsnprintf(msg, 0, fmt, ap)) < 0) {
917  va_end(ap);
918  va_end(aq);
919  return;
920  }
921  va_end(ap);
922 
923  if (!(msg = ast_malloc(size + 1))) {
924  va_end(aq);
925  return;
926  }
927 
928  vsnprintf(msg, size + 1, fmt, aq);
929  va_end(aq);
930 
931  if (!(emsg = ast_malloc(size * 2 + 1))) {
932  ast_free(msg);
933  return;
934  }
935 
936  for (sptr = msg, eptr = emsg; ; sptr++) {
937  if (*sptr == '"') {
938  *eptr++ = '\\';
939  }
940  *eptr++ = *sptr;
941  if (*sptr == '\0') {
942  break;
943  }
944  }
945  ast_free(msg);
946 
947  fprintf(stdout, "verbose \"%s\" %d\n", emsg, level);
948  fflush(stdout);
949  ast_free(emsg);
950 }
#define ast_free(a)
Definition: astmm.h:180
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:191
#define NULL
Definition: resample.c:96

References ast_free, ast_malloc, and NULL.

◆ ast_console_puts()

void ast_console_puts ( const char *  string)

write the string to the root console, and all attached network console clients

Definition at line 1350 of file asterisk.c.

1351 {
1352  /* Send to the root console */
1353  fputs(string, stdout);
1354  fflush(stdout);
1355 
1356  /* Send to any network console clients */
1357  ast_network_puts(string);
1358 }
static void ast_network_puts(const char *string)
write the string to all attached console clients
Definition: asterisk.c:1334

References ast_network_puts().

◆ ast_console_puts_mutable()

void ast_console_puts_mutable ( const char *  string,
int  level 
)

log the string to the console, and all attached console clients

Parameters
stringThe message to write to the console
levelThe log level of the message
Version
1.6.1 added level parameter

log the string to the console, and all attached console clients

Definition at line 1310 of file asterisk.c.

1311 {
1312  ast_console_puts_mutable_full(string, level, 0);
1313 }
void ast_console_puts_mutable_full(const char *message, int level, int sublevel)
log the string to the console, and all attached console clients
Definition: asterisk.c:1317

References ast_console_puts_mutable_full().

Referenced by init_logger_chain(), and make_logchannel().

◆ ast_console_puts_mutable_full()

void ast_console_puts_mutable_full ( const char *  message,
int  level,
int  sublevel 
)

log the string to the console, and all attached console clients

Since
14.0.0
Parameters
messageThe message to write to the console
sublevelIf the log level supports it, the sub-level of the message
levelThe log level of the message

Definition at line 1317 of file asterisk.c.

1318 {
1319  /* Send to the root console */
1321 
1322  /* Wake up a poll()ing console */
1324  pthread_kill(consolethread, SIGURG);
1325  }
1326 
1327  /* Send to any network console clients */
1328  ast_network_puts_mutable(message, level, sublevel);
1329 }
static void ast_network_puts_mutable(const char *string, int level, int sublevel)
log the string to all attached network console clients
Definition: asterisk.c:1291
static pthread_t consolethread
Definition: asterisk.c:384
static int console_print(const char *s)
Definition: asterisk.c:2198
#define AST_PTHREADT_NULL
Definition: lock.h:66
#define ast_opt_console
Definition: options.h:109

References ast_network_puts_mutable(), ast_opt_console, AST_PTHREADT_NULL, console_print(), and consolethread.

Referenced by ast_console_puts_mutable(), and logger_print_normal().

◆ ast_console_toggle_loglevel()

void ast_console_toggle_loglevel ( int  fd,
int  level,
int  state 
)

enables or disables logging of a specified level to the console fd specifies the index of the console receiving the level change level specifies the index of the logging level being toggled state indicates whether logging will be on or off (0 for off, 1 for on)

enables or disables logging of a specified level to the console fd specifies the index of the console receiving the level change level specifies the index of the logging level being toggled state indicates whether logging will be on or off (0 for off, 1 for on)

Definition at line 1245 of file asterisk.c.

1246 {
1247  int x;
1248 
1249  if (level >= NUMLOGLEVELS) {
1250  level = NUMLOGLEVELS - 1;
1251  }
1252 
1253  for (x = 0;x < AST_MAX_CONNECTS; x++) {
1254  if (fd == consoles[x].fd) {
1255  /*
1256  * Since the logging occurs when levels are false, set to
1257  * flipped iinput because this function accepts 0 as off and 1 as on
1258  */
1259  consoles[x].levels[level] = state ? 0 : 1;
1260  return;
1261  }
1262  }
1263 }
#define AST_MAX_CONNECTS
Definition: asterisk.c:296
struct console consoles[AST_MAX_CONNECTS]
Definition: asterisk.c:343
#define NUMLOGLEVELS
int levels[NUMLOGLEVELS]
Definition: asterisk.c:323

References AST_MAX_CONNECTS, consoles, console::levels, and NUMLOGLEVELS.

Referenced by handle_logger_set_level().

◆ ast_console_toggle_mute()

void ast_console_toggle_mute ( int  fd,
int  silent 
)

mute or unmute a console from logging

Definition at line 1268 of file asterisk.c.

1269 {
1270  int x;
1271  for (x = 0;x < AST_MAX_CONNECTS; x++) {
1272  if (fd == consoles[x].fd) {
1273  if (consoles[x].mute) {
1274  consoles[x].mute = 0;
1275  if (!silent)
1276  ast_cli(fd, "Console is not muted anymore.\n");
1277  } else {
1278  consoles[x].mute = 1;
1279  if (!silent)
1280  ast_cli(fd, "Console is muted.\n");
1281  }
1282  return;
1283  }
1284  }
1285  ast_cli(fd, "Couldn't find remote console.\n");
1286 }
static int mute
Definition: chan_alsa.c:148
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
int mute
Definition: asterisk.c:320

References ast_cli(), AST_MAX_CONNECTS, consoles, mute, and console::mute.

Referenced by handle_logger_mute().

◆ ast_create_callid()

ast_callid ast_create_callid ( void  )

factory function to create a new uniquely identifying callid.

Returns
The call id

Definition at line 2043 of file logger.c.

2044 {
2046 }
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
Definition: lock.h:755
static volatile int next_unique_callid
Definition: logger.c:90

References ast_atomic_fetchadd_int(), and next_unique_callid.

Referenced by __find_call(), ast_callid_threadstorage_auto(), iax_pvt_callid_new(), and jingle_alloc().

◆ ast_debug_get_by_module()

unsigned int ast_debug_get_by_module ( const char *  module)

Get the debug level for a module.

Parameters
modulethe name of module
Returns
the debug level

Definition at line 136 of file main/cli.c.

137 {
138  struct module_level *ml;
139  unsigned int res = 0;
140 
143  if (!strcasecmp(ml->module, module)) {
144  res = ml->level;
145  break;
146  }
147  }
149 
150  return res;
151 }
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:78
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
static struct module_level_list debug_modules
Definition: main/cli.c:107
Definition: search.h:40
map a debug or verbose level to a module name
Definition: main/cli.c:98
unsigned int level
Definition: main/cli.c:99

References AST_LIST_TRAVERSE, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, debug_modules, and module_level::level.

◆ ast_init_logger_for_socket_console()

void ast_init_logger_for_socket_console ( void  )

load logger.conf configuration for console socket connections

Definition at line 700 of file logger.c.

701 {
702  struct ast_config *cfg;
703  const char *s;
704  struct ast_flags config_flags = { 0 };
705 
706  if (!(cfg = ast_config_load2("logger.conf", "logger", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
707  return;
708  }
709 
710  if ((s = ast_variable_retrieve(cfg, "general", "dateformat"))) {
712  }
713 
714  ast_config_destroy(cfg);
715 }
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
Definition: extconf.c:1289
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
Definition: main/config.c:768
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
Definition: main/config.c:3220
static char dateformat[256]
Definition: logger.c:81
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:406
Structure used to handle boolean flags.
Definition: utils.h:199

References ast_config_destroy(), ast_config_load2(), ast_copy_string(), ast_variable_retrieve(), CONFIG_STATUS_FILEINVALID, and dateformat.

Referenced by ast_remotecontrol().

◆ ast_is_logger_initialized()

int ast_is_logger_initialized ( void  )

Test if logger is initialized.

Return values
trueif the logger is initialized

Definition at line 1929 of file logger.c.

1930 {
1931  return logger_initialized;
1932 }
static int logger_initialized
Definition: logger.c:89

References logger_initialized.

Referenced by check_init().

◆ ast_log()

static 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
levelType of log event
fileWill be provided by the AST_LOG_* macro
lineWill be provided by the AST_LOG_* macro
functionWill be provided by the AST_LOG_* macro
fmtThis is what is important. The format is the same as your favorite breed of printf. You know how that works, right? :-)

Definition at line 130 of file ael_main.c.

131 {
132  va_list vars;
133  va_start(vars,fmt);
134 
135  printf("LOG: lev:%d file:%s line:%d func: %s ",
136  level, file, line, function);
137  vprintf(fmt, vars);
138  fflush(stdout);
139  va_end(vars);
140 }

References ast_log_ap(), make_ari_stubs::file, logmsg::level, and logmsg::line.

Referenced by ast_callid_threadassoc_add(), ast_log_backtrace(), init_logger(), logger_queue_init(), logger_queue_restart(), logger_register_level(), main(), and rotate_file().

◆ ast_log_ap()

void ast_log_ap ( int  level,
const char *  file,
int  line,
const char *  function,
const char *  fmt,
va_list  ap 
)

Definition at line 2196 of file logger.c.

2197 {
2198  ast_callid callid;
2199 
2200  callid = ast_read_threadstorage_callid();
2201 
2202  if (level == __LOG_VERBOSE) {
2203  __ast_verbose_ap(file, line, function, 0, callid, fmt, ap);
2204  } else {
2205  ast_log_full(level, -1, file, line, function, callid, fmt, ap);
2206  }
2207 }

References __ast_verbose_ap(), __LOG_VERBOSE, ast_log_full(), ast_read_threadstorage_callid(), logmsg::callid, make_ari_stubs::file, logmsg::level, and logmsg::line.

Referenced by ast_log(), and module_load_error().

◆ ast_log_backtrace()

void ast_log_backtrace ( void  )

Log a backtrace of the current thread's execution stack to the Asterisk log.

Definition at line 2244 of file logger.c.

2245 {
2246 #ifdef HAVE_BKTR
2247  struct ast_bt *bt;
2248  int i = 0;
2249  struct ast_vector_string *strings;
2250 
2251  if (!(bt = ast_bt_create())) {
2252  ast_log(LOG_WARNING, "Unable to allocate space for backtrace structure\n");
2253  return;
2254  }
2255 
2256  if ((strings = ast_bt_get_symbols(bt->addresses, bt->num_frames))) {
2257  int count = AST_VECTOR_SIZE(strings);
2258  struct ast_str *buf = ast_str_create(bt->num_frames * 64);
2259 
2260  if (buf) {
2261  ast_str_append(&buf, 0, "Got %d backtrace record%c\n", count - 3, count - 3 != 1 ? 's' : ' ');
2262  for (i = 3; i < AST_VECTOR_SIZE(strings); i++) {
2263  ast_str_append(&buf, 0, "#%2d: %s\n", i - 3, AST_VECTOR_GET(strings, i));
2264  }
2266  ast_free(buf);
2267  }
2268 
2269  ast_bt_free_symbols(strings);
2270  } else {
2271  ast_log(LOG_ERROR, "Could not allocate memory for backtrace\n");
2272  }
2273  ast_bt_destroy(bt);
2274 #else
2275  ast_log(LOG_WARNING, "Must run configure with '--with-execinfo' for stack backtraces.\n");
2276 #endif /* defined(HAVE_BKTR) */
2277 }
#define ast_bt_free_symbols(string_vector)
Definition: backtrace.h:42
#define ast_bt_get_symbols(addresses, num_frames)
Definition: backtrace.h:41
#define ast_bt_create()
Definition: backtrace.h:39
#define ast_bt_destroy(bt)
Definition: backtrace.h:40
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define __LOG_ERROR
#define LOG_WARNING
void ast_log_safe(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message with protection against recursion.
Definition: logger.c:2209
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1117
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:739
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:640
A structure to hold backtrace information. This structure provides an easy means to store backtrace i...
Definition: backtrace.h:50
void * addresses[AST_MAX_BT_FRAMES]
Definition: backtrace.h:52
int num_frames
Definition: backtrace.h:54
Support for dynamic strings.
Definition: strings.h:604
String vector definitions.
Definition: vector.h:55
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:609
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:680

References __LOG_ERROR, ast_bt::addresses, ast_bt_create, ast_bt_destroy, ast_bt_free_symbols, ast_bt_get_symbols, ast_free, ast_log(), ast_log_safe(), ast_str_append(), ast_str_buffer(), ast_str_create, AST_VECTOR_GET, AST_VECTOR_SIZE, buf, LOG_ERROR, LOG_WARNING, NULL, and ast_bt::num_frames.

Referenced by __ast_assert_failed(), ast_json_vpack(), ast_sched_del_nonrunning(), and AST_TEST_DEFINE().

◆ ast_log_callid()

void ast_log_callid ( int  level,
const char *  file,
int  line,
const char *  function,
ast_callid  callid,
const char *  fmt,
  ... 
)

Used for sending a log message with a known call_id This is a modified logger function which is 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
levelType of log event
fileWill be provided by the AST_LOG_* macro
lineWill be provided by the AST_LOG_* macro
functionWill be provided by the AST_LOG_* macro
callidThis is the ast_callid that is associated with the log message. May be NULL.
fmtThis is what is important. The format is the same as your favorite breed of printf. You know how that works, right? :-)

Definition at line 2235 of file logger.c.

2236 {
2237  va_list ap;
2238  va_start(ap, fmt);
2239  ast_log_full(level, -1, file, line, function, callid, fmt, ap);
2240  va_end(ap);
2241 }

References ast_log_full(), logmsg::callid, make_ari_stubs::file, logmsg::level, and logmsg::line.

Referenced by ast_channel_destructor().

◆ ast_log_safe()

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

Used for sending a log message with protection against recursion.

Note
This function should be used by all error messages that might be directly or indirectly caused by logging.
See also
ast_log for documentation on the parameters.

Definition at line 2209 of file logger.c.

2210 {
2211  va_list ap;
2212  void *recursed = ast_threadstorage_get_ptr(&in_safe_log);
2213  ast_callid callid;
2214 
2215  if (recursed) {
2216  return;
2217  }
2218 
2219  if (ast_threadstorage_set_ptr(&in_safe_log, &(int) { 1 })) {
2220  /* We've failed to set the flag that protects against
2221  * recursion, so bail. */
2222  return;
2223  }
2224 
2225  callid = ast_read_threadstorage_callid();
2226 
2227  va_start(ap, fmt);
2228  ast_log_full(level, -1, file, line, function, callid, fmt, ap);
2229  va_end(ap);
2230 
2231  /* Clear flag so the next allocation failure can be logged. */
2232  ast_threadstorage_set_ptr(&in_safe_log, NULL);
2233 }
int ast_threadstorage_set_ptr(struct ast_threadstorage *ts, void *ptr)
Set a raw pointer from threadstorage.
void * ast_threadstorage_get_ptr(struct ast_threadstorage *ts)
Retrieve a raw pointer from threadstorage.

References ast_log_full(), ast_read_threadstorage_callid(), ast_threadstorage_get_ptr(), ast_threadstorage_set_ptr(), logmsg::callid, make_ari_stubs::file, logmsg::level, logmsg::line, and NULL.

Referenced by __ast_str_helper(), and ast_log_backtrace().

◆ ast_logger_create_channel()

int ast_logger_create_channel ( const char *  log_channel,
const char *  components 
)

Create a log channel.

Parameters
log_channelLog channel to create
componentsLogging config levels to add to the log channel

Definition at line 1508 of file logger.c.

1509 {
1510  struct logchannel *chan;
1511 
1512  if (ast_strlen_zero(components)) {
1513  return AST_LOGGER_DECLINE;
1514  }
1515 
1517 
1518  chan = find_logchannel(log_channel);
1519  if (chan) {
1521  return AST_LOGGER_FAILURE;
1522  }
1523 
1524  chan = make_logchannel(log_channel, components, 0, 1);
1525  if (!chan) {
1527  return AST_LOGGER_ALLOC_ERROR;
1528  }
1529 
1531  global_logmask |= chan->logmask;
1532 
1534 
1535  return AST_LOGGER_SUCCESS;
1536 }
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
#define AST_RWLIST_INSERT_HEAD
Definition: linkedlists.h:718
static unsigned int global_logmask
Definition: logger.c:87
static struct logchannel * make_logchannel(const char *channel, const char *components, int lineno, int dynamic)
Definition: logger.c:633
static struct logchannel * find_logchannel(const char *channel)
Find a particular logger channel by name.
Definition: logger.c:617
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
struct logchannel::@398 list
unsigned int logmask
Definition: logger.c:142
char components[0]
Definition: logger.c:162

References AST_LOGGER_ALLOC_ERROR, AST_LOGGER_DECLINE, AST_LOGGER_FAILURE, AST_LOGGER_SUCCESS, AST_RWLIST_INSERT_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strlen_zero(), logchannel::components, find_logchannel(), global_logmask, logchannel::list, logchannel::logmask, and make_logchannel().

Referenced by ast_ari_asterisk_add_log(), and handle_logger_add_channel().

◆ ast_logger_get_channels()

int ast_logger_get_channels ( int(*)(const char *channel, const char *type, const char *status, const char *configuration, void *data)  logentry,
void *  data 
)

Retrieve the existing log channels.

Parameters
logentryA callback to an updater function
dataData passed into the callback for manipulation

For each of the logging channels, logentry will be executed with the channel file name, log type, status of the log, and configuration levels.

Return values
0on success
1on failure
-2on allocation error

Definition at line 1396 of file logger.c.

1398 {
1399  struct logchannel *chan;
1400  struct ast_str *configs = ast_str_create(64);
1401  int res = AST_LOGGER_SUCCESS;
1402 
1403  if (!configs) {
1404  return AST_LOGGER_ALLOC_ERROR;
1405  }
1406 
1408  AST_RWLIST_TRAVERSE(&logchannels, chan, list) {
1409  unsigned int level;
1410 
1412 
1413  for (level = 0; level < ARRAY_LEN(levels); level++) {
1414  if ((chan->logmask & (1 << level)) && levels[level]) {
1415  ast_str_append(&configs, 0, "%s ", levels[level]);
1416  }
1417  }
1418 
1419  res = logentry(chan->filename, chan->type == LOGTYPE_CONSOLE ? "Console" :
1420  (chan->type == LOGTYPE_SYSLOG ? "Syslog" : "File"), chan->disabled ?
1421  "Disabled" : "Enabled", ast_str_buffer(configs), data);
1422 
1423  if (res) {
1425  ast_free(configs);
1426  configs = NULL;
1427  return AST_LOGGER_FAILURE;
1428  }
1429  }
1431 
1432  ast_free(configs);
1433  configs = NULL;
1434 
1435  return AST_LOGGER_SUCCESS;
1436 }
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:494
static char * levels[NUMLOGLEVELS]
Logging channels used in the Asterisk logging system.
Definition: logger.c:213
@ LOGTYPE_CONSOLE
Definition: logger.c:135
@ LOGTYPE_SYSLOG
Definition: logger.c:133
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
Definition: strings.h:674
enum logtypes type
Definition: logger.c:150
char filename[PATH_MAX]
Definition: logger.c:154
int disabled
Definition: logger.c:144
#define ARRAY_LEN(a)
Definition: utils.h:661

References ARRAY_LEN, ast_free, AST_LOGGER_ALLOC_ERROR, AST_LOGGER_FAILURE, AST_LOGGER_SUCCESS, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_str_append(), ast_str_buffer(), ast_str_create, ast_str_reset(), logchannel::disabled, logchannel::filename, levels, logchannel::logmask, LOGTYPE_CONSOLE, LOGTYPE_SYSLOG, NULL, and logchannel::type.

Referenced by ast_ari_asterisk_list_log_channels().

◆ ast_logger_get_dateformat()

const char* ast_logger_get_dateformat ( void  )

Get the logger configured date format.

Returns
The date format string
Since
13.0.0

Definition at line 2661 of file logger.c.

2662 {
2663  return dateformat;
2664 }

References dateformat.

Referenced by set_header().

◆ ast_logger_get_dynamic_level()

int ast_logger_get_dynamic_level ( const char *  name)

Retrieve dynamic logging level id.

Parameters
nameThe name of the level
Returns
The unique integer id for the given level
Return values
-1if level name not found

Definition at line 2614 of file logger.c.

2615 {
2616  int level = -1;
2617 
2619 
2620  level = logger_get_dynamic_level(name);
2621 
2623 
2624  return level;
2625 }
static const char name[]
Definition: format_mp3.c:68
static int logger_get_dynamic_level(const char *name)
Definition: logger.c:2596

References AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, logger_get_dynamic_level(), and name.

Referenced by log_exec().

◆ ast_logger_get_queue_limit()

int ast_logger_get_queue_limit ( void  )

Get the maximum number of messages allowed in the processing queue.

Returns
Queue limit

Definition at line 2671 of file logger.c.

2672 {
2673  return logger_queue_limit;
2674 }
static int logger_queue_limit
Definition: logger.c:96

References logger_queue_limit.

◆ ast_logger_register_level()

int ast_logger_register_level ( const char *  name)

Register a new logger level.

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

Definition at line 2585 of file logger.c.

2586 {
2587  int available = 0;
2588 
2592 
2593  return available;
2594 }
static int available(struct dahdi_pvt **pvt, int is_specific_channel)
Definition: chan_dahdi.c:13095
static int logger_register_level(const char *name)
Definition: logger.c:2548

References AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, available(), logger_register_level(), and name.

Referenced by handle_cli_dynamic_level_test(), handle_cli_performance_test(), and load_module().

◆ ast_logger_remove_channel()

int ast_logger_remove_channel ( const char *  log_channel)

Delete the specified log channel.

Parameters
log_channelThe log channel to delete

Definition at line 1574 of file logger.c.

1575 {
1576  struct logchannel *chan;
1577 
1579 
1580  chan = find_logchannel(log_channel);
1581  if (chan && chan->dynamic) {
1583  } else {
1585  return AST_LOGGER_FAILURE;
1586  }
1588 
1589  if (chan->fileptr) {
1590  fclose(chan->fileptr);
1591  chan->fileptr = NULL;
1592  }
1593  ast_free(chan);
1594  chan = NULL;
1595 
1596  return AST_LOGGER_SUCCESS;
1597 }
#define AST_RWLIST_REMOVE
Definition: linkedlists.h:885
int dynamic
Definition: logger.c:160
FILE * fileptr
Definition: logger.c:152

References ast_free, AST_LOGGER_FAILURE, AST_LOGGER_SUCCESS, AST_RWLIST_REMOVE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, logchannel::dynamic, logchannel::fileptr, find_logchannel(), logchannel::list, and NULL.

Referenced by ast_ari_asterisk_delete_log().

◆ ast_logger_rotate()

int ast_logger_rotate ( void  )

Reload logger while rotating log files.

Definition at line 1314 of file logger.c.

1315 {
1316  return reload_logger(1, NULL);
1317 }
static int reload_logger(int rotate, const char *altconf)
Definition: logger.c:1199

References NULL, and reload_logger().

Referenced by action_loggerrotate().

◆ ast_logger_rotate_channel()

int ast_logger_rotate_channel ( const char *  log_channel)

Rotate the specified log channel.

Parameters
log_channelThe log channel to rotate

Definition at line 1319 of file logger.c.

1320 {
1321  struct logchannel *f;
1322  int success = AST_LOGGER_FAILURE;
1323  char filename[PATH_MAX];
1324 
1325  make_filename(log_channel, filename, sizeof(filename));
1326 
1328 
1330 
1332  if (f->disabled) {
1333  f->disabled = 0; /* Re-enable logging at reload */
1334  manager_event(EVENT_FLAG_SYSTEM, "LogChannel", "Channel: %s\r\nEnabled: Yes\r\n",
1335  f->filename);
1336  }
1337  if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
1338  fclose(f->fileptr); /* Close file */
1339  f->fileptr = NULL;
1340  if (strcmp(filename, f->filename) == 0) {
1341  rotate_file(f->filename);
1342  success = AST_LOGGER_SUCCESS;
1343  }
1344  }
1345  }
1346 
1348 
1350 
1351  return success;
1352 }
#define PATH_MAX
Definition: asterisk.h:40
static void make_filename(const char *channel, char *filename, size_t size)
create the filename that will be used for a logger channel.
Definition: logger.c:576
static int init_logger_chain(const char *altconf)
Read config, setup channels.
Definition: logger.c:746
static int rotate_file(const char *filename)
Definition: logger.c:1032
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
Definition: manager.h:253
#define EVENT_FLAG_SYSTEM
Definition: manager.h:75
const char * ast_config_AST_LOG_DIR
Definition: options.c:159
int ast_mkdir(const char *path, int mode)
Recursively create directory path.
Definition: main/utils.c:2377

References ast_config_AST_LOG_DIR, AST_LOGGER_FAILURE, AST_LOGGER_SUCCESS, ast_mkdir(), AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, logchannel::disabled, EVENT_FLAG_SYSTEM, logchannel::filename, logchannel::fileptr, init_logger_chain(), logchannel::list, make_filename(), manager_event, NULL, PATH_MAX, and rotate_file().

Referenced by ast_ari_asterisk_rotate_log().

◆ ast_logger_set_queue_limit()

void ast_logger_set_queue_limit ( int  queue_limit)

Set the maximum number of messages allowed in the processing queue.

Parameters
queue_limit

Definition at line 2666 of file logger.c.

2667 {
2668  logger_queue_limit = queue_limit;
2669 }

References logger_queue_limit.

◆ ast_logger_unregister_level()

void ast_logger_unregister_level ( const char *  name)

Unregister a previously registered logger level.

Parameters
nameThe name of the level to be unregistered
Since
1.8

Definition at line 2643 of file logger.c.

2644 {
2645  int x;
2646 
2649 
2650  if (x) {
2652  }
2653 
2655 
2656  if (x) {
2657  ast_debug(1, "Unregistered dynamic logger level '%s' with index %u.\n", name, x);
2658  }
2659 }
static void update_logchannels(void)
Definition: logger.c:2444
static int logger_unregister_level(const char *name)
Definition: logger.c:2627

References ast_debug, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, logger_unregister_level(), name, and update_logchannels().

Referenced by handle_cli_dynamic_level_test(), handle_cli_performance_test(), load_module(), and unload_module().

◆ ast_queue_log()

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

Definition at line 952 of file logger.c.

953 {
954  va_list ap;
955  struct timeval tv;
956  struct ast_tm tm;
957  char qlog_msg[8192];
958  int qlog_len;
959  char time_str[30];
960 
961  if (!logger_initialized) {
962  /* You are too early. We are not open yet! */
963  return;
964  }
965  if (!queuelog_init) {
966  /* We must initialize now since someone is trying to log something. */
968  }
969 
970  if (ast_check_realtime("queue_log")) {
971  tv = ast_tvnow();
972  ast_localtime(&tv, &tm, logfiles.queue_log_realtime_use_gmt ? "GMT" : NULL);
973  ast_strftime(time_str, sizeof(time_str), "%F %T.%6q", &tm);
974  va_start(ap, fmt);
975  vsnprintf(qlog_msg, sizeof(qlog_msg), fmt, ap);
976  va_end(ap);
977  if (logfiles.queue_adaptive_realtime) {
979  AST_APP_ARG(data)[5];
980  );
981  AST_NONSTANDARD_APP_ARGS(args, qlog_msg, '|');
982  /* Ensure fields are large enough to receive data */
983  ast_realtime_require_field("queue_log",
984  "data1", RQ_CHAR, strlen(S_OR(args.data[0], "")),
985  "data2", RQ_CHAR, strlen(S_OR(args.data[1], "")),
986  "data3", RQ_CHAR, strlen(S_OR(args.data[2], "")),
987  "data4", RQ_CHAR, strlen(S_OR(args.data[3], "")),
988  "data5", RQ_CHAR, strlen(S_OR(args.data[4], "")),
989  SENTINEL);
990 
991  /* Store the log */
992  ast_store_realtime("queue_log", "time", time_str,
993  "callid", callid,
994  "queuename", queuename,
995  "agent", agent,
996  "event", event,
997  "data1", S_OR(args.data[0], ""),
998  "data2", S_OR(args.data[1], ""),
999  "data3", S_OR(args.data[2], ""),
1000  "data4", S_OR(args.data[3], ""),
1001  "data5", S_OR(args.data[4], ""),
1002  SENTINEL);
1003  } else {
1004  ast_store_realtime("queue_log", "time", time_str,
1005  "callid", callid,
1006  "queuename", queuename,
1007  "agent", agent,
1008  "event", event,
1009  "data", qlog_msg,
1010  SENTINEL);
1011  }
1012 
1013  if (!logfiles.queue_log_to_file) {
1014  return;
1015  }
1016  }
1017 
1018  if (qlog) {
1019  va_start(ap, fmt);
1020  qlog_len = snprintf(qlog_msg, sizeof(qlog_msg), "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event);
1021  vsnprintf(qlog_msg + qlog_len, sizeof(qlog_msg) - qlog_len, fmt, ap);
1022  va_end(ap);
1024  if (qlog) {
1025  fprintf(qlog, "%s\n", qlog_msg);
1026  fflush(qlog);
1027  }
1029  }
1030 }
#define SENTINEL
Definition: compiler.h:87
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
int ast_realtime_require_field(const char *family,...) attribute_sentinel
Inform realtime what fields that may be stored.
Definition: main/config.c:3448
int ast_check_realtime(const char *family)
Check if realtime engine is configured for family.
Definition: main/config.c:3429
int ast_store_realtime(const char *family,...) attribute_sentinel
Create realtime configuration.
Definition: main/config.c:3639
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
Definition: localtime.c:2524
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
Definition: localtime.c:1739
static int queuelog_init
Definition: logger.c:88
void logger_queue_start(void)
Start the ast_queue_log() logger.
Definition: logger.c:1940
static FILE * qlog
Definition: logger.c:200
static struct @397 logfiles
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition: strings.h:80
Definition: astman.c:222
const char * args
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:157

References args, AST_APP_ARG, ast_check_realtime(), AST_DECLARE_APP_ARGS, ast_localtime(), AST_NONSTANDARD_APP_ARGS, ast_realtime_require_field(), AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_store_realtime(), ast_strftime(), ast_tvnow(), logfiles, logger_initialized, logger_queue_start(), NULL, qlog, queuelog_init, RQ_CHAR, S_OR, and SENTINEL.

Referenced by aqm_exec(), find_queue_by_name_rt(), handle_blind_transfer(), handle_hangup(), handle_queue_add_member(), log_attended_transfer(), manager_add_queue_member(), manager_queue_log_custom(), manager_remove_queue_member(), ql_exec(), queue_agent_cb(), queue_exec(), rna(), rqm_exec(), rt_handle_member_record(), set_member_paused(), set_member_penalty_help_members(), set_queue_member_pause(), set_queue_member_ringinuse(), try_calling(), update_realtime_members(), wait_for_answer(), and wait_our_turn().

◆ ast_read_threadstorage_callid()

ast_callid ast_read_threadstorage_callid ( void  )

extracts the callerid from the thread

Return values
Non-zeroCall id related to the thread
0if no call_id is present in the thread

Definition at line 2048 of file logger.c.

2049 {
2050  ast_callid *callid;
2051 
2052  callid = ast_threadstorage_get(&unique_callid, sizeof(*callid));
2053 
2054  return callid ? *callid : 0;
2055 }

References ast_threadstorage_get(), and unique_callid.

Referenced by __ast_verbose(), ast_callid_threadstorage_auto(), ast_log_ap(), ast_log_safe(), bridge_channel_internal_join(), bridge_impart_internal(), common_recall_channel_setup(), iax2_request(), jingle_alloc(), launch_monitor_thread(), local_request_with_stream_topology(), media_request_helper(), sip_request_call(), and socket_process().

◆ ast_register_verbose()

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

◆ ast_trace_get_by_module()

unsigned int ast_trace_get_by_module ( const char *  module)

Get the trace level for a module.

Parameters
modulethe name of module
Returns
the trace level

Definition at line 153 of file main/cli.c.

154 {
155  struct module_level *ml;
156  unsigned int res = 0;
157 
160  if (!strcasecmp(ml->module, module)) {
161  res = ml->level;
162  break;
163  }
164  }
166 
167  return res;
168 }
static struct module_level_list trace_modules
Definition: main/cli.c:108

References AST_LIST_TRAVERSE, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, module_level::level, and trace_modules.

◆ ast_unregister_verbose()

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

◆ ast_verb_console_get()

int ast_verb_console_get ( void  )

Get this thread's console verbosity level.

Returns
verbosity level of the console.

Definition at line 2407 of file logger.c.

2408 {
2409  struct verb_console *console;
2410  int verb_level;
2411 
2414  if (!console) {
2415  verb_level = 0;
2416  } else if (console->level) {
2417  verb_level = *console->level;
2418  } else {
2419  verb_level = option_verbose;
2420  }
2422  return verb_level;
2423 }
int option_verbose
Definition: options.c:67
static struct ast_threadstorage my_verb_console
Definition: logger.c:2378

References AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_threadstorage_get(), my_verb_console, and option_verbose.

Referenced by handle_show_settings(), and handle_verbose().

◆ ast_verb_console_register()

void ast_verb_console_register ( int *  level)

Register this thread's console verbosity level pointer.

Parameters
levelWhere the verbose level value is.

Definition at line 2380 of file logger.c.

2381 {
2382  struct verb_console *console;
2383 
2385  if (!console || !level) {
2386  return;
2387  }
2388  console->level = level;
2389 
2393  ast_verb_update();
2394 }
void ast_verb_update(void)
Re-evaluate the system max verbosity level (ast_verb_sys_level).
Definition: logger.c:2318
Definition: test_heap.c:38
int * level
Definition: logger.c:2309

References AST_RWLIST_INSERT_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_threadstorage_get(), ast_verb_update(), verb_console::level, and my_verb_console.

Referenced by netconsole().

◆ ast_verb_console_set()

void ast_verb_console_set ( int  verb_level)

Set this thread's console verbosity level.

Parameters
verb_levelNew level to set.

Definition at line 2425 of file logger.c.

2426 {
2427  struct verb_console *console;
2428 
2430  if (!console) {
2431  return;
2432  }
2433 
2435  if (console->level) {
2436  *console->level = verb_level;
2437  } else {
2438  option_verbose = verb_level;
2439  }
2441  ast_verb_update();
2442 }

References AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_threadstorage_get(), ast_verb_update(), my_verb_console, and option_verbose.

Referenced by handle_verbose().

◆ ast_verb_console_unregister()

void ast_verb_console_unregister ( void  )

Unregister this thread's console verbosity level.

Definition at line 2396 of file logger.c.

2397 {
2398  struct verb_console *console;
2399 
2401  if (!console) {
2402  return;
2403  }
2405 }
static void verb_console_unregister(struct verb_console *console)
Definition: logger.c:2359

References ast_threadstorage_get(), my_verb_console, and verb_console_unregister().

Referenced by netconsole().

◆ ast_verb_update()

void ast_verb_update ( void  )

Re-evaluate the system max verbosity level (ast_verb_sys_level).

Definition at line 2318 of file logger.c.

2319 {
2320  struct logchannel *log;
2321  struct verb_console *console;
2322  int verb_level;
2323 
2325 
2327 
2328  /* Default to the root console verbosity. */
2329  verb_level = option_verbose;
2330 
2331  /* Determine max remote console level. */
2333  if (verb_level < *console->level) {
2334  verb_level = *console->level;
2335  }
2336  }
2338 
2339  /* Determine max logger channel level. */
2341  AST_RWLIST_TRAVERSE(&logchannels, log, list) {
2342  if (verb_level < log->verbosity) {
2343  verb_level = log->verbosity;
2344  }
2345  }
2347 
2348  ast_verb_sys_level = verb_level;
2349 
2351 }
int ast_verb_sys_level
Definition: options.c:64
#define ast_mutex_unlock(a)
Definition: lock.h:188
#define ast_mutex_lock(a)
Definition: lock.h:187
static ast_mutex_t verb_update_lock
Definition: logger.c:2316
int verbosity
Definition: logger.c:148

References AST_LIST_TRAVERSE, ast_mutex_lock, ast_mutex_unlock, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_verb_sys_level, verb_console::level, option_verbose, verb_update_lock, and logchannel::verbosity.

Referenced by ast_verb_console_register(), ast_verb_console_set(), init_logger(), reload_logger(), and verb_console_unregister().