Navigation


Changeset 965:9b37f34c1b1f in freeDiameter


Ignore:
Timestamp:
Mar 13, 2013, 1:23:37 AM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Some modifications to logging code:

  • Added a FD_LOG_NOTICE level for the logger function
  • Separated the internal debug levels (NONE, INFO, ...) from the "printlevel" for the logger
  • Renamed TRACE_DEBUG_ERROR to TRACE_ERROR for symetry
  • Renamed TRACE_DEBUG_BUFFER and TRACE_DEBUG_sSA. There take now the printlevel as parameter
  • Added new TRACE_NOTICE, fd_log_notice and fd_log_error macros.
  • sorry if I forgot some changes...
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • extensions/acl_wl/aw_conf.l

    r928 r965  
    9696<*>[[:alnum:]]+         |       /* This rule is only useful to print a complete token in error messages */
    9797<*>.                    {
    98                                 TRACE_DEBUG_ERROR("Unrecognized text on line %d col %d: '%s'.\n", yylloc->first_line, yylloc->first_column, yytext);
     98                                TRACE_ERROR("Unrecognized text on line %d col %d: '%s'.\n", yylloc->first_line, yylloc->first_column, yytext);
    9999                                return LEX_ERROR;
    100100                        }
  • extensions/app_radgw/rgw_clients.c

    r740 r965  
    922922        if (TRACE_BOOL(FULL + 1 )) {
    923923                TRACE_DEBUG(FULL, "Adding %s:", (type == RGW_CLI_NAS) ? "NAS" : "PROXY"  );
    924                 TRACE_DEBUG_sSA(FULL,    "\tIP : ", ip_port, NI_NUMERICHOST | NI_NUMERICSERV, "" );
    925                 TRACE_DEBUG_BUFFER(FULL, "\tKey: [", *key, keylen, "]" );
     924                TRACE_sSA(FD_LOG_DEBUG, FULL,    "\tIP : ", ip_port, NI_NUMERICHOST | NI_NUMERICSERV, "" );
     925                TRACE_BUFFER(FD_LOG_DEBUG, FULL, "\tKey: [", *key, keylen, "]" );
    926926        }
    927927       
     
    948948                }
    949949               
    950                 fd_log_debug("ERROR: Conflicting RADIUS clients descriptions!\n");
    951                 TRACE_DEBUG(NONE, "Previous entry: %s", (prev->type == RGW_CLI_NAS) ? "NAS" : "PROXY");
    952                 TRACE_DEBUG_sSA(NONE,    "\tIP : ", prev->sa, NI_NUMERICHOST | NI_NUMERICSERV, "" );
    953                 TRACE_DEBUG_BUFFER(NONE, "\tKey: [", prev->key.data, prev->key.len, "]" );
    954                 TRACE_DEBUG(NONE, "Conflicting entry: %s", (type == RGW_CLI_NAS) ? "NAS" : "PROXY");
    955                 TRACE_DEBUG_sSA(NONE,    "\tIP : ", ip_port, NI_NUMERICHOST | NI_NUMERICSERV, "" );
    956                 TRACE_DEBUG_BUFFER(NONE, "\tKey: [", *key, keylen, "]" );
     950                fd_log_erre("ERROR: Conflicting RADIUS clients descriptions!\n");
     951                TRACE_ERROR("Previous entry: %s", (prev->type == RGW_CLI_NAS) ? "NAS" : "PROXY");
     952                TRACE_sSA(FD_LOG_ERROR, NONE,    "\tIP : ", prev->sa, NI_NUMERICHOST | NI_NUMERICSERV, "" );
     953                TRACE_BUFFER(FD_LOG_ERROR, NONE, "\tKey: [", prev->key.data, prev->key.len, "]" );
     954                TRACE_ERROR("Conflicting entry: %s", (type == RGW_CLI_NAS) ? "NAS" : "PROXY");
     955                TRACE_sSA(FD_LOG_ERROR, NONE,    "\tIP : ", ip_port, NI_NUMERICHOST | NI_NUMERICSERV, "" );
     956                TRACE_BUFFER(FD_LOG_ERROR, NONE, "\tKey: [", *key, keylen, "]" );
    957957        }
    958958end:
     
    970970        for (ref = senti->next; ref != senti; ref = ref->next) {
    971971                client = (struct rgw_client *)ref;
    972                 TRACE_DEBUG_sSA(NONE,    "  - ", client->sa, NI_NUMERICHOST | NI_NUMERICSERV, (client->type == RGW_CLI_NAS) ? "" : " [PROXY]" );
     972                /* TODO: use a fct param instead of hardcoded FD_LOG_DEBUG */
     973                TRACE_sSA(FD_LOG_DEBUG, NONE,    "  - ", client->sa, NI_NUMERICHOST | NI_NUMERICSERV, (client->type == RGW_CLI_NAS) ? "" : " [PROXY]" );
    973974        }
    974975}
  • extensions/app_radgw/rgw_servers.c

    r740 r965  
    134134               
    135135                TRACE_DEBUG(FULL, "Received %d bytes", len);
    136                 TRACE_DEBUG_sSA(FULL, " from ", &from, NI_NUMERICHOST | NI_NUMERICSERV, "" );
     136                TRACE_sSA(FD_LOG_DEBUG, FULL, " from ", &from, NI_NUMERICHOST | NI_NUMERICSERV, "" );
    137137               
    138138                /* Search the associated client definition, if any */
    139139                CHECK_FCT_DO( rgw_clients_search((struct sockaddr *) &from, &nas_info),
    140140                        {
    141                                 TRACE_DEBUG(INFO, "Discarding %d bytes received from unknown IP:", len);
    142                                 TRACE_DEBUG_sSA(INFO, " ", &from, NI_NUMERICHOST | NI_NUMERICSERV, "" );
     141                                TRACE_NOTICE("Discarding %d bytes received from unknown IP:", len);
     142                                TRACE_sSA(FD_LOG_NOTICE, INFO, " ", &from, NI_NUMERICHOST | NI_NUMERICSERV, "" );
    143143                                continue;
    144144                        } );
     
    274274       
    275275        TRACE_DEBUG(FULL, "Sending %d bytes", buflen);
    276         TRACE_DEBUG_sSA(FULL, " to ", &sto, NI_NUMERICHOST | NI_NUMERICSERV, "" );
     276        TRACE_sSA(FD_LOG_DEBUG, FULL, " to ", &sto, NI_NUMERICHOST | NI_NUMERICSERV, "" );
    277277               
    278278        /* Send */
  • extensions/app_radgw/rgwx_acct.c

    r740 r965  
    435435                if (memcmp(&save[0], &rad_req->hdr->authenticator[0], MD5_MAC_LEN)) {
    436436                        /* Invalid authenticator */
    437                         TRACE_DEBUG_BUFFER(FULL+1, "Received ReqAuth: ", &save[0], MD5_MAC_LEN, "" );
    438                         TRACE_DEBUG_BUFFER(FULL+1, "Expected ReqAuth: ", &rad_req->hdr->authenticator[0], MD5_MAC_LEN, "" );
     437                        TRACE_BUFFER(FD_LOG_DEBUG, FULL+1, "Received ReqAuth: ", &save[0], MD5_MAC_LEN, "" );
     438                        TRACE_BUFFER(FD_LOG_DEBUG, FULL+1, "Expected ReqAuth: ", &rad_req->hdr->authenticator[0], MD5_MAC_LEN, "" );
    439439                        TRACE_DEBUG(INFO, "[acct.rgwx] Invalid Request Authenticator in Account-Request from %s, discarding the message.", rgw_clients_id(cli));
    440440                        return EINVAL;
  • include/freeDiameter/libfdproto.h

    r961 r965  
    112112 * FUNCTION:    fd_log
    113113 * MACRO:       fd_log_debug
     114 * MACRO:       fd_log_notice
     115 * MACRO:       fd_log_error
    114116 *
    115117 * PARAMETERS:
     
    127129 */
    128130void fd_log ( int, const char *, ... );
    129 #define fd_log_debug(format,args...) fd_log(FD_LOG_DEBUG, format, ## args)
     131#define fd_log_debug(format,args...)  fd_log(FD_LOG_DEBUG, format, ## args)
     132#define fd_log_notice(format,args...) fd_log(FD_LOG_NOTICE, format, ## args)
     133#define fd_log_error(format,args...)  fd_log(FD_LOG_ERROR, format, ## args)
     134
    130135void fd_log_debug_fstr( FILE *, const char *, ... );
    131136
     
    211216
    212217/* log levels definitions */
    213 #define FD_LOG_DEBUG 0
    214 #define FD_LOG_ERROR 5
     218#define FD_LOG_DEBUG  0  /* Verbose information for developers use */
     219#define FD_LOG_NOTICE 3  /* Normal execution states worth noting */
     220#define FD_LOG_ERROR  5  /* Error conditions, both recoverable or not */
    215221
    216222/* print level definitions */
     
    252258
    253259
    254 #define STD_TRACE_FMT_STRING "thread %s in %s@%s:%d: "
     260#define STD_TRACE_FMT_STRING "pid:%s in %s@%s:%d: "
    255261/*************
    256262 The general debug macro, each call results in two lines of debug messages (change the macro for more compact output)
     
    258264#ifdef DEBUG
    259265/* In DEBUG mode, we add (a lot of) meta-information along each trace. This makes multi-threading problems easier to debug. */
    260 #define TRACE_DEBUG(level,format,args... ) {                                                                                    \
     266#define TRACE(printlevel,level,format,args... ) {                                                                               \
    261267        if ( TRACE_BOOL(level) ) {                                                                                              \
    262268                const char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");                                 \
    263                 fd_log(level, STD_TRACE_FMT_STRING format, \
    264                                         __thn, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## args);                                               \
     269                fd_log((printlevel), STD_TRACE_FMT_STRING format,                                                               \
     270                                        __thn, __PRETTY_FUNCTION__, __STRIPPED_FILE__, __LINE__, ## args);                      \
    265271        }                                                                                                                       \
    266272}
    267273#else /* DEBUG */
    268 /* Do not print thread, function, ... only the message itself in this case, unless the debug level is set > FULL. */
    269 #define TRACE_DEBUG(level,format,args... ) {                                                                                            \
    270         if ( TRACE_BOOL(level) ) {                                                                                                      \
    271                 if (fd_g_debug_lvl > FULL) {                                                                                            \
    272                         const char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");                                 \
    273                         fd_log(level, STD_TRACE_FMT_STRING format,      \
    274                                __thn, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## args);  \
    275                 } else {                                                                                                                \
    276                         fd_log(level, format, ## args);           \
    277                 }                                                                                                                       \
    278         }                                                                                                                               \
     274/* Do not print thread, function, ... only the message itself in this case */
     275#define TRACE(printlevel,level,format,args... ) {                                       \
     276        if ( TRACE_BOOL(level) ) {                                                      \
     277                fd_log((printlevel), format, ## args);                                  \
     278        }                                                                               \
    279279}
    280280#endif /* DEBUG */
    281281
     282/* Report debug information */
     283#define TRACE_DEBUG(level,format,args... ) \
     284        TRACE(FD_LOG_DEBUG,(level),format,##args)
     285
     286/* Report a normal message that is usefull for normal admin monitoring */
     287#define TRACE_NOTICE(format,args... ) \
     288        TRACE(FD_LOG_NOTICE,INFO,format,##args)
     289
     290/* Report an error */
     291#define TRACE_ERROR(format,args... ) \
     292        TRACE(FD_LOG_ERROR, NONE, format, ##args)
     293
     294/*
     295TRACE_NOTICE(...) and fd_log_notice(...) are equivalent when the code is not compiled in DEBUG mode,
     296but there is more contextual information when compiled in DEBUG with the TRACE_NOTICE macro,
     297hence it is recommended to use this one except for formatted output (e.g. fd_*_dump function)
     298
     299resp. TRACE_DEBUG and TRACE_ERROR.
     300*/
     301
    282302/*************
    283  Derivatives from this macro
     303 Derivatives for debug
    284304 ************/
    285305/* Helper for function entry -- for very detailed trace of the execution */
     
    306326
    307327/* Trace a binary buffer content */
    308 #define TRACE_DEBUG_BUFFER(level, prefix, buf, bufsz, suffix ) {                                                                \
     328#ifdef DEBUG
     329/* In DEBUG mode, we add (a lot of) meta-information along each trace. This makes multi-threading problems easier to debug. */
     330#define TRACE_BUFFER(printlevel, level, prefix, buf, bufsz, suffix ) {                                                          \
    309331        if ( TRACE_BOOL(level) ) {                                                                                              \
    310332                int __i;                                                                                                        \
    311333                size_t __sz = (size_t)(bufsz);                                                                                  \
    312334                uint8_t * __buf = (uint8_t *)(buf);                                                                             \
     335                char __strbuf[1024+1];                                                                                          \
    313336                char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");                                       \
    314                 fd_log(level, STD_TRACE_FMT_STRING prefix,              \
    315                        __thn, __PRETTY_FUNCTION__, __FILE__, __LINE__); \
    316                 for (__i = 0; __i < __sz; __i++) {                                                                              \
    317                         fd_log(level, "%02.2hhx", __buf[__i]);         \
     337                for (__i = 0; (__i < __sz) && (__i<(sizeof(__strbuf)/2)); __i++) {                                              \
     338                        sprintf(__strbuf + (2 * __i), "%2.2hhx", __buf[__i]);                                                   \
    318339                }                                                                                                               \
    319                 fd_log(level, suffix);                        \
     340                fd_log(printlevel, STD_TRACE_FMT_STRING "%s%s%s",                                                               \
     341                       __thn, __PRETTY_FUNCTION__, __STRIPPED_FILE__, __LINE__, (prefix), __strbuf, (suffix));                  \
    320342        }                                                                                                                       \
    321343}
     344#else /* DEBUG */
     345/* Do not print thread, function, ... only the message itself in this case */
     346#define TRACE_BUFFER(printlevel, level, prefix, buf, bufsz, suffix ) {                                                          \
     347        if ( TRACE_BOOL(level) ) {                                                                                              \
     348                int __i;                                                                                                        \
     349                size_t __sz = (size_t)(bufsz);                                                                                  \
     350                uint8_t * __buf = (uint8_t *)(buf);                                                                             \
     351                char __strbuf[1024+1];                                                                                          \
     352                for (__i = 0; (__i < __sz) && (__i<(sizeof(__strbuf)/2)); __i++) {                                              \
     353                        sprintf(__strbuf + (2 * __i), "%2.2hhx", __buf[__i]);                                                   \
     354                }                                                                                                               \
     355                fd_log(printlevel, "%s%s%s", (prefix), __strbuf, (suffix));                                                     \
     356        }                                                                                                                       \
     357}
     358#endif /* DEBUG */
    322359
    323360/* Some aliases to socket addresses structures */
     
    334371
    335372/* Dump one sockaddr Node information */
    336 #define sSA_DUMP_NODE( buf, bufsize, sa, flag ) {                \
    337         sSA * __sa = (sSA *)(sa);                               \
    338         char __addrbuf[INET6_ADDRSTRLEN];                       \
    339         if (__sa) {                                             \
    340           int __rc = getnameinfo(__sa,                          \
    341                         sSAlen(__sa),                           \
    342                         __addrbuf,                              \
    343                         sizeof(__addrbuf),                      \
    344                         NULL,                                   \
    345                         0,                                      \
    346                         flag);                                  \
    347           if (__rc)                                             \
     373#define sSA_DUMP_NODE( buf, bufsize, sa, flag ) {                       \
     374        sSA * __sa = (sSA *)(sa);                                       \
     375        char __addrbuf[INET6_ADDRSTRLEN];                               \
     376        if (__sa) {                                                     \
     377          int __rc = getnameinfo(__sa,                                  \
     378                        sSAlen(__sa),                                   \
     379                        __addrbuf,                                      \
     380                        sizeof(__addrbuf),                              \
     381                        NULL,                                           \
     382                        0,                                              \
     383                        (flag));                                        \
     384          if (__rc)                                                     \
    348385                snprintf(buf, bufsize, "%s", gai_strerror(__rc));       \
    349           else                                                  \
    350                 snprintf(buf, bufsize, "%s", &__addrbuf[0]);       \
    351         } else {                                                \
    352                 snprintf(buf, bufsize, "(NULL / ANY)");             \
    353         }                                                       \
     386          else                                                          \
     387                snprintf(buf, bufsize, "%s", &__addrbuf[0]);            \
     388        } else {                                                        \
     389                snprintf(buf, bufsize, "(NULL / ANY)");                 \
     390        }                                                               \
    354391}
    355392/* Same but with the port (service) also */
     
    365402                        __servbuf,                                      \
    366403                        sizeof(__servbuf),                              \
    367                         flag);                                          \
     404                        (flag));                                        \
    368405          if (__rc)                                                     \
    369406                snprintf(buf, bufsize, "%s", gai_strerror(__rc));  \
     
    375412}
    376413
    377 /* Inside a debug trace */
    378 #define TRACE_DEBUG_sSA(level, prefix, sa, flags, suffix ) {                                                                            \
     414#ifdef DEBUG
     415/* In DEBUG mode, we add (a lot of) meta-information along each trace. This makes multi-threading problems easier to debug. */
     416#define TRACE_sSA(printlevel, level, prefix, sa, flags, suffix ) {                                                                              \
    379417        if ( TRACE_BOOL(level) ) {                                                                                              \
    380                 char buf[1024]; \
     418                char __buf[1024];                                                                                               \
    381419                char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");                                       \
    382                 sSA_DUMP_NODE_SERV(buf, sizeof(buf), sa, flags );       \
    383                 fd_log(level, STD_TRACE_FMT_STRING "%s%s%s",              \
    384                        __thn, __PRETTY_FUNCTION__, __FILE__, __LINE__, prefix, buf, suffix); \
     420                sSA_DUMP_NODE_SERV(__buf, sizeof(__buf), sa, flags );                                                           \
     421                fd_log(printlevel, STD_TRACE_FMT_STRING "%s%s%s" ,                                                              \
     422                       __thn, __PRETTY_FUNCTION__, __STRIPPED_FILE__, __LINE__, (prefix), __buf, (suffix));                     \
    385423        }                                                                                                                       \
    386424}
    387 
    388 /* Report an error */
    389 #define TRACE_DEBUG_ERROR(format,args... ) \
    390         TRACE_DEBUG(INFO, format, ##args)
     425#else /* DEBUG */
     426/* Do not print thread, function, ... only the message itself in this case */
     427#define TRACE_sSA(printlevel, level, prefix, sa, flags, suffix ) {                                                                              \
     428        if ( TRACE_BOOL(level) ) {                                                                                              \
     429                char __buf[1024];                                                                                               \
     430                sSA_DUMP_NODE_SERV(__buf, sizeof(__buf), sa, flags );                                                           \
     431                fd_log(printlevel, "%s%s%s" , (prefix), __buf, (suffix));                                                       \
     432        }                                                                                                                       \
     433}
     434#endif /* DEBUG */
    391435
    392436/******************
     
    395439#ifdef STRIP_DEBUG_CODE
    396440#undef TRACE_DEBUG
     441#undef TRACE_NOTICE
     442#undef TRACE_ERROR
    397443#undef TRACE_BOOL
    398 #undef TRACE_DEBUG_sSA
    399 #undef TRACE_DEBUG_BUFFER
    400 #undef TRACE_DEBUG_ERROR
    401 #define TRACE_DEBUG(level,format,args... )
    402 #define TRACE_BOOL(_level_) (0)
    403 #define TRACE_DEBUG_BUFFER(level, prefix, buf, bufsz, suffix )
    404 #define TRACE_DEBUG_sSA(level, prefix, sa, flags, suffix )
    405 #define TRACE_DEBUG_ERROR(format,args... ) {    \
    406         fd_log(FD_LOG_ERROR, format, ## args);  \
    407 }
     444#undef TRACE_BUFFER
     445#undef TRACE_sSA
     446
     447#define TRACE_DEBUG(level,format,args... ) /* noop */
     448#define TRACE_BOOL(_level_) (0) /* always false */
     449#define TRACE_NOTICE fd_log_notice
     450#define TRACE_ERROR fd_log_error
     451#define TRACE_BUFFER(printlevel, level, prefix, buf, bufsz, suffix ) {                                                          \
     452        if (printlevel > FD_LOG_DEBUG) {                                                                                        \
     453                int __i;                                                                                                        \
     454                size_t __sz = (size_t)(bufsz);                                                                                  \
     455                uint8_t * __buf = (uint8_t *)(buf);                                                                             \
     456                char * __strbuf[1024+1];                                                                                        \
     457                for (__i = 0; (__i < __sz) && (__i<(sizeof(__strbuf)/2); __i++) {                                               \
     458                        sprintf(__strbuf + (2 * __i), "%02.2hhx", __buf[__i]);                                                  \
     459                }                                                                                                               \
     460                fd_log(printlevel, prefix"%s"suffix, __strbuf);                                                                 \
     461        }
     462#define TRACE_sSA(printlevel, level, prefix, sa, flags, suffix )  {                                                             \
     463        if (printlevel > FD_LOG_DEBUG) {                                                                                        \
     464                char __buf[1024];                                                                                               \
     465                sSA_DUMP_NODE_SERV(__buf, sizeof(__buf), sa, flags );                                                           \
     466                fd_log(printlevel, prefix "%s" suffix, __buf);                                                                  \
     467        }
    408468#endif /* STRIP_DEBUG_CODE */
    409469
     
    424484        if (__ret__ < 0) {                                                              \
    425485                int __err__ = errno;    /* We may handle EINTR here */                  \
    426                 TRACE_DEBUG_ERROR("ERROR: in '" #__call__ "' :\t%s", strerror(__err__));\
     486                TRACE_ERROR("ERROR: in '" #__call__ "' :\t%s", strerror(__err__));\
    427487                __fallback__;                                                           \
    428488        }                                                                               \
     
    435495        if (__ret__ < 0) {                                                              \
    436496                int __err__ = errno;    /* We may handle EINTR here */                  \
    437                 TRACE_DEBUG_ERROR("ERROR: in '" #__call__ "' :\t%s", strerror(__err__));\
     497                TRACE_ERROR("ERROR: in '" #__call__ "' :\t%s", strerror(__err__));\
    438498                return __err__;                                                         \
    439499        }                                                                               \
     
    449509                        __fallback1__;                                                          \
    450510                } else {                                                                        \
    451                         TRACE_DEBUG_ERROR("ERROR: in '" #__call__ "':\t%s", strerror(__ret__)); \
     511                        TRACE_ERROR("ERROR: in '" #__call__ "':\t%s", strerror(__ret__));       \
    452512                        __fallback2__;                                                          \
    453513                }                                                                               \
     
    472532        if (__ret__ == NULL) {                                                          \
    473533                int __err__ = errno;                                                    \
    474                 TRACE_DEBUG_ERROR("ERROR: in '" #__call__ "':\t%s", strerror(__err__)); \
     534                TRACE_ERROR("ERROR: in '" #__call__ "':\t%s", strerror(__err__));       \
    475535                __fallback__;                                                           \
    476536        }                                                                               \
     
    486546        TRACE_DEBUG_ALL( "Check PARAMS: " #__bool__ );                                          \
    487547        if ( ! (__bool__) ) {                                                                   \
    488                 TRACE_DEBUG_ERROR("Warning: Invalid parameter received in '" #__bool__ "'");    \
     548                TRACE_ERROR("Warning: Invalid parameter received in '" #__bool__ "'");  \
    489549                __fallback__;                                                                   \
    490550        }
     
    499559        __ret__ = (__call__);                                                           \
    500560        if (__ret__ != 0) {                                                             \
    501                 TRACE_DEBUG_ERROR("ERROR: in '" #__call__ "':\t%s", strerror(__ret__)); \
     561                TRACE_ERROR("ERROR: in '" #__call__ "':\t%s", strerror(__ret__));       \
    502562                __fallback__;                                                           \
    503563        }                                                                               \
  • libfdcore/config.c

    r947 r965  
    248248        if (fddin == NULL) {
    249249                int ret = errno;
    250                 TRACE_DEBUG_ERROR("Unable to open configuration file for reading; tried the following locations: %s%s%s; Error: %s\n",
     250                TRACE_ERROR("Unable to open configuration file for reading; tried the following locations: %s%s%s; Error: %s\n",
    251251                                  orig ?: "", orig? " and " : "", fd_g_config->cnf_file, strerror(ret));
    252252                return ret;
  • libfdcore/fdd.l

    r961 r965  
    5252        yylloc->first_column = yylloc->last_column + 1;                 \
    5353        yylloc->last_column = yylloc->first_column + yyleng - 1;        \
    54         TRACE_DEBUG_ERROR(                                              \
     54        TRACE_ERROR(                                            \
    5555                "(%d:%d-%d:%d) matched rule %d, length=%d, txt='%s'\n", \
    5656                yylloc->first_line, yylloc->first_column,               \
     
    8484int globerrfct(const char *epath, int eerrno)
    8585{
    86         TRACE_DEBUG_ERROR("Failed to scan %s: %s\n", epath, strerror(eerrno));
     86        TRACE_ERROR("Failed to scan %s: %s\n", epath, strerror(eerrno));
    8787        return 1;
    8888}
     
    119119                        if (buf[yyleng-2] != '"')
    120120                        {
    121                                 TRACE_DEBUG_ERROR("Unterminated string: %s\n", yytext);
     121                                TRACE_ERROR("Unterminated string: %s\n", yytext);
    122122                                return LEX_ERROR;
    123123                        }
     
    126126                        if (current_nested_level >= MAX_NESTED_CONF_FILES)
    127127                        {
    128                                 TRACE_DEBUG_ERROR("Too many recursion levels in configuration files includes\n");
     128                                TRACE_ERROR("Too many recursion levels in configuration files includes\n");
    129129                                return LEX_ERROR;
    130130                        }
     
    135135                        if (globerror == GLOB_NOSPACE)
    136136                        {
    137                                 TRACE_DEBUG_ERROR("Not enough memory to parse include directive.\n");
     137                                TRACE_ERROR("Not enough memory to parse include directive.\n");
    138138                                return LEX_ERROR;
    139139                        }
    140140                        if (globerror == GLOB_ABORTED)
    141141                        {
    142                                 TRACE_DEBUG_ERROR("An error was encountered in include directive.\n");
     142                                TRACE_ERROR("An error was encountered in include directive.\n");
    143143                                return LEX_ERROR;
    144144                        }
     
    150150                        if (globerror)
    151151                        {
    152                                 TRACE_DEBUG_ERROR("Unexpected error in glob (%d).\n", globerror);
     152                                TRACE_ERROR("Unexpected error in glob (%d).\n", globerror);
    153153                                return LEX_ERROR;
    154154                        }
     
    166166                        if ( ! yyin )
    167167                        {
    168                                 TRACE_DEBUG_ERROR("Error in %s: %s", nested_conffiles[current_nested_level].filelist.gl_pathv[0], strerror(errno));
     168                                TRACE_ERROR("Error in %s: %s", nested_conffiles[current_nested_level].filelist.gl_pathv[0], strerror(errno));
    169169                                return LEX_ERROR;
    170170                        }
     
    206206                                if ( ! yyin )
    207207                                {
    208                                         TRACE_DEBUG_ERROR("Error in %s: %s", nested_conffiles[current_nested_level].filelist.gl_pathv[nested_conffiles[current_nested_level].current_file], strerror(errno));
     208                                        TRACE_ERROR("Error in %s: %s", nested_conffiles[current_nested_level].filelist.gl_pathv[nested_conffiles[current_nested_level].current_file], strerror(errno));
    209209                                        return LEX_ERROR;
    210210                                }
     
    234234                                if (ret != 1) {
    235235                                        /* No matching: an error occurred */
    236                                         TRACE_DEBUG_ERROR("Unable to convert the value '%s' to a valid number: %s\n", yytext, strerror(errno));
     236                                        TRACE_ERROR("Unable to convert the value '%s' to a valid number: %s\n", yytext, strerror(errno));
    237237                                        return LEX_ERROR; /* trig an error in yacc parser */
    238238                                        /* Maybe we could REJECT instead of failing here? */
     
    277277        /* Unrecognized character */
    278278<*>.                    {
    279                                 TRACE_DEBUG_ERROR("Unrecognized text on line %d col %d: '%s'.\n", yylloc->first_line, yylloc->first_column, yytext);
     279                                TRACE_ERROR("Unrecognized text on line %d col %d: '%s'.\n", yylloc->first_line, yylloc->first_column, yytext);
    280280                                return LEX_ERROR;
    281281                        }
  • libfdcore/fdd.y

    r964 r965  
    6363{
    6464        if (ploc->first_line != ploc->last_line) {
    65                 TRACE_DEBUG_ERROR("%s:%d.%d-%d.%d : %s\n", conf->cnf_file, ploc->first_line, ploc->first_column, ploc->last_line, ploc->last_column, s);
     65                TRACE_ERROR("%s:%d.%d-%d.%d : %s\n", conf->cnf_file, ploc->first_line, ploc->first_column, ploc->last_line, ploc->last_column, s);
    6666        } else if (ploc->first_column != ploc->last_column) {
    67                 TRACE_DEBUG_ERROR("%s:%d.%d-%d : %s\n", conf->cnf_file, ploc->first_line, ploc->first_column, ploc->last_column, s);
     67                TRACE_ERROR("%s:%d.%d-%d : %s\n", conf->cnf_file, ploc->first_line, ploc->first_column, ploc->last_column, s);
    6868        } else {
    69                 TRACE_DEBUG_ERROR("%s:%d.%d : %s\n", conf->cnf_file, ploc->first_line, ploc->first_column, s);
     69                TRACE_ERROR("%s:%d.%d : %s\n", conf->cnf_file, ploc->first_line, ploc->first_column, s);
    7070        }
    7171}
     
    328328                                if (fd == NULL) {
    329329                                        int ret = errno;
    330                                         TRACE_DEBUG_ERROR("WARNING: Unable to open extension file %s for reading: %s\nLD_LIBRARY_PATH will be used.\n", fname, strerror(ret));
     330                                        TRACE_ERROR("WARNING: Unable to open extension file %s for reading: %s\nLD_LIBRARY_PATH will be used.\n", fname, strerror(ret));
    331331                                } else {
    332332                                        fclose(fd);
     
    501501                                if (fd == NULL) {
    502502                                        int ret = errno;
    503                                         TRACE_DEBUG_ERROR("Unable to open certificate file %s for reading: %s\n", $3, strerror(ret));
     503                                        TRACE_ERROR("Unable to open certificate file %s for reading: %s\n", $3, strerror(ret));
    504504                                        yyerror (&yylloc, conf, "Error on file name");
    505505                                        YYERROR;
     
    509509                                if (fd == NULL) {
    510510                                        int ret = errno;
    511                                         TRACE_DEBUG_ERROR("Unable to open private key file %s for reading: %s\n", $5, strerror(ret));
     511                                        TRACE_ERROR("Unable to open private key file %s for reading: %s\n", $5, strerror(ret));
    512512                                        yyerror (&yylloc, conf, "Error on file name");
    513513                                        YYERROR;
     
    532532                                if (fd == NULL) {
    533533                                        int ret = errno;
    534                                         TRACE_DEBUG_ERROR("Unable to open CA file %s for reading: %s\n", $3, strerror(ret));
     534                                        TRACE_ERROR("Unable to open CA file %s for reading: %s\n", $3, strerror(ret));
    535535                                        yyerror (&yylloc, conf, "Error on file name");
    536536                                        YYERROR;
     
    572572                                if (fd == NULL) {
    573573                                        int ret = errno;
    574                                         TRACE_DEBUG_ERROR("Unable to open CRL file %s for reading: %s\n", $3, strerror(ret));
     574                                        TRACE_ERROR("Unable to open CRL file %s for reading: %s\n", $3, strerror(ret));
    575575                                        yyerror (&yylloc, conf, "Error on file name");
    576576                                        YYERROR;
     
    615615                                                        &err_pos),
    616616                                                { yyerror (&yylloc, conf, "Error setting Priority parameter.");
    617                                                   TRACE_DEBUG_ERROR("Error at position : %s\n", err_pos);
     617                                                  TRACE_ERROR("Error at position : %s\n", err_pos);
    618618                                                  YYERROR; } );
    619619                        }
     
    632632                                if (fd == NULL) {
    633633                                        int ret = errno;
    634                                         TRACE_DEBUG_ERROR("Unable to open DH file %s for reading: %s\n", $3, strerror(ret));
     634                                        TRACE_ERROR("Unable to open DH file %s for reading: %s\n", $3, strerror(ret));
    635635                                        yyerror (&yylloc, conf, "Error on file name");
    636636                                        YYERROR;
  • libfdcore/sctp.c

    r961 r965  
    748748                        fd_log_debug("Calling sctp_bindx with the following address array:\n");
    749749                        for (i = 0; i < count; i++) {
    750                                 TRACE_DEBUG_sSA(FULL, "    - ", ptr.sa, NI_NUMERICHOST | NI_NUMERICSERV, "" );
     750                                TRACE_sSA(FD_LOG_DEBUG, FULL, "    - ", ptr.sa, NI_NUMERICHOST | NI_NUMERICSERV, "" );
    751751                                ptr.buf += (ptr.sa->sa_family == AF_INET) ? sizeof(sSA4) : sizeof(sSA6) ;
    752752                        }
     
    776776                fd_log_debug("SCTP server bound on :\n");
    777777                for (ptr.sa = sar; sz-- > 0; ptr.buf += (ptr.sa->sa_family == AF_INET) ? sizeof(sSA4) : sizeof(sSA6)) {
    778                         TRACE_DEBUG_sSA(FULL, "    - ", ptr.sa, NI_NUMERICHOST | NI_NUMERICSERV, "" );
     778                        TRACE_sSA(FD_LOG_DEBUG, FULL, "    - ", ptr.sa, NI_NUMERICHOST | NI_NUMERICSERV, "" );
    779779                }
    780780                sctp_freeladdrs(sar);
     
    842842                ptr.buf = sar.buf;
    843843                for (i=0; i< count; i++) {
    844                         TRACE_DEBUG_sSA(FULL, "  - ", ptr.sa, NI_NUMERICHOST | NI_NUMERICSERV, "" );
     844                        TRACE_sSA(FD_LOG_DEBUG, FULL, "  - ", ptr.sa, NI_NUMERICHOST | NI_NUMERICSERV, "" );
    845845                        ptr.buf += (ptr.sa->sa_family == AF_INET) ? sizeof(sSA4) : sizeof(sSA6);
    846846                }
     
    11511151                        case SCTP_PEER_ADDR_CHANGE:
    11521152                                TRACE_DEBUG(FULL, "Received SCTP_PEER_ADDR_CHANGE notification");
    1153                                 TRACE_DEBUG_sSA(SCTP_LEVEL, "    intf_change : ", &(notif->sn_paddr_change.spc_aaddr), NI_NUMERICHOST | NI_NUMERICSERV, "" );
     1153                                TRACE_sSA(FD_LOG_DEBUG, SCTP_LEVEL, "    intf_change : ", &(notif->sn_paddr_change.spc_aaddr), NI_NUMERICHOST | NI_NUMERICSERV, "" );
    11541154                                TRACE_DEBUG(SCTP_LEVEL, "          state : %d", notif->sn_paddr_change.spc_state);
    11551155                                TRACE_DEBUG(SCTP_LEVEL, "          error : %d", notif->sn_paddr_change.spc_error);
  • libfdcore/sctps.c

    r894 r965  
    343343       
    344344        CHECK_POSIX_DO( pthread_rwlock_wrlock(&sto->lock), return -1 );
    345         TRACE_DEBUG_BUFFER(GNUTLS_DBG_LEVEL, "Session store [key ", key.data, key.size, "]");
     345        TRACE_BUFFER(FD_LOG_DEBUG, GNUTLS_DBG_LEVEL, "Session store [key ", key.data, key.size, "]");
    346346       
    347347        li = find_or_next(sto, key, &match);
     
    352352                if ((data.size != sr->data.size) || memcmp(data.data, sr->data.data, data.size)) {
    353353                        TRACE_DEBUG(INFO, "GnuTLS tried to store a session with same key and different data!");
    354                         TRACE_DEBUG_BUFFER(INFO, "Session store [key ", key.data, key.size, "]");
    355                         TRACE_DEBUG_BUFFER(INFO, "  -- old data [", sr->data.data, sr->data.size, "]");
    356                         TRACE_DEBUG_BUFFER(INFO, "  -- new data [", data.data, data.size, "]");
     354                        TRACE_BUFFER(FD_LOG_DEBUG, INFO, "Session store [key ", key.data, key.size, "]");
     355                        TRACE_BUFFER(FD_LOG_DEBUG, INFO, "  -- old data [", sr->data.data, sr->data.size, "]");
     356                        TRACE_BUFFER(FD_LOG_DEBUG, INFO, "  -- new data [", data.data, data.size, "]");
    357357                       
    358358                        ret = -1;
     
    397397       
    398398        CHECK_POSIX_DO( pthread_rwlock_wrlock(&sto->lock), return -1 );
    399         TRACE_DEBUG_BUFFER(GNUTLS_DBG_LEVEL, "Session delete [key ", key.data, key.size, "]");
     399        TRACE_BUFFER(FD_LOG_DEBUG, GNUTLS_DBG_LEVEL, "Session delete [key ", key.data, key.size, "]");
    400400       
    401401        li = find_or_next(sto, key, &match);
     
    430430
    431431        CHECK_POSIX_DO( pthread_rwlock_rdlock(&sto->lock), return error );
    432         TRACE_DEBUG_BUFFER(GNUTLS_DBG_LEVEL, "Session fetch [key ", key.data, key.size, "]");
     432        TRACE_BUFFER(FD_LOG_DEBUG, GNUTLS_DBG_LEVEL, "Session fetch [key ", key.data, key.size, "]");
    433433       
    434434        li = find_or_next(sto, key, &match);
     
    557557                        size_t   ids = sizeof(id);
    558558                        CHECK_GNUTLS_DO( gnutls_session_get_id(conn->cc_tls_para.session, id, &ids), /* continue */ );
    559                         TRACE_DEBUG_BUFFER(GNUTLS_DBG_LEVEL, "Master session id: [", id, ids, "]");
     559                        TRACE_BUFFER(FD_LOG_DEBUG, GNUTLS_DBG_LEVEL, "Master session id: [", id, ids, "]");
    560560                }
    561561        }
  • libfdcore/tcp.c

    r788 r965  
    137137        pthread_cleanup_push(fd_cleanup_socket, &s);
    138138       
    139         TRACE_DEBUG_sSA(FULL, "Attempting TCP connection with peer: ", sa, NI_NUMERICHOST | NI_NUMERICSERV, "..." );
     139        TRACE_sSA(FD_LOG_DEBUG, FULL, "Attempting TCP connection with peer: ", sa, NI_NUMERICHOST | NI_NUMERICSERV, "..." );
    140140       
    141141        /* Try connecting to the remote address */
  • libfdproto/log.c

    r961 r965  
    9595
    9696    /* add timestamp */
    97     fprintf(fd_g_debug_fstr, "%s\t", fd_log_time(NULL, buf, sizeof(buf)));
     97    fprintf(fd_g_debug_fstr, "%s  ", fd_log_time(NULL, buf, sizeof(buf)));
     98    switch(loglevel) {
     99            case FD_LOG_DEBUG:  fprintf(fd_g_debug_fstr, " DBG   "); break;
     100            case FD_LOG_NOTICE: fprintf(fd_g_debug_fstr, "NOTI   "); break;
     101            case FD_LOG_ERROR:  fprintf(fd_g_debug_fstr, "ERROR  "); break;
     102            default:            fprintf(fd_g_debug_fstr, " ???   ");
     103    }
    98104    vfprintf(fd_g_debug_fstr, format, ap);
    99105    if (format && (format[strlen(format)-1] != '\n')) {
Note: See TracChangeset for help on using the changeset viewer.