FreeSWITCH API Documentation  1.7.0
switch_log.h
Go to the documentation of this file.
1 /*
2  * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
3  * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
4  *
5  * Version: MPL 1.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
18  *
19  * The Initial Developer of the Original Code is
20  * Anthony Minessale II <anthm@freeswitch.org>
21  * Portions created by the Initial Developer are Copyright (C)
22  * the Initial Developer. All Rights Reserved.
23  *
24  * Contributor(s):
25  *
26  * Anthony Minessale II <anthm@freeswitch.org>
27  *
28  *
29  * switch_log.h -- Logger
30  *
31  */
32 /*! \file switch_log.h
33  \brief Simple Log
34 
35  Logging Routines
36 */
37 
38 #ifndef SWITCH_LOG_H
39 #define SWITCH_LOG_H
40 
41 #include <switch.h>
42 
44 ///\defgroup log Logger Routines
45 ///\ingroup core1
46 ///\{
47 /*! \brief Log Data
48  */
49  typedef struct {
50  /*! The complete log message */
51  char *data;
52  /*! The file where the message originated */
53  char file[80];
54  /*! The line number where the message originated */
55  uint32_t line;
56  /*! The function where the message originated */
57  char func[80];
58  /*! The log level of the message */
60  /*! The time when the log line was sent */
62  /*! A pointer to where the actual content of the message starts (skipping past the preformatted portion) */
63  char *content;
64  char *userdata;
65  /* To maintain abi, only add new elements to the end of this struct and do not delete any elements */
69 
71 
72 
73 /*!
74  \brief Initilize the logging engine
75  \param pool the memory pool to use
76  \note to be called at application startup by the core
77 */
79 
80 /*!
81  \brief Shut down the logging engine
82  \note to be called at application termination by the core
83 */
85 
86 #ifndef SWIG
87 /*!
88  \brief Write log data to the logging engine
89  \param channel the log channel to write to
90  \param file the current file
91  \param func the current function
92  \param line the current line
93  \param userdata ununsed
94  \param level the current log level
95  \param fmt desired format
96  \param ... variable args
97  \note there are channel macros to supply the first 4 parameters (SWITCH_CHANNEL_LOG, SWITCH_CHANNEL_LOG_CLEAN, ...)
98  \see switch_types.h
99 */
100 SWITCH_DECLARE(void) switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file,
101  _In_z_ const char *func, _In_ int line,
102  _In_opt_z_ const char *userdata, _In_ switch_log_level_t level,
103  _In_z_ _Printf_format_string_ const char *fmt, ...) PRINTF_FUNCTION(7, 8);
104 /*!
105  \brief Write log data to the logging engine
106  \param channel the log channel to write to
107  \param file the current file
108  \param func the current function
109  \param line the current line
110  \param userdata ununsed
111  \param level the current log level
112  \param fmt desired format
113  \param ap variable args
114  \note there are channel macros to supply the first 4 parameters (SWITCH_CHANNEL_LOG, SWITCH_CHANNEL_LOG_CLEAN, ...)
115  \see switch_types.h
116 */
117 SWITCH_DECLARE(void) switch_log_vprintf(_In_ switch_text_channel_t channel, _In_z_ const char *file,
118  _In_z_ const char *func, _In_ int line,
119  _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, const char *fmt, va_list ap);
120 
121 #endif
122 /*!
123  \brief Shut down the logging engine
124  \note to be called at application termination by the core
125 */
128 
129 /*!
130  \brief Return the name of the specified log level
131  \param level the level
132  \return the name of the log level
133 */
135 
136 /*!
137  \brief Return the level number of the specified log level name
138  \param str the name of the level
139  \return the log level
140 */
142 
143 SWITCH_DECLARE(uint32_t) switch_log_str2mask(_In_z_ const char *str);
144 #define switch_log_check_mask(_mask, _level) (_mask & ((size_t)1 << _level))
145 
146 
149 
150 ///\}
152 #endif
153 /* For Emacs:
154  * Local Variables:
155  * mode:c
156  * indent-tabs-mode:t
157  * tab-width:4
158  * c-basic-offset:4
159  * End:
160  * For VIM:
161  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
162  */
#define _Printf_format_string_
switch_log_level_t level
Definition: switch_log.h:59
switch_text_channel_t
A target to write log/debug info to.
Log Data.
Definition: switch_log.h:49
#define SWITCH_END_EXTERN_C
Definition: switch.h:43
switch_time_t timestamp
Definition: switch_log.h:61
#define _Ret_z_
switch_bool_t
Definition: switch_types.h:405
switch_log_node_t * switch_log_node_dup(const switch_log_node_t *node)
Definition: switch_log.c:106
switch_memory_pool_t * pool
switch_log_level_t slevel
Definition: switch_log.h:67
uint32_t switch_log_str2mask(_In_z_ const char *str)
switch_text_channel_t channel
Definition: switch_log.h:66
_Ret_z_ const char * switch_log_level2str(_In_ switch_log_level_t level)
Return the name of the specified log level.
int64_t switch_time_t
Definition: switch_apr.h:188
switch_log_level_t switch_log_str2level(_In_z_ const char *str)
Return the level number of the specified log level name.
#define _In_z_
switch_status_t switch_log_shutdown(void)
Shut down the logging engine.
Definition: switch_log.c:560
#define PRINTF_FUNCTION(fmtstr, vars)
switch_status_t
Common return values.
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.
Main Library Header.
#define SWITCH_DECLARE(type)
switch_status_t(* switch_log_function_t)(const switch_log_node_t *node, switch_log_level_t level)
Definition: switch_log.h:70
void switch_log_node_free(switch_log_node_t **pnode)
Definition: switch_log.c:125
struct apr_pool_t switch_memory_pool_t
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.
switch_status_t switch_log_init(_In_ switch_memory_pool_t *pool, _In_ switch_bool_t colorize)
Initilize the logging engine.
#define _In_opt_z_
switch_status_t switch_log_unbind_logger(_In_ switch_log_function_t function)
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.
switch_log_level_t
Log Level Enumeration.
#define _In_
#define SWITCH_BEGIN_EXTERN_C
Definition: switch.h:42