Ignore:
Timestamp:
Oct 25, 2009 8:46:40 AM (10 years ago)
Author:
bennylp
Message:

Ticket #981: new pj_perror() utility API

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/errno.c

    r2394 r2965  
    1919 */ 
    2020#include <pj/errno.h> 
     21#include <pj/log.h> 
    2122#include <pj/string.h> 
    2223#include <pj/compat/string.h> 
     24#include <pj/compat/stdarg.h> 
    2325#include <pj/assert.h> 
    2426 
     
    197199} 
    198200 
     201#if PJ_LOG_MAX_LEVEL >= 1 
     202static void call_logger(const char *sender, int level, const char *format, ...) 
     203{ 
     204    va_list arg; 
     205    va_start(arg, format); 
     206    pj_log(sender, level, format, arg); 
     207    va_end(arg); 
     208} 
     209 
     210/* 
     211 * perror() 
     212 */ 
     213PJ_DEF(void) pj_perror(int log_level, const char *sender,  
     214                       pj_status_t status, const char *title, 
     215                       int options) 
     216{ 
     217    char errmsg[PJ_ERR_MSG_SIZE]; 
     218 
     219    PJ_ASSERT_ON_FAIL(options==0, return); 
     220    PJ_UNUSED_ARG(options); 
     221 
     222    pj_strerror(status, errmsg, sizeof(errmsg)); 
     223    call_logger(sender, log_level, "%s: %s", title, errmsg); 
     224} 
     225#endif  /* #if PJ_LOG_MAX_LEVEL >= 1 */ 
     226 
     227 
Note: See TracChangeset for help on using the changeset viewer.