Navigation


Changeset 965:9b37f34c1b1f in freeDiameter for libfdcore


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...
Location:
libfdcore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • 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 */
Note: See TracChangeset for help on using the changeset viewer.