Mercurial > hg > freeDiameter
changeset 944:6cdb2a54aaf6
Log config file errors using the standard logging framework instead of fprintf.
author | Thomas Klausner <tk@giga.or.at> |
---|---|
date | Tue, 12 Feb 2013 11:51:10 +0100 |
parents | e6bf3214d1ef |
children | 284608b307ee |
files | libfdcore/fdd.l libfdcore/fdd.y |
diffstat | 2 files changed, 10 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/libfdcore/fdd.l Sun Jan 20 03:22:41 2013 +0100 +++ b/libfdcore/fdd.l Tue Feb 12 11:51:10 2013 +0100 @@ -51,8 +51,7 @@ #define YY_USER_ACTION { \ yylloc->first_column = yylloc->last_column + 1; \ yylloc->last_column = yylloc->first_column + yyleng - 1; \ - TRACE_DEBUG(FULL, \ - "(%d:%d-%d:%d) matched rule %d, length=%d, txt='%s'\n", \ + TRACE_DEBUG_ERROR("(%d:%d-%d:%d) matched rule %d, length=%d, txt='%s'\n", \ yylloc->first_line, yylloc->first_column, \ yylloc->last_line, yylloc->last_column, \ yy_act, yyleng, yytext); \ @@ -103,7 +102,7 @@ int ret = sscanf(yytext, "%i", &yylval->integer); if (ret != 1) { /* No matching: an error occurred */ - fprintf(stderr, "Unable to convert the value '%s' to a valid number: %s\n", yytext, strerror(errno)); + TRACE_DEBUG_ERROR("Unable to convert the value '%s' to a valid number: %s\n", yytext, strerror(errno)); return LEX_ERROR; /* trig an error in yacc parser */ /* Maybe we could REJECT instead of failing here? */ } @@ -146,7 +145,7 @@ <*>[[:alnum:]]+ | /* This rule is only useful to print a complete token in error messages */ /* Unrecognized character */ <*>. { - fprintf(stderr, "Unrecognized text on line %d col %d: '%s'.\n", yylloc->first_line, yylloc->first_column, yytext); + TRACE_DEBUG_ERROR("Unrecognized text on line %d col %d: '%s'.\n", yylloc->first_line, yylloc->first_column, yytext); return LEX_ERROR; }
--- a/libfdcore/fdd.y Sun Jan 20 03:22:41 2013 +0100 +++ b/libfdcore/fdd.y Tue Feb 12 11:51:10 2013 +0100 @@ -61,12 +61,13 @@ /* Function to report error */ void yyerror (YYLTYPE *ploc, struct fd_config * conf, char const *s) { - if (ploc->first_line != ploc->last_line) - fprintf(stderr, "%s:%d.%d-%d.%d : %s\n", conf->cnf_file, ploc->first_line, ploc->first_column, ploc->last_line, ploc->last_column, s); - else if (ploc->first_column != ploc->last_column) - fprintf(stderr, "%s:%d.%d-%d : %s\n", conf->cnf_file, ploc->first_line, ploc->first_column, ploc->last_column, s); - else - fprintf(stderr, "%s:%d.%d : %s\n", conf->cnf_file, ploc->first_line, ploc->first_column, s); + if (ploc->first_line != ploc->last_line) { + 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); + } else if (ploc->first_column != ploc->last_column) { + TRACE_DEBUG_ERROR("%s:%d.%d-%d : %s\n", conf->cnf_file, ploc->first_line, ploc->first_column, ploc->last_column, s); + } else { + TRACE_DEBUG_ERROR("%s:%d.%d : %s\n", conf->cnf_file, ploc->first_line, ploc->first_column, s); + } } int got_peer_noip = 0;