Review Board 1.7.16


Add ability for modules to dynamically register/unregister logger levels

Review Request #244 - Created May 4, 2009 and submitted

Kevin Fleming
trunk
Reviewers
asterisk-dev
Asterisk
This patch adds the ability for modules to dynamically create logger levels for their own use; these are named levels just like the built-in levels, and can be directed to any destination that the logger can send any level to, by including their names in logger.conf.
Tested using included test_logger module.

Diff revision 4 (Latest)

1 2 3 4
1 2 3 4

  1. /trunk/include/asterisk/logger.h: Loading...
  2. /trunk/main/logger.c: Loading...
  3. /trunk/tests/test_logger.c: Loading...
/trunk/include/asterisk/logger.h
Revision 194522 New Change
[20] 192 lines
[+20] [+] unsigned int ast_debug_get_by_file(const char *file);
193
 * \return the debug level
193
 * \return the debug level
194
 */
194
 */
195
unsigned int ast_verbose_get_by_file(const char *file);
195
unsigned int ast_verbose_get_by_file(const char *file);
196

    
   
196

   
197
/*!
197
/*!

    
   
198
 * \brief Register a new logger level

    
   
199
 * \param name The name of the level to be registered

    
   
200
 * \retval -1 if an error occurs

    
   
201
 * \retval non-zero level to be used with ast_log for sending messages to this level

    
   
202
 * \since 1.6.3

    
   
203
 */

    
   
204
int ast_logger_register_level(const char *name);

    
   
205

   

    
   
206
/*!

    
   
207
 * \brief Unregister a previously registered logger level

    
   
208
 * \param name The name of the level to be unregistered

    
   
209
 * \return nothing

    
   
210
 * \since 1.6.3

    
   
211
 */

    
   
212
void ast_logger_unregister_level(const char *name);

    
   
213

   

    
   
214
/*!

    
   
215
 * \brief Send a log message to a dynamically registered log level

    
   
216
 * \param level The log level to send the message to

    
   
217
 *

    
   
218
 * Like ast_log, the log message may include printf-style formats, and

    
   
219
 * the data for these must be provided as additional parameters after

    
   
220
 * the log message.

    
   
221
 *

    
   
222
 * \return nothing

    
   
223
 * \since 1.6.3

    
   
224
 */

    
   
225

   

    
   
226
#define ast_log_dynamic_level(level, ...) ast_log(level, __FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)

    
   
227

   

    
   
228
/*!
198
 * \brief Log a DEBUG message
229
 * \brief Log a DEBUG message
199
 * \param level The minimum value of option_debug for this message
230
 * \param level The minimum value of option_debug for this message
200
 *        to get logged
231
 *        to get logged
201
 */
232
 */
202
#define ast_debug(level, ...) do {       \
233
#define ast_debug(level, ...) do {       \
[+20] [20] 73 lines
/trunk/main/logger.c
Revision 194522 New Change
 
/trunk/tests/test_logger.c
New File
 
  1. /trunk/include/asterisk/logger.h: Loading...
  2. /trunk/main/logger.c: Loading...
  3. /trunk/tests/test_logger.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.