RTS API Documentation  1.10.11
Data Structures | Macros | Typedefs | Functions | Variables
Logger Routines
+ Collaboration diagram for Logger Routines:

Data Structures

struct  switch_log_node_t
 Log Data. More...
 
struct  switch_log_json_format_item_t
 JSON Log formatting data item. More...
 
struct  switch_log_json_format_t
 JSON Log formatting data. More...
 

Macros

#define switch_log_check_mask(_mask, _level)   (_mask & ((size_t)1 << _level))
 

Typedefs

typedef switch_status_t(* switch_log_function_t) (const switch_log_node_t *node, switch_log_level_t level)
 

Functions

cJSONswitch_log_node_to_json (const switch_log_node_t *node, int log_level, switch_log_json_format_t *json_format, switch_event_t *chan_vars)
 Convert a log node to JSON object. Destroy JSON object when finished. More...
 
switch_status_t switch_log_init (_In_ switch_memory_pool_t *pool, _In_ switch_bool_t colorize)
 Initilize the logging engine. More...
 
switch_status_t switch_log_shutdown (void)
 Shut down the logging engine. More...
 
void switch_log_printf (_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
 Write log data to the logging engine. More...
 
void void switch_log_vprintf (_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, const char *fmt, va_list ap)
 Write log data to the logging engine. More...
 
void switch_log_meta_printf (switch_text_channel_t channel, const char *file, const char *func, int line, const char *userdata, switch_log_level_t level, cJSON **meta, const char *fmt,...) PRINTF_FUNCTION(8
 Write log data to the logging engine w/ optional JSON metadata. More...
 
void void switch_log_meta_vprintf (_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, cJSON **meta, const char *fmt, va_list ap)
 Write log data to the logging engine w/ optional JSON metadata. More...
 
switch_status_t switch_log_bind_logger (_In_ switch_log_function_t function, _In_ switch_log_level_t level, _In_ switch_bool_t is_console)
 Shut down the logging engine. More...
 
switch_status_t switch_log_unbind_logger (_In_ switch_log_function_t function)
 
_Ret_z_ const char * switch_log_level2str (_In_ switch_log_level_t level)
 Return the name of the specified log level. More...
 
switch_log_level_t switch_log_str2level (_In_z_ const char *str)
 Return the level number of the specified log level name. More...
 
uint32_t switch_log_str2mask (_In_z_ const char *str)
 
switch_log_node_tswitch_log_node_dup (const switch_log_node_t *node)
 
void switch_log_node_free (switch_log_node_t **pnode)
 

Variables

char * switch_log_node_t::data
 
char switch_log_node_t::file [80]
 
uint32_t switch_log_node_t::line
 
char switch_log_node_t::func [80]
 
switch_log_level_t switch_log_node_t::level
 
switch_time_t switch_log_node_t::timestamp
 
char * switch_log_node_t::content
 
char * switch_log_node_t::userdata
 
switch_text_channel_t switch_log_node_t::channel
 
switch_log_level_t switch_log_node_t::slevel
 
switch_event_tswitch_log_node_t::tags
 
int64_t switch_log_node_t::sequence
 
cJSONswitch_log_node_t::meta
 
const char * switch_log_json_format_item_t::name
 
const char * switch_log_json_format_item_t::value
 
switch_log_json_format_item_t switch_log_json_format_t::version
 
switch_log_json_format_item_t switch_log_json_format_t::host
 
switch_log_json_format_item_t switch_log_json_format_t::timestamp
 
switch_log_json_format_item_t switch_log_json_format_t::level
 
switch_log_json_format_item_t switch_log_json_format_t::ident
 
switch_log_json_format_item_t switch_log_json_format_t::pid
 
switch_log_json_format_item_t switch_log_json_format_t::uuid
 
switch_log_json_format_item_t switch_log_json_format_t::file
 
switch_log_json_format_item_t switch_log_json_format_t::line
 
switch_log_json_format_item_t switch_log_json_format_t::function
 
switch_log_json_format_item_t switch_log_json_format_t::full_message
 
switch_log_json_format_item_t switch_log_json_format_t::short_message
 
const char * switch_log_json_format_t::custom_field_prefix
 
double switch_log_json_format_t::timestamp_divisor
 
switch_log_json_format_item_t switch_log_json_format_t::sequence
 

Detailed Description

Macro Definition Documentation

◆ switch_log_check_mask

#define switch_log_check_mask (   _mask,
  _level 
)    (_mask & ((size_t)1 << _level))

Definition at line 219 of file switch_log.h.

Typedef Documentation

◆ switch_log_function_t

typedef switch_status_t(* switch_log_function_t) (const switch_log_node_t *node, switch_log_level_t level)

Definition at line 104 of file switch_log.h.

Function Documentation

◆ switch_log_bind_logger()

switch_status_t switch_log_bind_logger ( _In_ switch_log_function_t  function,
_In_ switch_log_level_t  level,
_In_ switch_bool_t  is_console 
)

Shut down the logging engine.

Note
to be called at application termination by the core

◆ switch_log_init()

switch_status_t switch_log_init ( _In_ switch_memory_pool_t pool,
_In_ switch_bool_t  colorize 
)

Initilize the logging engine.

Parameters
poolthe memory pool to use
Note
to be called at application startup by the core

Referenced by switch_core_init().

◆ switch_log_level2str()

_Ret_z_ const char* switch_log_level2str ( _In_ switch_log_level_t  level)

Return the name of the specified log level.

Parameters
levelthe level
Returns
the name of the log level

◆ switch_log_meta_printf()

void switch_log_meta_printf ( switch_text_channel_t  channel,
const char *  file,
const char *  func,
int  line,
const char *  userdata,
switch_log_level_t  level,
cJSON **  meta,
const char *  fmt,
  ... 
)

Write log data to the logging engine w/ optional JSON metadata.

Parameters
channelthe log channel to write to
filethe current file
functhe current function
linethe current line
userdataununsed
levelthe current log level
metalog metadata - consumed by this function
fmtdesired format
...variable args
Note
there are channel macros to supply the first 4 parameters (SWITCH_CHANNEL_LOG, SWITCH_CHANNEL_LOG_CLEAN, ...)
See also
switch_types.h

◆ switch_log_meta_vprintf()

void void switch_log_meta_vprintf ( _In_ switch_text_channel_t  channel,
_In_z_ const char *  file,
_In_z_ const char *  func,
_In_ int  line,
_In_opt_z_ const char *  userdata,
_In_ switch_log_level_t  level,
cJSON **  meta,
const char *  fmt,
va_list  ap 
)

Write log data to the logging engine w/ optional JSON metadata.

Parameters
channelthe log channel to write to
filethe current file
functhe current function
linethe current line
userdataununsed
levelthe current log level
metalog metadata - consumed by this function
fmtdesired format
apvariable args
Note
there are channel macros to supply the first 4 parameters (SWITCH_CHANNEL_LOG, SWITCH_CHANNEL_LOG_CLEAN, ...)
See also
switch_types.h

◆ switch_log_node_dup()

switch_log_node_t* switch_log_node_dup ( const switch_log_node_t node)

Definition at line 267 of file switch_log.c.

References cJSON_True, switch_log_node_t::content, switch_log_node_t::data, switch_log_node_t::meta, switch_assert, switch_event_dup(), switch_log_node_alloc(), switch_log_node_t::tags, and switch_log_node_t::userdata.

268 {
270 
271  *newnode = *node;
272  newnode->content = NULL;
273 
274  if (node->data) {
275  newnode->data = strdup(node->data);
276  switch_assert(newnode->data);
277 
278  // content is a pointer inside data; need to calculate the new pointer
279  if (node->content && node->content >= node->data) {
280  newnode->content = newnode->data + (node->content - node->data);
281  }
282  }
283 
284  if (node->userdata) {
285  newnode->userdata = strdup(node->userdata);
286  switch_assert(newnode->userdata);
287  }
288 
289  if (node->tags) {
290  switch_event_dup(&newnode->tags, node->tags);
291  }
292 
293  if (node->meta) {
294  newnode->meta = cJSON_Duplicate(node->meta, cJSON_True);
295  }
296 
297  return newnode;
298 }
Log Data.
Definition: switch_log.h:49
switch_event_t * tags
Definition: switch_log.h:68
switch_status_t switch_event_dup(switch_event_t **event, switch_event_t *todup)
Duplicate an event.
#define cJSON_True
Definition: switch_cJSON.h:83
static switch_log_node_t * switch_log_node_alloc(void)
Definition: switch_log.c:249
#define switch_assert(expr)

◆ switch_log_node_free()

void switch_log_node_free ( switch_log_node_t **  pnode)

Definition at line 300 of file switch_log.c.

References switch_log_node_t::data, switch_log_node_t::meta, switch_event_destroy(), switch_queue_trypush(), switch_safe_free, SWITCH_STATUS_SUCCESS, switch_log_node_t::tags, and switch_log_node_t::userdata.

Referenced by log_thread(), switch_core_memory_reclaim_logger(), and switch_log_meta_vprintf().

301 {
302  switch_log_node_t *node;
303 
304  if (!pnode) {
305  return;
306  }
307 
308  node = *pnode;
309 
310  if (node) {
311  switch_safe_free(node->userdata);
312  switch_safe_free(node->data);
313  if (node->tags) {
314  switch_event_destroy(&node->tags);
315  }
316  if (node->meta) {
317  cJSON_Delete(node->meta);
318  node->meta = NULL;
319  }
320 #ifdef SWITCH_LOG_RECYCLE
321  if (switch_queue_trypush(LOG_RECYCLE_QUEUE, node) != SWITCH_STATUS_SUCCESS) {
322  free(node);
323  }
324 #else
325  free(node);
326 #endif
327  }
328  *pnode = NULL;
329 }
Log Data.
Definition: switch_log.h:49
switch_event_t * tags
Definition: switch_log.h:68
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
switch_status_t switch_queue_trypush(switch_queue_t *queue, void *data)
Definition: switch_apr.c:1279
void switch_event_destroy(switch_event_t **event)
Destroy an event.

◆ switch_log_node_to_json()

cJSON* switch_log_node_to_json ( const switch_log_node_t node,
int  log_level,
switch_log_json_format_t json_format,
switch_event_t chan_vars 
)

Convert a log node to JSON object. Destroy JSON object when finished.

Parameters
nodethe node
log_levelthe log level
json_formatthe output format definition
char_varsoptional channel variables to add to logs

Definition at line 91 of file switch_log.c.

References cJSON::child, cJSON_True, switch_log_node_t::content, switch_log_json_format_t::custom_field_prefix, switch_log_node_t::file, switch_log_json_format_t::file, switch_log_json_format_t::full_message, switch_log_node_t::func, switch_log_json_format_t::function, switch_event::headers, switch_log_json_format_t::host, switch_log_json_format_t::ident, switch_log_json_format_t::level, switch_log_node_t::line, switch_log_json_format_t::line, switch_log_node_t::meta, switch_event_header::name, switch_log_json_format_item_t::name, switch_event_header::next, cJSON::next, switch_log_json_format_t::pid, switch_log_node_t::sequence, switch_log_json_format_t::sequence, switch_log_json_format_t::short_message, cJSON::string, switch_channel_get_variable, switch_core_get_variable(), switch_core_session_get_channel(), switch_core_session_locate, switch_core_session_rwunlock(), switch_event_add_header_string(), SWITCH_EVENT_CHANNEL_DATA, switch_event_create_brackets(), switch_event_create_plain(), switch_event_destroy(), switch_event_dup(), switch_mprintf(), switch_safe_free, switch_snprintf(), SWITCH_STACK_BOTTOM, SWITCH_TRUE, switch_log_node_t::tags, switch_log_node_t::timestamp, switch_log_json_format_t::timestamp, switch_log_json_format_t::timestamp_divisor, switch_log_node_t::userdata, switch_log_json_format_t::uuid, switch_event_header::value, switch_log_json_format_item_t::value, switch_log_json_format_t::version, zstr, and zstr_buf.

92 {
93  cJSON *json = NULL;
94  char *hostname;
95  char *full_message = node->content;
96  char *parsed_full_message = NULL;
97  char *field_name = NULL;
98  switch_event_t *log_fields = NULL;
100 
101  if (node->meta && cJSON_IsObject(node->meta)) {
102  if (json_format->custom_field_prefix) {
103  cJSON *field = NULL;
104  json = cJSON_CreateObject();
105  for (field = node->meta->child; field; field = field->next) {
106  if (!zstr(field->string)) {
107  char *field_name = switch_mprintf("%s%s", json_format->custom_field_prefix, field->string);
108  cJSON_AddItemToObject(json, field_name, cJSON_Duplicate(field, cJSON_True));
109  free(field_name);
110  }
111  }
112  } else {
113  json = cJSON_Duplicate(node->meta, cJSON_True);
114  }
115  } else {
116  json = cJSON_CreateObject();
117  }
118 
119  if (json_format->version.name && json_format->version.value) {
120  cJSON_AddItemToObject(json, json_format->version.name, cJSON_CreateString(json_format->version.value));
121  }
122  if (json_format->host.name) {
123  if (json_format->host.value) {
124  cJSON_AddItemToObject(json, json_format->host.name, cJSON_CreateString(json_format->host.value));
125  } else if ((hostname = switch_core_get_variable("hostname")) && !zstr(hostname)) {
126  cJSON_AddItemToObject(json, json_format->host.name, cJSON_CreateString(hostname));
127  } else if ((hostname = switch_core_get_variable("local_ip_v4")) && !zstr(hostname)) {
128  cJSON_AddItemToObject(json, json_format->host.name, cJSON_CreateString(hostname));
129  }
130  }
131  if (json_format->timestamp.name) {
132  double timestamp = node->timestamp;
133  if (json_format->timestamp_divisor > 1.0) {
134  timestamp = timestamp / json_format->timestamp_divisor;
135  }
136  cJSON_AddItemToObject(json, json_format->timestamp.name, cJSON_CreateNumber(timestamp));
137  }
138  if (json_format->level.name) {
139  cJSON_AddItemToObject(json, json_format->level.name, cJSON_CreateNumber(log_level));
140  }
141  if (json_format->ident.name) {
142  if (json_format->ident.value) {
143  cJSON_AddItemToObject(json, json_format->ident.name, cJSON_CreateString(json_format->ident.value));
144  } else {
145  cJSON_AddItemToObject(json, json_format->ident.name, cJSON_CreateString("freeswitch"));
146  }
147  }
148  if (json_format->pid.name) {
149  if (json_format->pid.value) {
150  cJSON_AddItemToObject(json, json_format->pid.name, cJSON_CreateNumber(atoi(json_format->pid.value)));
151  } else {
152  cJSON_AddItemToObject(json, json_format->pid.name, cJSON_CreateNumber((int)getpid()));
153  }
154  }
155  if (json_format->uuid.name && !zstr(node->userdata)) {
156  cJSON_AddItemToObject(json, json_format->uuid.name, cJSON_CreateString(node->userdata));
157  }
158  if (json_format->file.name && !zstr_buf(node->file)) {
159  cJSON_AddItemToObject(json, json_format->file.name, cJSON_CreateString(node->file));
160  if (json_format->line.name) {
161  cJSON_AddItemToObject(json, json_format->line.name, cJSON_CreateNumber(node->line));
162  }
163  }
164  if (json_format->function.name && !zstr_buf(node->func)) {
165  cJSON_AddItemToObject(json, json_format->function.name, cJSON_CreateString(node->func));
166  }
167  if (json_format->sequence.name) {
168  cJSON_AddItemToObject(json, json_format->sequence.name, cJSON_CreateNumber(node->sequence));
169  }
170 
171  /* skip initial space and new line */
172  if (*full_message == ' ') {
173  full_message++;
174  }
175  if (*full_message == '\n') {
176  full_message++;
177  }
178 
179  /* get fields from log tags */
180  if (node->tags) {
181  switch_event_dup(&log_fields, node->tags);
182  }
183 
184  /* get fields from channel data, if configured */
185  if (!zstr(node->userdata) && chan_vars && chan_vars->headers && (session = switch_core_session_locate(node->userdata))) {
188  /* session_fields name mapped to variable name */
189  for (hp = chan_vars->headers; hp; hp = hp->next) {
190  if (!zstr(hp->name) && !zstr(hp->value)) {
191  const char *val = switch_channel_get_variable(channel, hp->value);
192  if (!zstr(val)) {
193  if (!log_fields) {
195  }
197  }
198  }
199  }
201  }
202 
203  /* parse list of fields from message text, if any */
204  if (strncmp(full_message, "LOG_FIELDS", 10) == 0) {
205  switch_event_create_brackets(full_message+10, '[', ']', ',', &log_fields, &parsed_full_message, SWITCH_TRUE);
206  full_message = parsed_full_message;
207  }
208 
209  /* add additional fields */
210  if (log_fields) {
212  const char *prefix = json_format->custom_field_prefix ? json_format->custom_field_prefix : "";
213  for (hp = log_fields->headers; hp; hp = hp->next) {
214  if (!zstr(hp->name) && !zstr(hp->value)) {
215  if (strncmp(hp->name, "@#", 2) == 0) {
216  field_name = switch_mprintf("%s%s", prefix, hp->name + 2);
217  cJSON_AddItemToObject(json, field_name, cJSON_CreateNumber(strtod(hp->value, NULL)));
218  } else {
219  field_name = switch_mprintf("%s%s", prefix, hp->name);
220  cJSON_AddItemToObject(json, field_name, cJSON_CreateString(hp->value));
221  }
222  free(field_name);
223  }
224  }
225  switch_event_destroy(&log_fields);
226  }
227 
228  if (json_format->full_message.name) {
229  cJSON_AddItemToObject(json, json_format->full_message.name, cJSON_CreateString(full_message));
230  } else {
231  cJSON_AddItemToObject(json, "message", cJSON_CreateString(full_message));
232  }
233 
234  if (json_format->short_message.name) {
235  char short_message[151];
236  char *short_message_end = NULL;
237  switch_snprintf(short_message, sizeof(short_message) - 1, "%s", full_message);
238  if ((short_message_end = strchr(short_message, '\n'))) {
239  *short_message_end = '\0';
240  }
241  cJSON_AddItemToObject(json, json_format->short_message.name, cJSON_CreateString(short_message));
242  }
243 
244  switch_safe_free(parsed_full_message);
245 
246  return json;
247 }
switch_log_json_format_item_t sequence
Definition: switch_log.h:101
switch_core_session_t * session
switch_log_json_format_item_t version
Definition: switch_log.h:87
switch_event_t * tags
Definition: switch_log.h:68
switch_status_t switch_event_create_brackets(char *data, char a, char b, char c, switch_event_t **event, char **new_data, switch_bool_t dup)
Representation of an event.
Definition: switch_event.h:80
switch_log_json_format_item_t pid
Definition: switch_log.h:92
An event Header.
Definition: switch_event.h:65
switch_log_json_format_item_t timestamp
Definition: switch_log.h:89
switch_status_t switch_event_dup(switch_event_t **event, switch_event_t *todup)
Duplicate an event.
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
#define zstr(x)
Definition: switch_utils.h:314
switch_log_json_format_item_t ident
Definition: switch_log.h:91
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
switch_log_json_format_item_t line
Definition: switch_log.h:95
struct cJSON * child
Definition: switch_cJSON.h:101
char * string
Definition: switch_cJSON.h:114
#define cJSON_True
Definition: switch_cJSON.h:83
#define switch_channel_get_variable(_c, _v)
switch_status_t switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
Add a string header to an event.
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
switch_log_json_format_item_t uuid
Definition: switch_log.h:93
struct cJSON * next
Definition: switch_cJSON.h:98
switch_log_json_format_item_t full_message
Definition: switch_log.h:97
#define zstr_buf(s)
Definition: switch_utils.h:318
char * switch_core_get_variable(_In_z_ const char *varname)
Retrieve a global variable from the core.
static switch_status_t switch_event_create_plain(switch_event_t **event, switch_event_types_t event_id)
Definition: switch_event.h:386
switch_time_t timestamp
Definition: switch_log.h:61
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
switch_log_json_format_item_t short_message
Definition: switch_log.h:98
int64_t sequence
Definition: switch_log.h:70
struct switch_event_header * next
Definition: switch_event.h:76
#define switch_core_session_locate(uuid_str)
Locate a session based on it&#39;s uuid.
Definition: switch_core.h:932
const char * custom_field_prefix
Definition: switch_log.h:99
switch_log_json_format_item_t level
Definition: switch_log.h:90
switch_log_json_format_item_t host
Definition: switch_log.h:88
switch_log_json_format_item_t function
Definition: switch_log.h:96
void switch_event_destroy(switch_event_t **event)
Destroy an event.
SWITCH_BEGIN_EXTERN_C char * switch_mprintf(const char *zFormat,...)
switch_log_json_format_item_t file
Definition: switch_log.h:94
switch_event_header_t * headers
Definition: switch_event.h:90

◆ switch_log_printf()

void switch_log_printf ( _In_ switch_text_channel_t  channel,
_In_z_ const char *  file,
_In_z_ const char *  func,
_In_ int  line,
_In_opt_z_ const char *  userdata,
_In_ switch_log_level_t  level,
_In_z_ _Printf_format_string_ const char *  fmt,
  ... 
)

Write log data to the logging engine.

Parameters
channelthe log channel to write to
filethe current file
functhe current function
linethe current line
userdataununsed
levelthe current log level
fmtdesired format
...variable args
Note
there are channel macros to supply the first 4 parameters (SWITCH_CHANNEL_LOG, SWITCH_CHANNEL_LOG_CLEAN, ...)
See also
switch_types.h

Referenced by _switch_cache_db_get_db_handle(), _switch_core_session_request_video_refresh(), Event::addBody(), Event::addHeader(), api_hook(), asr_set_json_text_params(), audio_bridge_on_consume_media(), audio_bridge_on_routing(), audio_bridge_thread(), EventConsumer::bind(), IVRMenu::bindAction(), bridge(), chat_thread_run(), check_channel_status(), check_dtls_reinvite(), check_ice(), check_jb(), check_jb_sync(), check_jitter(), check_queue(), check_rtcp_and_ice(), check_timeout(), collect_thread_run(), console_clean_log(), console_log(), console_log2(), console_xml_config(), CoreSession::consoleLog(), CoreSession::consoleLog2(), core_event_handler(), Event::delHeader(), CoreSession::destroy(), CoreSession::detectSpeech(), do_2833(), do_api_on(), do_chat_send(), do_dtls(), do_flush(), do_mos(), do_shutdown(), do_trans(), dtls_bio_filter_ctrl(), dtls_bio_filter_write(), dtls_state_handshake(), dtls_state_setup(), dump_buffer(), early_thread_run(), eavesdrop_callback(), ecd_deliver(), enable_local_rtcp_socket(), enable_remote_rtcp_socket(), Event::Event(), event_handler(), exec_cb(), API::execute(), CoreSession::execute(), API::executeString(), Event::fire(), free_header(), freeswitch_kill_background(), fs_consol_clean(), fs_consol_log(), fs_switch_ivr_originate(), get_backend(), get_pmp_pubaddr(), get_upnp_pubaddr(), Event::getBody(), CoreSession::getDigits(), Event::getHeader(), Event::getType(), handle_ice(), handle_nack(), handle_rfc2833(), CoreSession::hangup(), hanguphook(), ice_out(), inband_dtmf_callback(), inband_dtmf_generate_callback(), inherit_codec(), init_nat_monitor(), init_upnp(), ip_choose_family(), is_valid_action(), limit_state_handler(), load_config(), load_configuration(), Event::merge(), meta_on_dtmf(), monitor_callback(), msock_init(), msrp_init_ssl(), msrp_listener(), msrp_parse_buffer(), msrp_parse_headers(), msrp_report(), msrp_socket_recv(), msrp_worker(), next_cpu(), CoreSession::originate(), play_and_collect(), play_and_detect_input_callback(), CoreSession::playAndDetectSpeech(), pool_thread(), preprocess(), preprocess_exec(), preprocess_exec_set(), preprocess_glob(), preprocess_stun_set(), process_device_hup(), process_rtcp_packet(), process_rtcp_report(), read_bundle_rtp_packet(), read_displace_callback(), read_rtcp_packet(), read_rtp_packet(), record_callback(), record_helper_destroy(), recording_thread(), recover_callback(), rtcp_generate_report_block(), rtcp_generate_sender_info(), rtcp_stats(), rtcp_stats_init(), rtp_common_read(), rtp_common_write(), rtp_write_ready(), CoreSession::say(), CoreSession::sayPhrase(), set_dtmf_delay(), CoreSession::set_tts_parms(), CoreSession::setHangupHook(), Event::setPriority(), setup_ringback(), CoreSession::setVariable(), signal_bridge_on_hibernate(), CoreSession::speak(), speech_callback(), speech_on_dtmf(), speech_thread(), sql_close(), sql_in_thread(), switch_agc_feed(), switch_cache_db_database_interface_flush_handles(), switch_cache_db_execute_sql2str(), switch_cache_db_execute_sql_callback(), switch_cache_db_execute_sql_callback_err(), switch_cache_db_execute_sql_event_callback(), switch_cache_db_execute_sql_event_callback_err(), switch_cache_db_execute_sql_real(), switch_cache_db_load_extension(), switch_cache_db_persistant_execute(), switch_cache_db_persistant_execute_trans_full(), switch_cache_db_test_reactive_ex(), switch_caller_extension_add_application(), switch_caller_extension_add_application_printf(), switch_channel_add_variable_var_check(), switch_channel_check_device_state(), switch_channel_clear_device_record(), switch_channel_dequeue_dtmf(), switch_channel_expand_variables_check(), switch_channel_export_variable_var_check(), switch_channel_flip_cid(), switch_channel_handle_cause(), switch_channel_invert_cid(), switch_channel_perform_answer(), switch_channel_perform_hangup(), switch_channel_perform_mark_answered(), switch_channel_perform_mark_pre_answered(), switch_channel_perform_mark_ring_ready_value(), switch_channel_perform_ring_ready_value(), switch_channel_perform_set_callstate(), switch_channel_perform_set_running_state(), switch_channel_perform_set_state(), switch_channel_process_export(), switch_channel_queue_dtmf(), switch_channel_queue_dtmf_string(), switch_channel_set_device_id(), switch_channel_set_name(), switch_channel_set_variable_strip_quotes_var_check(), switch_channel_set_variable_var_check(), switch_chromakey_add_color(), switch_collect_input_callback(), switch_console_complete(), switch_console_execute(), switch_console_expand_alias(), switch_console_list_uuid(), switch_console_loop(), switch_console_save_history(), switch_console_set_alias(), switch_console_stream_write(), switch_core_asr_feed(), switch_core_asr_open(), switch_core_cert_extract_fingerprint(), switch_core_cert_gen_fingerprint(), switch_core_check_dtls_pem(), switch_core_codec_add_implementation(), switch_core_codec_control(), switch_core_codec_decode(), switch_core_codec_decode_video(), switch_core_codec_destroy(), switch_core_codec_encode(), switch_core_codec_encode_video(), switch_core_codec_init_with_bitrate(), switch_core_db_exec(), switch_core_db_load_extension(), switch_core_db_open_file(), switch_core_db_open_in_memory(), switch_core_db_persistant_execute_trans(), switch_core_db_test_reactive(), switch_core_destroy(), switch_core_directory_open(), switch_core_execute_chat_app(), switch_core_file_close(), switch_core_file_read(), switch_core_file_write(), switch_core_gen_certs(), switch_core_init(), switch_core_init_and_modload(), switch_core_launch_thread(), switch_core_media_activate_rtp(), switch_core_media_add_crypto(), switch_core_media_add_payload_map(), switch_core_media_bug_add(), switch_core_media_bug_close(), switch_core_media_bug_read(), switch_core_media_bug_remove_all_function(), switch_core_media_bug_transfer_callback(), switch_core_media_build_crypto(), switch_core_media_choose_port(), switch_core_media_choose_ports(), switch_core_media_ext_address_lookup(), switch_core_media_gen_local_sdp(), switch_core_media_merge_sdp_codec_string(), switch_core_media_negotiate_sdp(), switch_core_media_patch_sdp(), switch_core_media_process_sdp_filter(), switch_core_media_process_t38_passthru(), switch_core_media_proxy_remote_addr(), switch_core_media_read_frame(), switch_core_media_read_lock_unlock(), switch_core_media_receive_message(), switch_core_media_set_codec(), switch_core_media_set_r_sdp_codec_string(), switch_core_media_set_udptl_image_sdp(), switch_core_media_set_video_codec(), switch_core_media_set_video_file(), switch_core_media_start_udptl(), switch_core_memory_reclaim(), switch_core_memory_reclaim_events(), switch_core_memory_stop(), switch_core_perform_alloc(), switch_core_perform_destroy_memory_pool(), switch_core_perform_file_open(), switch_core_perform_new_memory_pool(), switch_core_perform_permanent_alloc(), switch_core_perform_permanent_strdup(), switch_core_perform_session_alloc(), switch_core_perform_session_strdup(), switch_core_perform_strndup(), switch_core_port_allocator_new(), switch_core_port_allocator_request_port(), switch_core_recovery_flush(), switch_core_recovery_recover(), switch_core_session_check_incoming_crypto(), switch_core_session_ctl(), switch_core_session_enable_heartbeat(), switch_core_session_exec(), switch_core_session_execute_application_get_flags(), switch_core_session_execute_exten(), switch_core_session_get_app_flags(), switch_core_session_hangup_state(), switch_core_session_launch_thread(), switch_core_session_outgoing_channel(), switch_core_session_parse_crypto_prefs(), switch_core_session_perform_destroy(), switch_core_session_perform_force_locate(), switch_core_session_perform_kill_channel(), switch_core_session_perform_receive_message(), switch_core_session_read_frame(), switch_core_session_read_lock(), switch_core_session_read_lock_hangup(), switch_core_session_read_video_frame(), switch_core_session_recv_dtmf(), switch_core_session_request_by_name(), switch_core_session_request_uuid(), switch_core_session_run(), switch_core_session_send_dtmf(), switch_core_session_send_dtmf_string(), switch_core_session_set_codec_slin(), switch_core_session_set_external_id(), switch_core_session_set_read_codec(), switch_core_session_set_real_read_codec(), switch_core_session_set_uuid(), switch_core_session_set_video_read_codec(), switch_core_session_set_video_write_codec(), switch_core_session_set_write_codec(), switch_core_session_start_audio_write_thread(), switch_core_session_start_text_thread(), switch_core_session_start_video_thread(), switch_core_session_thread(), switch_core_session_thread_launch(), switch_core_session_thread_pool_launch(), switch_core_session_thread_pool_worker(), switch_core_session_wake_video_thread(), switch_core_session_write_encoded_video_frame(), switch_core_session_write_frame(), switch_core_session_write_lock(), switch_core_session_write_text_frame(), switch_core_session_write_video_frame(), switch_core_speech_open(), switch_core_speech_read_tts(), switch_core_sqldb_pause(), switch_core_sqldb_resume(), switch_core_sqldb_start(), switch_core_sqldb_start_thread(), switch_core_sqldb_stop_thread(), switch_core_standard_on_consume_media(), switch_core_standard_on_destroy(), switch_core_standard_on_exchange_media(), switch_core_standard_on_execute(), switch_core_standard_on_hangup(), switch_core_standard_on_hibernate(), switch_core_standard_on_init(), switch_core_standard_on_park(), switch_core_standard_on_reporting(), switch_core_standard_on_reset(), switch_core_standard_on_routing(), switch_core_standard_on_soft_execute(), switch_core_timer_check(), switch_core_timer_destroy(), switch_core_timer_init(), switch_core_timer_next(), switch_core_timer_step(), switch_core_timer_sync(), switch_curl_process_mime(), switch_dial_handle_list_create_json_obj(), switch_digest(), switch_dow_cmp(), switch_event_bind_removable(), switch_event_channel_broadcast(), switch_event_channel_deliver_thread(), switch_event_channel_unsub_head(), switch_event_create_brackets(), switch_event_dispatch_thread(), switch_event_free_subclass_detailed(), switch_event_init(), switch_event_launch_dispatch_threads(), switch_event_shutdown(), switch_event_unbind(), switch_event_unbind_callback(), switch_fd_read_dline(), switch_fp_read_dline(), switch_fulldate_cmp(), switch_html_strip(), switch_img_data_url(), switch_img_data_url_png(), switch_img_find_position(), switch_img_from_raw(), switch_img_mirror(), switch_img_patch(), switch_img_patch_png(), switch_img_read_png(), switch_img_scale(), switch_img_to_raw(), switch_img_txt_handle_create(), switch_img_txt_handle_destroy(), switch_img_txt_handle_render(), switch_img_write_png(), switch_img_write_to_file(), switch_ivr_3p_media(), switch_ivr_3p_nomedia(), switch_ivr_activate_unicast(), switch_ivr_bind_dtmf_meta_session(), switch_ivr_capture_text(), switch_ivr_check_presence_mapping(), switch_ivr_collect_digits_count(), switch_ivr_deactivate_unicast(), switch_ivr_delay_echo(), switch_ivr_detect_audio(), switch_ivr_detect_silence(), switch_ivr_detect_speech(), switch_ivr_detect_speech_disable_all_grammars(), switch_ivr_detect_speech_disable_grammar(), switch_ivr_detect_speech_enable_grammar(), switch_ivr_detect_speech_load_grammar(), switch_ivr_detect_speech_unload_grammar(), switch_ivr_digit_stream_parser_del_event(), switch_ivr_digit_stream_parser_new(), switch_ivr_digit_stream_parser_set_event(), switch_ivr_displace_session(), switch_ivr_dmachine_bind(), switch_ivr_dmachine_clear_realm(), switch_ivr_dmachine_feed(), switch_ivr_dmachine_set_realm(), switch_ivr_dmachine_set_terminators(), switch_ivr_eavesdrop_session(), switch_ivr_enterprise_orig_and_bridge(), switch_ivr_enterprise_originate(), switch_ivr_hold(), switch_ivr_inband_dtmf_generate_session(), switch_ivr_insert_file(), switch_ivr_intercept_session(), switch_ivr_media(), switch_ivr_menu_execute(), switch_ivr_menu_init(), switch_ivr_menu_stack_xml_add(), switch_ivr_menu_stack_xml_build(), switch_ivr_menu_stack_xml_init(), switch_ivr_multi_threaded_bridge(), switch_ivr_nomedia(), switch_ivr_orig_and_bridge(), switch_ivr_originate(), switch_ivr_park(), switch_ivr_parse_all_events(), switch_ivr_parse_event(), switch_ivr_phrase_macro_event(), switch_ivr_play_and_collect_input(), switch_ivr_play_and_detect_speech(), switch_ivr_play_file(), switch_ivr_preprocess_session(), switch_ivr_process_fh(), switch_ivr_read(), switch_ivr_record_file_event(), switch_ivr_record_session_event(), switch_ivr_say(), switch_ivr_say_string(), switch_ivr_session_transfer(), switch_ivr_set_user_extended(), switch_ivr_sleep(), switch_ivr_soft_hold(), switch_ivr_sound_test(), switch_ivr_speak_text(), switch_ivr_speak_text_handle(), switch_ivr_tone_detect_session(), switch_ivr_unbind_dtmf_meta_session(), switch_ivr_unhold(), switch_ivr_uuid_bridge(), switch_ivr_video_write_overlay_session(), switch_ivr_wait_for_answer(), switch_ivr_wait_for_silence(), switch_jb_put_packet(), switch_jb_set_session(), switch_limit_incr(), switch_limit_init(), switch_limit_interval_reset(), switch_limit_release(), switch_limit_reset(), switch_limit_status(), switch_limit_usage(), switch_load_core_config(), switch_load_network_lists(), switch_load_timezones(), switch_loadable_module_build_dynamic(), switch_loadable_module_create_interface(), switch_loadable_module_exec(), switch_loadable_module_get_management_interface(), switch_loadable_module_init(), switch_loadable_module_load_file(), switch_loadable_module_load_module_ex(), switch_loadable_module_process(), switch_loadable_module_runtime(), switch_loadable_module_sort_codecs(), switch_loadable_module_unload_module(), switch_loadable_module_unprocess(), switch_lookup_timezone(), SWITCH_MODULE_LOAD_FUNCTION(), SWITCH_MODULE_RUNTIME_FUNCTION(), switch_msrp_destroy(), switch_msrp_do_send(), switch_msrp_init(), switch_msrp_perform_send(), switch_msrp_session_destroy(), switch_msrp_start_client(), switch_nat_add_mapping_internal(), switch_nat_add_mapping_pmp(), switch_nat_add_mapping_upnp(), switch_nat_del_mapping_pmp(), switch_nat_del_mapping_upnp(), switch_nat_init(), switch_nat_multicast_runtime(), switch_nat_republish(), switch_nat_thread_start(), switch_nat_thread_stop(), switch_network_list_perform_add_cidr_token(), switch_odbc_handle_callback_exec_detailed(), switch_odbc_handle_connect(), switch_odbc_handle_disconnect(), switch_odbc_handle_exec(), switch_packetizer_feed(), switch_packetizer_feed_extradata(), switch_packetizer_read(), switch_parse_codec_buf(), switch_play_and_get_digits(), switch_regex_match_partial(), switch_regex_perform(), switch_rtp_activate_ice(), switch_rtp_activate_rtcp(), switch_rtp_add_crypto_key(), switch_rtp_add_dtls(), switch_rtp_change_ice_dest(), switch_rtp_change_interval(), switch_rtp_create(), switch_rtp_dequeue_dtmf(), switch_rtp_destroy(), switch_rtp_enable_vad(), switch_rtp_init(), switch_rtp_pause_jitter_buffer(), switch_rtp_set_max_missed_packets(), switch_rtp_set_media_timeout(), switch_rtp_set_video_buffer_size(), switch_rtp_shutdown(), switch_rtp_write_frame(), switch_rtp_write_raw(), switch_scheduler_add_task_ex(), switch_scheduler_del_task_group(), switch_scheduler_del_task_id(), switch_scheduler_task_thread(), switch_scheduler_task_thread_stop(), switch_send_rtcp_event(), switch_simple_email(), switch_speex_fmtp_parse(), switch_speex_init(), switch_sql_queue_manager_destroy(), switch_sql_queue_manager_push(), switch_sql_queue_manager_push_confirm(), switch_sql_queue_manager_start(), switch_sql_queue_manager_stop(), SWITCH_STANDARD_APP(), SWITCH_STANDARD_SCHED_FUNC(), switch_stream_spawn(), switch_stun_ip_lookup(), switch_system_fork(), switch_system_thread(), switch_thread_join(), switch_time_calibrate_clock(), switch_time_sync(), switch_user_sql_thread(), switch_vad_process(), switch_vad_reset(), switch_vad_set_mode(), switch_vad_set_param(), switch_xml_ampencode(), switch_xml_config_item_print_doc(), switch_xml_config_parse_event(), switch_xml_config_parse_module_settings(), switch_xml_free(), switch_xml_locate(), switch_xml_locate_language(), switch_xml_locate_language_ex(), switch_xml_locate_user_cache(), switch_xml_locate_user_merged(), switch_xml_parse_file_simple(), switch_xml_std_datetime_check(), system_thread(), task_thread_loop(), text_bridge_thread(), text_helper_thread(), thread_launch_failure(), timer_destroy(), timer_generic_sync(), timer_init(), tone_detect_callback(), CoreSession::transfer(), transfer_after_bridge(), uuid_bridge_on_reset(), uuid_bridge_on_soft_execute(), video_helper_thread(), and xswitch_http_request().

◆ switch_log_shutdown()

switch_status_t switch_log_shutdown ( void  )

Shut down the logging engine.

Note
to be called at application termination by the core

Definition at line 799 of file switch_log.c.

References switch_cond_next(), switch_core_memory_reclaim_logger(), switch_queue_push(), SWITCH_STATUS_SUCCESS, switch_thread_join(), thread, and THREAD_RUNNING.

Referenced by switch_core_destroy().

800 {
801  switch_status_t st;
802 
803 
805  while (THREAD_RUNNING) {
807  }
808 
810 
812 
813  return SWITCH_STATUS_SUCCESS;
814 }
void switch_core_memory_reclaim_logger(void)
Definition: switch_log.c:783
static switch_thread_t * thread
Definition: switch_log.c:486
static switch_queue_t * LOG_QUEUE
Definition: switch_log.c:61
static int8_t THREAD_RUNNING
Definition: switch_log.c:65
switch_status_t switch_thread_join(switch_status_t *retval, switch_thread_t *thd)
Definition: switch_apr.c:1379
void switch_cond_next(void)
Definition: switch_time.c:658
switch_status_t
Common return values.
switch_status_t switch_queue_push(switch_queue_t *queue, void *data)
Definition: switch_apr.c:1253

◆ switch_log_str2level()

switch_log_level_t switch_log_str2level ( _In_z_ const char *  str)

Return the level number of the specified log level name.

Parameters
strthe name of the level
Returns
the log level

Referenced by console_log(), console_log2(), CoreSession::consoleLog(), CoreSession::consoleLog2(), fs_consol_log(), and switch_load_core_config().

◆ switch_log_str2mask()

uint32_t switch_log_str2mask ( _In_z_ const char *  str)

◆ switch_log_unbind_logger()

switch_status_t switch_log_unbind_logger ( _In_ switch_log_function_t  function)

◆ switch_log_vprintf()

void void switch_log_vprintf ( _In_ switch_text_channel_t  channel,
_In_z_ const char *  file,
_In_z_ const char *  func,
_In_ int  line,
_In_opt_z_ const char *  userdata,
_In_ switch_log_level_t  level,
const char *  fmt,
va_list  ap 
)

Write log data to the logging engine.

Parameters
channelthe log channel to write to
filethe current file
functhe current function
linethe current line
userdataununsed
levelthe current log level
fmtdesired format
apvariable args
Note
there are channel macros to supply the first 4 parameters (SWITCH_CHANNEL_LOG, SWITCH_CHANNEL_LOG_CLEAN, ...)
See also
switch_types.h

Variable Documentation

◆ channel

switch_text_channel_t switch_log_node_t::channel

Definition at line 66 of file switch_log.h.

Referenced by switch_log_meta_vprintf().

◆ content

char* switch_log_node_t::content

A pointer to where the actual content of the message starts (skipping past the preformatted portion)

Definition at line 63 of file switch_log.h.

Referenced by switch_log_meta_vprintf(), switch_log_node_dup(), and switch_log_node_to_json().

◆ custom_field_prefix

const char* switch_log_json_format_t::custom_field_prefix

Definition at line 99 of file switch_log.h.

Referenced by switch_log_node_to_json().

◆ data

char* switch_log_node_t::data

The complete log message

Definition at line 51 of file switch_log.h.

Referenced by switch_log_meta_vprintf(), switch_log_node_dup(), and switch_log_node_free().

◆ file [1/2]

char switch_log_node_t::file[80]

The file where the message originated

Definition at line 53 of file switch_log.h.

Referenced by switch_log_meta_vprintf(), and switch_log_node_to_json().

◆ file [2/2]

switch_log_json_format_item_t switch_log_json_format_t::file

Definition at line 94 of file switch_log.h.

Referenced by switch_log_node_to_json().

◆ full_message

switch_log_json_format_item_t switch_log_json_format_t::full_message

Definition at line 97 of file switch_log.h.

Referenced by switch_log_node_to_json().

◆ func

char switch_log_node_t::func[80]

The function where the message originated

Definition at line 57 of file switch_log.h.

Referenced by switch_log_meta_vprintf(), and switch_log_node_to_json().

◆ function

switch_log_json_format_item_t switch_log_json_format_t::function

Definition at line 96 of file switch_log.h.

Referenced by switch_log_node_to_json().

◆ host

switch_log_json_format_item_t switch_log_json_format_t::host

Definition at line 88 of file switch_log.h.

Referenced by switch_log_node_to_json().

◆ ident

switch_log_json_format_item_t switch_log_json_format_t::ident

Definition at line 91 of file switch_log.h.

Referenced by switch_log_node_to_json().

◆ level [1/2]

switch_log_level_t switch_log_node_t::level

The log level of the message

Definition at line 59 of file switch_log.h.

Referenced by log_thread(), and switch_log_meta_vprintf().

◆ level [2/2]

switch_log_json_format_item_t switch_log_json_format_t::level

Definition at line 90 of file switch_log.h.

Referenced by switch_log_node_to_json().

◆ line [1/2]

uint32_t switch_log_node_t::line

The line number where the message originated

Definition at line 55 of file switch_log.h.

Referenced by switch_log_meta_vprintf(), and switch_log_node_to_json().

◆ line [2/2]

switch_log_json_format_item_t switch_log_json_format_t::line

Definition at line 95 of file switch_log.h.

Referenced by switch_log_node_to_json().

◆ meta

cJSON* switch_log_node_t::meta

◆ name

const char* switch_log_json_format_item_t::name

Definition at line 79 of file switch_log.h.

Referenced by switch_log_node_to_json().

◆ pid

switch_log_json_format_item_t switch_log_json_format_t::pid

Definition at line 92 of file switch_log.h.

Referenced by switch_log_node_to_json().

◆ sequence [1/2]

int64_t switch_log_node_t::sequence

Definition at line 70 of file switch_log.h.

Referenced by log_thread(), and switch_log_node_to_json().

◆ sequence [2/2]

switch_log_json_format_item_t switch_log_json_format_t::sequence

Definition at line 101 of file switch_log.h.

Referenced by switch_log_node_to_json().

◆ short_message

switch_log_json_format_item_t switch_log_json_format_t::short_message

Definition at line 98 of file switch_log.h.

Referenced by switch_log_node_to_json().

◆ slevel

switch_log_level_t switch_log_node_t::slevel

Definition at line 67 of file switch_log.h.

Referenced by switch_log_meta_vprintf().

◆ tags

switch_event_t* switch_log_node_t::tags

◆ timestamp [1/2]

switch_time_t switch_log_node_t::timestamp

The time when the log line was sent

Definition at line 61 of file switch_log.h.

Referenced by switch_log_meta_vprintf(), and switch_log_node_to_json().

◆ timestamp [2/2]

switch_log_json_format_item_t switch_log_json_format_t::timestamp

Definition at line 89 of file switch_log.h.

Referenced by switch_log_node_to_json().

◆ timestamp_divisor

double switch_log_json_format_t::timestamp_divisor

Definition at line 100 of file switch_log.h.

Referenced by switch_log_node_to_json().

◆ userdata

char* switch_log_node_t::userdata

◆ uuid

switch_log_json_format_item_t switch_log_json_format_t::uuid

Definition at line 93 of file switch_log.h.

Referenced by switch_log_node_to_json().

◆ value

const char* switch_log_json_format_item_t::value

Definition at line 80 of file switch_log.h.

Referenced by switch_log_node_to_json().

◆ version

switch_log_json_format_item_t switch_log_json_format_t::version

Definition at line 87 of file switch_log.h.

Referenced by switch_log_node_to_json().