From 1bfe85099f0343a83f390ea9840e224fb06acc55 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 16 Nov 2015 13:56:23 +0200 Subject: [PATCH] server/module/filters: All LOGIF and skygw_log_write calls removed. All LOGIF and skygw_log_write calls have been replaced with the equivalent MXS_[ERROR|WARNING|NOTICE|INFO|DEBUG] calls. --- server/modules/filter/dbfwfilter.c | 157 ++++++++-------- server/modules/filter/hint/hintparser.c | 79 ++------ server/modules/filter/mqfilter.c | 120 +++++------- server/modules/filter/namedserverfilter.c | 37 ++-- server/modules/filter/qlafilter.c | 74 ++++---- server/modules/filter/regexfilter.c | 30 ++- server/modules/filter/slavelag.c | 24 +-- server/modules/filter/tee.c | 193 +++++++++----------- server/modules/filter/test/harness_common.c | 33 ++-- server/modules/filter/test/harness_ui.c | 8 +- server/modules/filter/test/harness_util.c | 2 +- server/modules/filter/topfilter.c | 51 +++--- 12 files changed, 336 insertions(+), 472 deletions(-) diff --git a/server/modules/filter/dbfwfilter.c b/server/modules/filter/dbfwfilter.c index 1460759b2..7334011a4 100644 --- a/server/modules/filter/dbfwfilter.c +++ b/server/modules/filter/dbfwfilter.c @@ -514,7 +514,7 @@ static TIMERANGE* parse_time(const char* str) } else { - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: malloc returned NULL."); + MXS_ERROR("dbfwfilter: malloc returned NULL."); } } } @@ -596,7 +596,7 @@ RULE* find_rule(char* tok, FW_INSTANCE* instance) } rlist = rlist->next; } - skygw_log_write(LOGFILE_ERROR, "Error : Rule not found: %s",tok); + MXS_ERROR("Rule not found: %s",tok); return NULL; } @@ -611,7 +611,7 @@ void add_users(char* rule, FW_INSTANCE* instance) STRLINK* link = calloc(1,sizeof(STRLINK)); if(link == NULL){ - skygw_log_write(LOGFILE_ERROR,"Error : Memory allocation failed"); + MXS_ERROR("Memory allocation failed"); return; } link->next = instance->userstrings; @@ -644,9 +644,9 @@ bool link_rules(char* orig, FW_INSTANCE* instance) if((userptr == NULL || ruleptr == NULL || modeptr == NULL)|| (userptr > modeptr || userptr > ruleptr || modeptr > ruleptr)) { - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Rule syntax incorrect, right keywords not found in the correct order: %s",orig); - rval = false; - goto parse_err; + MXS_ERROR("dbfwfilter: Rule syntax incorrect, right keywords not found in the correct order: %s",orig); + rval = false; + goto parse_err; } *modeptr++ = '\0'; @@ -656,7 +656,7 @@ bool link_rules(char* orig, FW_INSTANCE* instance) if(tok == NULL) { - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Rule syntax incorrect, right keywords not found in the correct order: %s",orig); + MXS_ERROR("dbfwfilter: Rule syntax incorrect, right keywords not found in the correct order: %s",orig); rval = false; goto parse_err; } @@ -665,7 +665,7 @@ bool link_rules(char* orig, FW_INSTANCE* instance) tok = strtok_r(NULL," ",&saveptr); if(tok == NULL) { - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Rule syntax incorrect, missing keyword after 'match': %s",orig); + MXS_ERROR("dbfwfilter: Rule syntax incorrect, missing keyword after 'match': %s",orig); rval = false; goto parse_err; } @@ -677,14 +677,14 @@ bool link_rules(char* orig, FW_INSTANCE* instance) match_any = false; strict = true; }else{ - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Rule syntax incorrect, 'match' was not followed by correct keyword: %s",orig); - rval = false; - goto parse_err; + MXS_ERROR("dbfwfilter: Rule syntax incorrect, 'match' was not followed by correct keyword: %s",orig); + rval = false; + goto parse_err; } } else { - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Rule syntax incorrect, bad token: %s",tok); + MXS_ERROR("dbfwfilter: Rule syntax incorrect, bad token: %s",tok); rval = false; goto parse_err; } @@ -693,7 +693,7 @@ bool link_rules(char* orig, FW_INSTANCE* instance) if(tok != NULL) { - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Rule syntax incorrect, extra token found after 'match' keyword: %s",orig); + MXS_ERROR("dbfwfilter: Rule syntax incorrect, extra token found after 'match' keyword: %s",orig); rval = false; goto parse_err; } @@ -702,7 +702,7 @@ bool link_rules(char* orig, FW_INSTANCE* instance) if(tok == NULL) { - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Rule syntax incorrect, no rules given: %s",orig); + MXS_ERROR("dbfwfilter: Rule syntax incorrect, no rules given: %s",orig); rval = false; goto parse_err; } @@ -711,7 +711,7 @@ bool link_rules(char* orig, FW_INSTANCE* instance) if(tok == NULL) { - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Rule syntax incorrect, no rules given: %s",orig); + MXS_ERROR("dbfwfilter: Rule syntax incorrect, no rules given: %s",orig); rval = false; goto parse_err; } @@ -730,7 +730,7 @@ bool link_rules(char* orig, FW_INSTANCE* instance) } else { - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Rule syntax incorrect, could not find rule '%s'.",tok); + MXS_ERROR("dbfwfilter: Rule syntax incorrect, could not find rule '%s'.",tok); rval = false; goto parse_err; } @@ -747,14 +747,14 @@ bool link_rules(char* orig, FW_INSTANCE* instance) if(userptr == NULL) { - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Rule syntax incorrect, no users given: %s",orig); + MXS_ERROR("dbfwfilter: Rule syntax incorrect, no users given: %s",orig); rval = false; goto parse_err; } if(rulelist == NULL) { - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Rule syntax incorrect, no rules found: %s",orig); + MXS_ERROR("dbfwfilter: Rule syntax incorrect, no rules found: %s",orig); rval = false; goto parse_err; } @@ -770,7 +770,7 @@ bool link_rules(char* orig, FW_INSTANCE* instance) user = (USER*)calloc(1,sizeof(USER)); if(user == NULL){ - skygw_log_write(LOGFILE_ERROR,"Error: dbfwfilter: failed to allocate memory when parsing rules."); + MXS_ERROR("dbfwfilter: failed to allocate memory when parsing rules."); rval = false; goto parse_err; } @@ -858,7 +858,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) if(tok == NULL) { - skygw_log_write(LOGFILE_ERROR,"dbfwfilter: Rule parsing failed, no rule: %s",rule); + MXS_ERROR("dbfwfilter: Rule parsing failed, no rule: %s",rule); rval = false; goto retblock; } @@ -872,7 +872,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) if(tok == NULL) { - skygw_log_write(LOGFILE_ERROR,"dbfwfilter: Rule parsing failed, incomplete rule: %s",rule); + MXS_ERROR("dbfwfilter: Rule parsing failed, incomplete rule: %s",rule); rval = false; goto retblock; } @@ -883,7 +883,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) if(ruledef == NULL) { - skygw_log_write(LOGFILE_ERROR,"Error: Memory allocation failed."); + MXS_ERROR("Memory allocation failed."); rval = false; goto retblock; } @@ -893,7 +893,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) if(rlist == NULL) { free(ruledef); - skygw_log_write(LOGFILE_ERROR,"Error: Memory allocation failed."); + MXS_ERROR("Memory allocation failed."); rval = false; goto retblock; } @@ -914,7 +914,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) } else { - skygw_log_write(LOGFILE_ERROR,"Error : Unknown token in rule '%s': %s",rule,tok); + MXS_ERROR("Unknown token in rule '%s': %s",rule,tok); rval = false; goto retblock; } @@ -923,7 +923,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) if(tok == NULL) { - skygw_log_write(LOGFILE_ERROR,"dbfwfilter: Rule parsing failed, no allow or deny: %s",rule); + MXS_ERROR("dbfwfilter: Rule parsing failed, no allow or deny: %s",rule); rval = false; goto retblock; } @@ -948,7 +948,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) { if(req_defined) { - skygw_log_write(LOGFILE_ERROR,"dbfwfilter: Rule parsing failed, Multiple non-optional rules: %s",rule); + MXS_ERROR("dbfwfilter: Rule parsing failed, Multiple non-optional rules: %s",rule); rval = false; goto retblock; } @@ -985,7 +985,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) { if(at_def) { - skygw_log_write(LOGFILE_ERROR,"dbfwfilter: Rule parsing failed, multiple 'at_times' tokens: %s",rule); + MXS_ERROR("dbfwfilter: Rule parsing failed, multiple 'at_times' tokens: %s",rule); rval = false; goto retblock; } @@ -997,7 +997,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) break; if(!check_time(tok)) { - skygw_log_write(LOGFILE_ERROR,"dbfwfilter: Rule parsing failed, malformed time definition: %s",tok); + MXS_ERROR("dbfwfilter: Rule parsing failed, malformed time definition: %s",tok); rval = false; goto retblock; } @@ -1006,7 +1006,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) if(tmp == NULL) { - skygw_log_write(LOGFILE_ERROR,"dbfwfilter: Rule parsing failed, unexpected characters after time definition."); + MXS_ERROR("dbfwfilter: Rule parsing failed, unexpected characters after time definition."); rval = false; tr_free(tr); goto retblock; @@ -1038,14 +1038,14 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) if(tok == NULL) { - skygw_log_write(LOGFILE_ERROR,"dbfwfilter: Rule parsing failed, No regex string."); + MXS_ERROR("dbfwfilter: Rule parsing failed, No regex string."); rval = false; goto retblock; } if(*tok != '\'' && *tok != '\"') { - skygw_log_write(LOGFILE_ERROR,"dbfwfilter: Rule parsing failed, regex string not quoted."); + MXS_ERROR("dbfwfilter: Rule parsing failed, regex string not quoted."); rval = false; goto retblock; } @@ -1079,7 +1079,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) if(n_char >= 2048) { - skygw_log_write_flush(LOGFILE_ERROR, "dbfwfilter: Failed to parse rule, regular expression length is over 2048 characters."); + MXS_ERROR("dbfwfilter: Failed to parse rule, regular expression length is over 2048 characters."); rval = false; goto retblock; } @@ -1087,14 +1087,14 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) str = calloc(((tok - start) + 1),sizeof(char)); if(str == NULL) { - skygw_log_write_flush(LOGFILE_ERROR, "Fatal Error: malloc returned NULL."); + MXS_ERROR("Fatal Error: malloc returned NULL."); rval = false; goto retblock; } re = (regex_t*)malloc(sizeof(regex_t)); if(re == NULL){ - skygw_log_write_flush(LOGFILE_ERROR, "Fatal Error: malloc returned NULL."); + MXS_ERROR("Fatal Error: malloc returned NULL."); rval = false; free(str); goto retblock; @@ -1103,7 +1103,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) memcpy(str, start, (tok-start)); if(regcomp(re, str,REG_NOSUB|instance->regflags)){ - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Invalid regular expression '%s'.", str); + MXS_ERROR("dbfwfilter: Invalid regular expression '%s'.", str); rval = false; free(re); goto retblock; @@ -1130,7 +1130,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) if(tok == NULL){ free(qs); rval = false; - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Missing parameter in limit_queries: '%s'.", rule); + MXS_ERROR("dbfwfilter: Missing parameter in limit_queries: '%s'.", rule); goto retblock; } @@ -1140,14 +1140,14 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) { free(qs); rval = false; - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Rule parsing failed, not a number: '%s'.", tok); + MXS_ERROR("dbfwfilter: Rule parsing failed, not a number: '%s'.", tok); goto retblock; } if(qs->limit < 1){ free(qs); rval = false; - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Bad query amount: %s", tok); + MXS_ERROR("dbfwfilter: Bad query amount: %s", tok); goto retblock; } @@ -1157,7 +1157,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) if(tok == NULL){ free(qs); rval = false; - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Missing parameter in limit_queries: '%s'.", rule); + MXS_ERROR("dbfwfilter: Missing parameter in limit_queries: '%s'.", rule); goto retblock; } @@ -1167,14 +1167,14 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) { free(qs); rval = false; - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Rule parsing failed, not a number: '%s'.", tok); + MXS_ERROR("dbfwfilter: Rule parsing failed, not a number: '%s'.", tok); goto retblock; } if(qs->period < 1){ free(qs); rval = false; - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Bad time period: %s", tok); + MXS_ERROR("dbfwfilter: Bad time period: %s", tok); goto retblock; } @@ -1184,7 +1184,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) if(tok == NULL){ free(qs); rval = false; - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Missing parameter in limit_queries: '%s'.", rule); + MXS_ERROR("dbfwfilter: Missing parameter in limit_queries: '%s'.", rule); goto retblock; } qs->cooldown = strtod(tok,&errptr); @@ -1193,14 +1193,14 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) { free(qs); rval = false; - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Rule parsing failed, not a number: '%s'.", tok); + MXS_ERROR("dbfwfilter: Rule parsing failed, not a number: '%s'.", tok); goto retblock; } if(qs->cooldown < 1){ free(qs); rval = false; - skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Bad blocking period: %s", tok); + MXS_ERROR("dbfwfilter: Bad blocking period: %s", tok); goto retblock; } @@ -1216,7 +1216,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) { if(oq_def) { - skygw_log_write(LOGFILE_ERROR,"dbfwfilter: Rule parsing failed, multiple 'on_queries' tokens: %s",rule); + MXS_ERROR("dbfwfilter: Rule parsing failed, multiple 'on_queries' tokens: %s",rule); rval = false; goto retblock; } @@ -1225,28 +1225,22 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) if(tok == NULL) { - skygw_log_write(LOGFILE_ERROR, - "dbfwfilter: Missing parameter for 'on_queries'."); + MXS_ERROR("dbfwfilter: Missing parameter for 'on_queries'."); rval = false; goto retblock; } if(!parse_querytypes(tok,ruledef)){ - skygw_log_write(LOGFILE_ERROR, - "dbfwfilter: Invalid query type" - "requirements: %s." - ,tok); + MXS_ERROR("dbfwfilter: Invalid query type requirements: %s.", tok); rval = false; goto retblock; } } else { - skygw_log_write(LOGFILE_ERROR, - "dbfwfilter: Unknown rule type: %s" - ,tok); - rval = false; - goto retblock; + MXS_ERROR("dbfwfilter: Unknown rule type: %s", tok); + rval = false; + goto retblock; } tok = strtok_r(NULL," ,",&saveptr); } @@ -1298,16 +1292,16 @@ createInstance(char **options, FILTER_PARAMETER **params) if ((my_instance = calloc(1, sizeof(FW_INSTANCE))) == NULL || (my_instance->lock = (SPINLOCK*)malloc(sizeof(SPINLOCK))) == NULL){ - skygw_log_write(LOGFILE_ERROR, "Memory allocation for firewall filter failed."); - return NULL; + MXS_ERROR("Memory allocation for firewall filter failed."); + return NULL; } spinlock_init(my_instance->lock); if((ht = hashtable_alloc(100, hashkeyfun, hashcmpfun)) == NULL){ - skygw_log_write(LOGFILE_ERROR, "Unable to allocate hashtable."); - free(my_instance); - return NULL; + MXS_ERROR("Unable to allocate hashtable."); + free(my_instance); + return NULL; } hashtable_memory_fns(ht,(HASHMEMORYFN)strdup,NULL,(HASHMEMORYFN)free,huserfree); @@ -1338,15 +1332,15 @@ createInstance(char **options, FILTER_PARAMETER **params) if(filename == NULL) { - skygw_log_write(LOGFILE_ERROR, "Unable to find rule file for firewall filter. Please provide the path with" - " rules="); + MXS_ERROR("Unable to find rule file for firewall filter. Please provide the path with" + " rules="); hashtable_free(my_instance->htable); free(my_instance); return NULL; } if((file = fopen(filename,"rb")) == NULL ){ - skygw_log_write(LOGFILE_ERROR, "Error while opening rule file for firewall filter."); + MXS_ERROR("Error while opening rule file for firewall filter."); hashtable_free(my_instance->htable); free(my_instance); free(filename); @@ -1361,7 +1355,7 @@ createInstance(char **options, FILTER_PARAMETER **params) if(fgets(buffer,2048,file) == NULL){ if(ferror(file)){ - skygw_log_write(LOGFILE_ERROR, "Error while reading rule file for firewall filter."); + MXS_ERROR("Error while reading rule file for firewall filter."); fclose(file); hashtable_free(my_instance->htable); free(my_instance); @@ -1394,7 +1388,7 @@ createInstance(char **options, FILTER_PARAMETER **params) if(file_empty) { - skygw_log_write(LOGFILE_ERROR,"dbfwfilter: File is empty: %s", filename); + MXS_ERROR("dbfwfilter: File is empty: %s", filename); free(filename); err = true; goto retblock; @@ -1408,7 +1402,7 @@ createInstance(char **options, FILTER_PARAMETER **params) if(ptr == NULL) { - skygw_log_write(LOGFILE_ERROR,"dbfwfilter: No 'users' line found."); + MXS_ERROR("dbfwfilter: No 'users' line found."); err = true; goto retblock; } @@ -1417,7 +1411,7 @@ createInstance(char **options, FILTER_PARAMETER **params) if(!link_rules(ptr->value,my_instance)) { - skygw_log_write(LOGFILE_ERROR,"dbfwfilter: Failed to parse rule: %s",ptr->value); + MXS_ERROR("dbfwfilter: Failed to parse rule: %s",ptr->value); err = true; } tmp = ptr; @@ -1525,7 +1519,7 @@ GWBUF* gen_dummy_error(FW_SESSION* session, char* msg) session->session->data == NULL || session->session->client == NULL) { - skygw_log_write_flush(LOGFILE_ERROR, "Error : Firewall filter session missing data."); + MXS_ERROR("Firewall filter session missing data."); return NULL; } @@ -1535,8 +1529,8 @@ GWBUF* gen_dummy_error(FW_SESSION* session, char* msg) errmsg = (char*)malloc((512 + errlen)*sizeof(char)); if(errmsg == NULL){ - skygw_log_write_flush(LOGFILE_ERROR, "Fatal Error: Memory allocation failed."); - return NULL; + MXS_ERROR("Memory allocation failed."); + return NULL; } @@ -1673,7 +1667,7 @@ bool rule_matches(FW_INSTANCE* my_instance, FW_SESSION* my_session, GWBUF *queue switch(rulelist->rule->type){ case RT_UNDEFINED: - skygw_log_write_flush(LOGFILE_ERROR, "Error: Undefined rule type found."); + MXS_ERROR("Undefined rule type found."); break; case RT_REGEX: @@ -1684,7 +1678,7 @@ bool rule_matches(FW_INSTANCE* my_instance, FW_SESSION* my_session, GWBUF *queue if(!rulelist->rule->allow){ msg = strdup("Permission denied, query matched regular expression."); - skygw_log_write(LOGFILE_TRACE, "dbfwfilter: rule '%s': regex matched on query",rulelist->rule->name); + MXS_INFO("dbfwfilter: rule '%s': regex matched on query",rulelist->rule->name); goto queryresolved; }else{ break; @@ -1697,7 +1691,7 @@ bool rule_matches(FW_INSTANCE* my_instance, FW_SESSION* my_session, GWBUF *queue if(!rulelist->rule->allow){ matches = true; msg = strdup("Permission denied at this time."); - skygw_log_write(LOGFILE_TRACE, "dbfwfilter: rule '%s': query denied at: %s",rulelist->rule->name,asctime(tm_now)); + MXS_INFO("dbfwfilter: rule '%s': query denied at: %s",rulelist->rule->name,asctime(tm_now)); goto queryresolved; }else{ break; @@ -1724,7 +1718,8 @@ bool rule_matches(FW_INSTANCE* my_instance, FW_SESSION* my_session, GWBUF *queue if(!rulelist->rule->allow) { sprintf(emsg,"Permission denied to column '%s'.",strln->value); - skygw_log_write(LOGFILE_TRACE, "dbfwfilter: rule '%s': query targets forbidden column: %s",rulelist->rule->name,strln->value); + MXS_INFO("dbfwfilter: rule '%s': query targets forbidden column: %s", + rulelist->rule->name,strln->value); msg = strdup(emsg); goto queryresolved; } @@ -1755,7 +1750,7 @@ bool rule_matches(FW_INSTANCE* my_instance, FW_SESSION* my_session, GWBUF *queue matches = true; msg = strdup("Usage of wildcard denied."); - skygw_log_write(LOGFILE_TRACE, "dbfwfilter: rule '%s': query contains a wildcard.",rulelist->rule->name); + MXS_INFO("dbfwfilter: rule '%s': query contains a wildcard.",rulelist->rule->name); goto queryresolved; } free(where); @@ -1808,7 +1803,7 @@ bool rule_matches(FW_INSTANCE* my_instance, FW_SESSION* my_session, GWBUF *queue double blocked_for = queryspeed->cooldown - difftime(time_now,queryspeed->triggered); sprintf(emsg,"Queries denied for %f seconds",blocked_for); - skygw_log_write(LOGFILE_TRACE, "dbfwfilter: rule '%s': user denied for %f seconds",rulelist->rule->name,blocked_for); + MXS_INFO("dbfwfilter: rule '%s': user denied for %f seconds",rulelist->rule->name,blocked_for); msg = strdup(emsg); matches = true; @@ -1828,8 +1823,8 @@ bool rule_matches(FW_INSTANCE* my_instance, FW_SESSION* my_session, GWBUF *queue matches = true; queryspeed->active = true; - skygw_log_write(LOGFILE_TRACE, - "dbfwfilter: rule '%s': query limit triggered (%d queries in %f seconds), denying queries from user for %f seconds.", + MXS_INFO("dbfwfilter: rule '%s': query limit triggered (%d queries in %f seconds), " + "denying queries from user for %f seconds.", rulelist->rule->name, queryspeed->limit, queryspeed->period, @@ -1859,8 +1854,8 @@ bool rule_matches(FW_INSTANCE* my_instance, FW_SESSION* my_session, GWBUF *queue { matches = true; msg = strdup("Required WHERE/HAVING clause is missing."); - skygw_log_write(LOGFILE_TRACE, "dbfwfilter: rule '%s': query has no where/having clause, query is denied.", - rulelist->rule->name); + MXS_INFO("dbfwfilter: rule '%s': query has no where/having clause, query is denied.", + rulelist->rule->name); } break; diff --git a/server/modules/filter/hint/hintparser.c b/server/modules/filter/hint/hintparser.c index 6556b2a99..f43c4caee 100644 --- a/server/modules/filter/hint/hintparser.c +++ b/server/modules/filter/hint/hintparser.c @@ -266,18 +266,10 @@ HINT_MODE mode = HM_EXECUTE; break; default: /* Error: expected hint, name or STOP */ - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Error : Syntax error in hint. Expected " - "'route', 'stop' or hint name instead of " - "'%s'. Hint ignored.", - token_get_keyword(tok)))); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Syntax error in hint. Expected " - "'route', 'stop' or hint name instead of " - "'%s'. Hint ignored.", - token_get_keyword(tok)))); + MXS_ERROR("Syntax error in hint. Expected " + "'route', 'stop' or hint name instead of " + "'%s'. Hint ignored.", + token_get_keyword(tok)); token_free(tok); goto retblock; } @@ -286,16 +278,9 @@ HINT_MODE mode = HM_EXECUTE; if (tok->token != TOK_TO) { /* Error, expect TO */; - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Error : Syntax error in hint. Expected " + MXS_ERROR("Syntax error in hint. Expected " "'to' instead of '%s'. Hint ignored.", - token_get_keyword(tok)))); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Syntax error in hint. Expected " - "'to' instead of '%s'. Hint ignored.", - token_get_keyword(tok)))); + token_get_keyword(tok)); token_free(tok); goto retblock; } @@ -317,18 +302,10 @@ HINT_MODE mode = HM_EXECUTE; break; default: /* Error expected MASTER, SLAVE or SERVER */ - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Error : Syntax error in hint. Expected " + MXS_ERROR("Syntax error in hint. Expected " "'master', 'slave', or 'server' instead " "of '%s'. Hint ignored.", - token_get_keyword(tok)))); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Syntax error in hint. Expected " - "'master', 'slave', or 'server' instead " - "of '%s'. Hint ignored.", - token_get_keyword(tok)))); + token_get_keyword(tok)); token_free(tok); goto retblock; @@ -343,18 +320,10 @@ HINT_MODE mode = HM_EXECUTE; else { /* Error: Expected server name */ - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Error : Syntax error in hint. Expected " + MXS_ERROR("Syntax error in hint. Expected " "server name instead of '%s'. Hint " "ignored.", - token_get_keyword(tok)))); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Syntax error in hint. Expected " - "server name instead of '%s'. Hint " - "ignored.", - token_get_keyword(tok)))); + token_get_keyword(tok)); token_free(tok); goto retblock; } @@ -378,18 +347,10 @@ HINT_MODE mode = HM_EXECUTE; break; default: /* Error, token tok->value not expected */ - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Error : Syntax error in hint. Expected " - "'=', 'prepare', or 'start' instead of " - "'%s'. Hint ignored.", - token_get_keyword(tok)))); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Syntax error in hint. Expected " - "'=', 'prepare', or 'start' instead of " - "'%s'. Hint ignored.", - token_get_keyword(tok)))); + MXS_ERROR("Syntax error in hint. Expected " + "'=', 'prepare', or 'start' instead of " + "'%s'. Hint ignored.", + token_get_keyword(tok)); token_free(tok); goto retblock; } @@ -413,18 +374,10 @@ HINT_MODE mode = HM_EXECUTE; break; default: /* Error, token tok->value not expected */ - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Error : Syntax error in hint. Expected " + MXS_ERROR("Syntax error in hint. Expected " "'route' or hint name instead of " "'%s'. Hint ignored.", - token_get_keyword(tok)))); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Syntax error in hint. Expected " - "'route' or hint name instead of " - "'%s'. Hint ignored.", - token_get_keyword(tok)))); + token_get_keyword(tok)); token_free(tok); goto retblock; } diff --git a/server/modules/filter/mqfilter.c b/server/modules/filter/mqfilter.c index 7d78f20ea..1587240bd 100644 --- a/server/modules/filter/mqfilter.c +++ b/server/modules/filter/mqfilter.c @@ -307,53 +307,45 @@ init_conn(MQ_INSTANCE *my_instance) if((my_instance->sock = amqp_ssl_socket_new(my_instance->conn)) != NULL){ if((amqp_ok = amqp_ssl_socket_set_cacert(my_instance->sock,my_instance->ssl_CA_cert)) != AMQP_STATUS_OK){ - skygw_log_write(LOGFILE_ERROR, - "Error : Failed to set CA certificate: %s", amqp_error_string2(amqp_ok)); - goto cleanup; + MXS_ERROR("Failed to set CA certificate: %s", amqp_error_string2(amqp_ok)); + goto cleanup; } if((amqp_ok = amqp_ssl_socket_set_key(my_instance->sock, my_instance->ssl_client_cert, my_instance->ssl_client_key)) != AMQP_STATUS_OK){ - skygw_log_write(LOGFILE_ERROR, - "Error : Failed to set client certificate and key: %s", amqp_error_string2(amqp_ok)); - goto cleanup; + MXS_ERROR("Failed to set client certificate and key: %s", amqp_error_string2(amqp_ok)); + goto cleanup; } }else{ amqp_ok = AMQP_STATUS_SSL_CONNECTION_FAILED; - skygw_log_write(LOGFILE_ERROR, - "Error : SSL socket creation failed."); + MXS_ERROR("SSL socket creation failed."); goto cleanup; } /**SSL is not used, falling back to TCP*/ }else if((my_instance->sock = amqp_tcp_socket_new(my_instance->conn)) == NULL){ - skygw_log_write(LOGFILE_ERROR, - "Error : TCP socket creation failed."); - goto cleanup; + MXS_ERROR("TCP socket creation failed."); + goto cleanup; } /**Socket creation was successful, trying to open the socket*/ if((amqp_ok = amqp_socket_open(my_instance->sock,my_instance->hostname,my_instance->port)) != AMQP_STATUS_OK){ - skygw_log_write(LOGFILE_ERROR, - "Error : Failed to open socket: %s", amqp_error_string2(amqp_ok)); - goto cleanup; + MXS_ERROR("Failed to open socket: %s", amqp_error_string2(amqp_ok)); + goto cleanup; } amqp_rpc_reply_t reply; reply = amqp_login(my_instance->conn,my_instance->vhost,0,AMQP_DEFAULT_FRAME_SIZE,0,AMQP_SASL_METHOD_PLAIN,my_instance->username,my_instance->password); if(reply.reply_type != AMQP_RESPONSE_NORMAL){ - skygw_log_write(LOGFILE_ERROR, - "Error : Login to RabbitMQ server failed."); - - goto cleanup; + MXS_ERROR("Login to RabbitMQ server failed."); + goto cleanup; } amqp_channel_open(my_instance->conn,my_instance->channel); reply = amqp_get_rpc_reply(my_instance->conn); if(reply.reply_type != AMQP_RESPONSE_NORMAL){ - skygw_log_write(LOGFILE_ERROR, - "Error : Channel creation failed."); - goto cleanup; + MXS_ERROR("Channel creation failed."); + goto cleanup; } amqp_exchange_declare(my_instance->conn,my_instance->channel, @@ -365,8 +357,7 @@ init_conn(MQ_INSTANCE *my_instance) reply = amqp_get_rpc_reply(my_instance->conn); if(reply.reply_type != AMQP_RESPONSE_NORMAL){ - skygw_log_write(LOGFILE_ERROR, - "Error : Exchange declaration failed,trying to redeclare the exchange."); + MXS_ERROR("Exchange declaration failed,trying to redeclare the exchange."); if(reply.reply_type == AMQP_RESPONSE_SERVER_EXCEPTION){ if(reply.reply.id == AMQP_CHANNEL_CLOSE_METHOD){ amqp_send_method(my_instance->conn,my_instance->channel,AMQP_CHANNEL_CLOSE_OK_METHOD,NULL); @@ -386,9 +377,8 @@ init_conn(MQ_INSTANCE *my_instance) reply = amqp_get_rpc_reply(my_instance->conn); } if(reply.reply_type != AMQP_RESPONSE_NORMAL){ - skygw_log_write(LOGFILE_ERROR, - "Error : Exchange redeclaration failed."); - goto cleanup; + MXS_ERROR("Exchange redeclaration failed."); + goto cleanup; } } @@ -402,9 +392,8 @@ init_conn(MQ_INSTANCE *my_instance) amqp_empty_table); reply = amqp_get_rpc_reply(my_instance->conn); if(reply.reply_type != AMQP_RESPONSE_NORMAL){ - skygw_log_write(LOGFILE_ERROR, - "Error : Queue declaration failed."); - goto cleanup; + MXS_ERROR("Queue declaration failed."); + goto cleanup; } @@ -415,9 +404,8 @@ init_conn(MQ_INSTANCE *my_instance) amqp_empty_table); reply = amqp_get_rpc_reply(my_instance->conn); if(reply.reply_type != AMQP_RESPONSE_NORMAL){ - skygw_log_write(LOGFILE_ERROR, - "Error : Failed to bind queue to exchange."); - goto cleanup; + MXS_ERROR("Failed to bind queue to exchange."); + goto cleanup; } } rval = 1; @@ -451,10 +439,9 @@ char** parse_optstr(char* str, char* tok, int* szstore) arr = malloc(sizeof(char*)*size); if(arr == NULL){ - skygw_log_write(LOGFILE_ERROR, - "Error : Cannot allocate enough memory."); - *szstore = 0; - return NULL; + MXS_ERROR("Cannot allocate enough memory."); + *szstore = 0; + return NULL; } *szstore = size; @@ -552,7 +539,7 @@ createInstance(char **options, FILTER_PARAMETER **params) }else if(!strcmp(arr[x],"all")){ my_instance->trgtype = TRG_ALL; }else{ - skygw_log_write(LOGFILE_ERROR,"Error: Unknown option for 'logging_trigger':%s.",arr[x]); + MXS_ERROR("Unknown option for 'logging_trigger':%s.",arr[x]); } } @@ -719,8 +706,7 @@ int declareQueue(MQ_INSTANCE *my_instance, MQ_SESSION* my_session, char* qname) reply = amqp_get_rpc_reply(my_instance->conn); if(reply.reply_type != AMQP_RESPONSE_NORMAL){ success = 0; - skygw_log_write(LOGFILE_ERROR, - "Error : Queue declaration failed."); + MXS_ERROR("Queue declaration failed."); } @@ -733,8 +719,7 @@ int declareQueue(MQ_INSTANCE *my_instance, MQ_SESSION* my_session, char* qname) reply = amqp_get_rpc_reply(my_instance->conn); if(reply.reply_type != AMQP_RESPONSE_NORMAL){ success = 0; - skygw_log_write(LOGFILE_ERROR, - "Error : Failed to bind queue to exchange."); + MXS_ERROR("Failed to bind queue to exchange."); } spinlock_release(&my_instance->rconn_lock); @@ -766,8 +751,7 @@ void sendMessage(void* data) }else{ instance->rconn_intv += 5.0; - skygw_log_write(LOGFILE_ERROR, - "Error : Failed to reconnect to the MQRabbit server "); + MXS_ERROR("Failed to reconnect to the MQRabbit server "); } } err_num = instance->conn_stat; @@ -853,11 +837,10 @@ void pushMessage(MQ_INSTANCE *instance, amqp_basic_properties_t* prop, char* msg newmsg->prop = prop; }else{ - skygw_log_write(LOGFILE_ERROR, - "Error : Cannot allocate enough memory."); - free(prop); - free(msg); - return; + MXS_ERROR("Cannot allocate enough memory."); + free(prop); + free(msg); + return; } spinlock_acquire(&instance->msg_lock); @@ -1033,8 +1016,8 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue) } if(!success){ - skygw_log_write(LOGFILE_ERROR,"Error: Parsing query failed."); - goto send_downstream; + MXS_ERROR("Parsing query failed."); + goto send_downstream; } if(!my_instance->log_all){ @@ -1044,7 +1027,7 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue) } if(my_instance->trgtype == TRG_ALL){ - skygw_log_write_flush(LOGFILE_TRACE,"Trigger is TRG_ALL"); + MXS_INFO("Trigger is TRG_ALL"); schema_ok = true; src_ok = true; obj_ok = true; @@ -1064,8 +1047,8 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue) if(strcmp(my_instance->src_trg->user[i],sessusr) == 0) { - skygw_log_write_flush(LOGFILE_TRACE,"Trigger is TRG_SOURCE: user: %s = %s",my_instance->src_trg->user[i],sessusr); - src_ok = true; + MXS_INFO("Trigger is TRG_SOURCE: user: %s = %s",my_instance->src_trg->user[i],sessusr); + src_ok = true; break; } @@ -1082,7 +1065,7 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue) if(strcmp(my_instance->src_trg->host[i],sesshost) == 0) { - skygw_log_write_flush(LOGFILE_TRACE,"Trigger is TRG_SOURCE: host: %s = %s",my_instance->src_trg->host[i],sesshost); + MXS_INFO("Trigger is TRG_SOURCE: host: %s = %s",my_instance->src_trg->host[i],sesshost); src_ok = true; break; } @@ -1119,7 +1102,7 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue) if(strcmp(tmp,my_instance->shm_trg->objects[i]) == 0){ - skygw_log_write_flush(LOGFILE_TRACE,"Trigger is TRG_SCHEMA: %s = %s",tmp,my_instance->shm_trg->objects[i]); + MXS_INFO("Trigger is TRG_SCHEMA: %s = %s",tmp,my_instance->shm_trg->objects[i]); schema_ok = true; break; @@ -1138,7 +1121,7 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue) if(strcmp(my_session->db,my_instance->shm_trg->objects[i]) == 0){ - skygw_log_write_flush(LOGFILE_TRACE,"Trigger is TRG_SCHEMA: %s = %s",my_session->db,my_instance->shm_trg->objects[i]); + MXS_INFO("Trigger is TRG_SCHEMA: %s = %s",my_session->db,my_instance->shm_trg->objects[i]); schema_ok = true; break; @@ -1178,7 +1161,7 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue) if(!strcmp(tbnm,my_instance->obj_trg->objects[i])){ obj_ok = true; - skygw_log_write_flush(LOGFILE_TRACE,"Trigger is TRG_OBJECT: %s = %s",my_instance->obj_trg->objects[i],sesstbls[j]); + MXS_INFO("Trigger is TRG_OBJECT: %s = %s",my_instance->obj_trg->objects[i],sesstbls[j]); break; } @@ -1212,19 +1195,19 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue) * Something matched the trigger, log the query */ - skygw_log_write_flush(LOGFILE_TRACE,"Routing message to: %s:%d %s as %s/%s, exchange: %s<%s> key:%s queue:%s", - my_instance->hostname,my_instance->port, - my_instance->vhost,my_instance->username, - my_instance->password,my_instance->exchange, - my_instance->exchange_type,my_instance->key, - my_instance->queue); + MXS_INFO("Routing message to: %s:%d %s as %s/%s, exchange: %s<%s> key:%s queue:%s", + my_instance->hostname,my_instance->port, + my_instance->vhost,my_instance->username, + my_instance->password,my_instance->exchange, + my_instance->exchange_type,my_instance->key, + my_instance->queue); if(my_session->uid == NULL){ my_session->uid = calloc(33,sizeof(char)); if(!my_session->uid){ - skygw_log_write(LOGFILE_ERROR,"Error : Out of memory."); + MXS_ERROR("Out of memory."); }else{ genkey(my_session->uid,32); } @@ -1257,8 +1240,7 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue) /**Try to convert to a canonical form and use the plain query if unsuccessful*/ if((canon_q = skygw_get_canonical(queue)) == NULL){ - skygw_log_write_flush(LOGFILE_ERROR, - "Error: Cannot form canonical query."); + MXS_ERROR("Cannot form canonical query."); } } @@ -1268,8 +1250,7 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue) int qlen = strnlen(canon_q,length) + strnlen(t_buf,128); if((combined = malloc((qlen+1)*sizeof(char))) == NULL){ - skygw_log_write_flush(LOGFILE_ERROR, - "Error: Out of memory"); + MXS_ERROR("Out of memory"); } strcpy(combined,t_buf); strncat(combined,canon_q,length); @@ -1409,8 +1390,7 @@ static int clientReply(FILTER* instance, void *session, GWBUF *reply) prop->message_id = amqp_cstring_bytes("reply"); } if(!(combined = calloc(GWBUF_LENGTH(reply) + 256,sizeof(char)))){ - skygw_log_write_flush(LOGFILE_ERROR, - "Error : Out of memory"); + MXS_ERROR("Out of memory"); } memset(t_buf,0,128); diff --git a/server/modules/filter/namedserverfilter.c b/server/modules/filter/namedserverfilter.c index f478e05d2..c634d8198 100644 --- a/server/modules/filter/namedserverfilter.c +++ b/server/modules/filter/namedserverfilter.c @@ -161,10 +161,8 @@ int i, cflags = REG_ICASE; my_instance->user = strdup(params[i]->value); else if (!filter_standard_parameter(params[i]->name)) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "namedserverfilter: Unexpected parameter '%s'.\n", - params[i]->name))); + MXS_ERROR("namedserverfilter: Unexpected parameter '%s'.", + params[i]->name); } } @@ -182,10 +180,8 @@ int i, cflags = REG_ICASE; } else { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "namedserverfilter: unsupported option '%s'.\n", - options[i]))); + MXS_ERROR("namedserverfilter: unsupported option '%s'.", + options[i]); } } } @@ -193,25 +189,22 @@ int i, cflags = REG_ICASE; if (my_instance->match == NULL || my_instance->server == NULL) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "namedserverfilter: Missing required configured" - " option. You must specify a match and server " - "option as a minimum."))); - free(my_instance); - return NULL; + MXS_ERROR("namedserverfilter: Missing required configured" + " option. You must specify a match and server " + "option as a minimum."); + free(my_instance); + return NULL; } if (regcomp(&my_instance->re, my_instance->match, my_instance->cflags)) { - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, - "namedserverfilter: Invalid regular expression '%s'.\n", - my_instance->match))); - free(my_instance->match); - free(my_instance->server); - free(my_instance); - return NULL; + MXS_ERROR("namedserverfilter: Invalid regular expression '%s'.\n", + my_instance->match); + free(my_instance->match); + free(my_instance->server); + free(my_instance); + return NULL; } } return (FILTER *)my_instance; diff --git a/server/modules/filter/qlafilter.c b/server/modules/filter/qlafilter.c index 94ccdefca..1b72326ea 100644 --- a/server/modules/filter/qlafilter.c +++ b/server/modules/filter/qlafilter.c @@ -205,10 +205,8 @@ int i; } else if (!filter_standard_parameter(params[i]->name)) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "qlafilter: Unexpected parameter '%s'.\n", - params[i]->name))); + MXS_ERROR("qlafilter: Unexpected parameter '%s'.", + params[i]->name); } } } @@ -216,26 +214,24 @@ int i; if (my_instance->match && regcomp(&my_instance->re, my_instance->match, REG_ICASE)) { - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, - "qlafilter: Invalid regular expression '%s'" - " for the match parameter.\n", - my_instance->match))); - free(my_instance->match); - free(my_instance->source); - if(my_instance->filebase){ - free(my_instance->filebase); - } - free(my_instance); - return NULL; + MXS_ERROR("qlafilter: Invalid regular expression '%s'" + " for the match parameter.\n", + my_instance->match); + free(my_instance->match); + free(my_instance->source); + if(my_instance->filebase){ + free(my_instance->filebase); + } + free(my_instance); + return NULL; } if (my_instance->nomatch && regcomp(&my_instance->nore, my_instance->nomatch, REG_ICASE)) { - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, - "qlafilter: Invalid regular expression '%s'" - " for the nomatch paramter.\n", - my_instance->match))); + MXS_ERROR("qlafilter: Invalid regular expression '%s'" + " for the nomatch paramter.", + my_instance->match); if (my_instance->match) regfree(&my_instance->re); free(my_instance->match); @@ -273,14 +269,12 @@ char *remote, *userName; == NULL) { char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write( - LOGFILE_ERROR, - "Error : Memory allocation for qla filter " - "file name failed due to %d, %s.", - errno, - strerror_r(errno, errbuf, sizeof(errbuf))))); - free(my_session); - return NULL; + MXS_ERROR("Memory allocation for qla filter " + "file name failed due to %d, %s.", + errno, + strerror_r(errno, errbuf, sizeof(errbuf))); + free(my_session); + return NULL; } my_session->active = 1; @@ -312,27 +306,23 @@ char *remote, *userName; if (my_session->fp == NULL) { char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write( - LOGFILE_ERROR, - "Error : Opening output file for qla " - "fileter failed due to %d, %s", - errno, - strerror_r(errno, errbuf, sizeof(errbuf))))); - free(my_session->filename); - free(my_session); - my_session = NULL; + MXS_ERROR("Opening output file for qla " + "fileter failed due to %d, %s", + errno, + strerror_r(errno, errbuf, sizeof(errbuf))); + free(my_session->filename); + free(my_session); + my_session = NULL; } } } else { char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write( - LOGFILE_ERROR, - "Error : Memory allocation for qla filter failed due to " - "%d, %s.", - errno, - strerror_r(errno, errbuf, sizeof(errbuf))))); + MXS_ERROR("Memory allocation for qla filter failed due to " + "%d, %s.", + errno, + strerror_r(errno, errbuf, sizeof(errbuf))); } return my_session; } diff --git a/server/modules/filter/regexfilter.c b/server/modules/filter/regexfilter.c index 519b24820..ab35c0af2 100644 --- a/server/modules/filter/regexfilter.c +++ b/server/modules/filter/regexfilter.c @@ -208,10 +208,8 @@ createInstance(char **options, FILTER_PARAMETER **params) } else if (!filter_standard_parameter(params[i]->name)) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "regexfilter: Unexpected parameter '%s'.\n", - params[i]->name))); + MXS_ERROR("regexfilter: Unexpected parameter '%s'.", + params[i]->name); } } @@ -229,10 +227,8 @@ createInstance(char **options, FILTER_PARAMETER **params) } else { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "regexfilter: unsupported option '%s'.\n", - options[i]))); + MXS_ERROR("regexfilter: unsupported option '%s'.", + options[i]); } } } @@ -241,9 +237,7 @@ createInstance(char **options, FILTER_PARAMETER **params) { if ((my_instance->logfile = fopen(logfile, "a")) == NULL) { - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, - "regexfilter: Failed to open file '%s'.\n", - logfile))); + MXS_ERROR("regexfilter: Failed to open file '%s'.", logfile); free_instance(my_instance); free(logfile); return NULL; @@ -269,9 +263,8 @@ createInstance(char **options, FILTER_PARAMETER **params) { char errbuffer[1024]; pcre2_get_error_message(errnumber, (PCRE2_UCHAR*) & errbuffer, sizeof(errbuffer)); - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, - "Error: regexfilter: Compiling regular expression '%s' failed at %lu: %s\n", - my_instance->match, erroffset, errbuffer))); + MXS_ERROR("regexfilter: Compiling regular expression '%s' failed at %lu: %s", + my_instance->match, erroffset, errbuffer); free_instance(my_instance); return NULL; } @@ -279,9 +272,8 @@ createInstance(char **options, FILTER_PARAMETER **params) if((my_instance->match_data = pcre2_match_data_create_from_pattern( my_instance->re, NULL)) == NULL) { - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, - "Error: regexfilter: Failure to create PCRE2 matching data. " - "This is most likely caused by a lack of available memory."))); + MXS_ERROR("regexfilter: Failure to create PCRE2 matching data. " + "This is most likely caused by a lack of available memory."); free_instance(my_instance); return NULL; } @@ -511,7 +503,7 @@ void log_match(REGEX_INSTANCE* inst, char* re, char* old, char* new) } if(inst->log_trace) { - LOGIF(LT,(skygw_log_write(LT,"Match %s: [%s] -> [%s]",re,old,new))); + MXS_INFO("Match %s: [%s] -> [%s]",re,old,new); } } @@ -530,6 +522,6 @@ void log_nomatch(REGEX_INSTANCE* inst, char* re, char* old) } if(inst->log_trace) { - LOGIF(LT,(skygw_log_write(LT,"No match %s: [%s]",re,old))); + MXS_INFO("No match %s: [%s]",re,old); } } diff --git a/server/modules/filter/slavelag.c b/server/modules/filter/slavelag.c index 1e9bbaaa2..df8b6331b 100644 --- a/server/modules/filter/slavelag.c +++ b/server/modules/filter/slavelag.c @@ -179,10 +179,8 @@ int i,cflags = 0; my_instance->nomatch = strdup(params[i]->value); else { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "lagfilter: Unexpected parameter '%s'.\n", - params[i]->name))); + MXS_ERROR("lagfilter: Unexpected parameter '%s'.\n", + params[i]->name); } } @@ -200,10 +198,8 @@ int i,cflags = 0; } else { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "lagfilter: unsupported option '%s'.", - options[i]))); + MXS_ERROR("lagfilter: unsupported option '%s'.", + options[i]))); } } } @@ -212,20 +208,16 @@ int i,cflags = 0; { if(regcomp(&my_instance->re,my_instance->match,cflags)) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "lagfilter: Failed to compile regex '%s'.", - my_instance->match))); + MXS_ERROR("lagfilter: Failed to compile regex '%s'.", + my_instance->match); } } if(my_instance->nomatch) { if(regcomp(&my_instance->nore,my_instance->nomatch,cflags)) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "lagfilter: Failed to compile regex '%s'.", - my_instance->nomatch))); + MXS_ERROR("lagfilter: Failed to compile regex '%s'.", + my_instance->nomatch))); } } } diff --git a/server/modules/filter/tee.c b/server/modules/filter/tee.c index 2f68b22bd..880bc5c24 100644 --- a/server/modules/filter/tee.c +++ b/server/modules/filter/tee.c @@ -274,9 +274,9 @@ orphan_free(void* data) #ifdef SS_DEBUG if(o_stopping + o_ready > 0) - skygw_log_write(LOGFILE_DEBUG, "tee.c: %d orphans in " - "SESSION_STATE_STOPPING, %d orphans in " - "SESSION_STATE_ROUTER_READY. ", o_stopping, o_ready); + MXS_DEBUG("tee.c: %d orphans in " + "SESSION_STATE_STOPPING, %d orphans in " + "SESSION_STATE_ROUTER_READY. ", o_stopping, o_ready); #endif while(finished) @@ -297,7 +297,7 @@ orphan_free(void* data) } #ifdef SS_DEBUG - skygw_log_write(LOGFILE_DEBUG, "tee.c: %d orphans freed.", o_freed); + MXS_DEBUG("tee.c: %d orphans freed.", o_freed); #endif } @@ -358,9 +358,8 @@ int i; { if (options) { - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, - "tee: The tee filter has been passed an option, " - "this filter does not support any options.\n"))); + MXS_ERROR("tee: The tee filter has been passed an option, " + "this filter does not support any options."); } my_instance->service = NULL; my_instance->source = NULL; @@ -375,11 +374,8 @@ int i; { if ((my_instance->service = service_find(params[i]->value)) == NULL) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "tee: service '%s' " - "not found.\n", - params[i]->value))); + MXS_ERROR("tee: service '%s' not found.\n", + params[i]->value); } } else if (!strcmp(params[i]->name, "match")) @@ -396,10 +392,8 @@ int i; my_instance->userName = strdup(params[i]->value); else if (!filter_standard_parameter(params[i]->name)) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "tee: Unexpected parameter '%s'.\n", - params[i]->name))); + MXS_ERROR("tee: Unexpected parameter '%s'.", + params[i]->name); } } } @@ -414,29 +408,27 @@ int i; if (my_instance->match && regcomp(&my_instance->re, my_instance->match, REG_ICASE)) { - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, - "tee: Invalid regular expression '%s'" - " for the match parameter.\n", - my_instance->match))); - free(my_instance->match); - free(my_instance->source); - free(my_instance); - return NULL; + MXS_ERROR("tee: Invalid regular expression '%s'" + " for the match parameter.", + my_instance->match); + free(my_instance->match); + free(my_instance->source); + free(my_instance); + return NULL; } if (my_instance->nomatch && regcomp(&my_instance->nore, my_instance->nomatch, REG_ICASE)) { - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, - "tee: Invalid regular expression '%s'" - " for the nomatch paramter.\n", - my_instance->match))); - if (my_instance->match) - regfree(&my_instance->re); - free(my_instance->match); - free(my_instance->source); - free(my_instance); - return NULL; + MXS_ERROR("tee: Invalid regular expression '%s'" + " for the nomatch paramter.\n", + my_instance->match); + if (my_instance->match) + regfree(&my_instance->re); + free(my_instance->match); + free(my_instance->source); + free(my_instance); + return NULL; } } return (FILTER *)my_instance; @@ -460,11 +452,10 @@ char *remote, *userName; if (strcmp(my_instance->service->name, session->service->name) == 0) { - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, - "Error : %s: Recursive use of tee filter in service.", - session->service->name))); - my_session = NULL; - goto retblock; + MXS_ERROR("%s: Recursive use of tee filter in service.", + session->service->name); + my_session = NULL; + goto retblock; } HASHTABLE* ht = hashtable_alloc(100,simple_str_hash,strcmp); @@ -473,11 +464,10 @@ char *remote, *userName; if(is_loop) { - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, - "Error : %s: Recursive use of tee filter in service.", - session->service->name))); - my_session = NULL; - goto retblock; + MXS_ERROR("%s: Recursive use of tee filter in service.", + session->service->name); + my_session = NULL; + goto retblock; } if ((my_session = calloc(1, sizeof(TEE_SESSION))) != NULL) @@ -497,9 +487,7 @@ char *remote, *userName; { my_session->active = 0; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Warning : Tee filter is not active."))); + MXS_WARNING("Tee filter is not active."); } } userName = session_getUser(session); @@ -510,9 +498,7 @@ char *remote, *userName; { my_session->active = 0; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Warning : Tee filter is not active."))); + MXS_WARNING("Tee filter is not active."); } if (my_session->active) @@ -527,10 +513,8 @@ char *remote, *userName; freeSession(instance, (void *)my_session); my_session = NULL; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Creating client DCB for Tee " - "filter failed. Terminating session."))); + MXS_ERROR("Creating client DCB for Tee " + "filter failed. Terminating session."); goto retblock; } @@ -540,11 +524,9 @@ char *remote, *userName; dcb_close(dcb); freeSession(instance, (void *)my_session); my_session = NULL; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : tee: Allocating memory for " - "dummy filter definition failed." - " Terminating session."))); + MXS_ERROR("tee: Allocating memory for " + "dummy filter definition failed." + " Terminating session."); goto retblock; } @@ -557,10 +539,8 @@ char *remote, *userName; dcb_close(dcb); freeSession(instance, (void *)my_session); my_session = NULL; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Creating client session for Tee " - "filter failed. Terminating session."))); + MXS_ERROR("Creating client session for Tee " + "filter failed. Terminating session."); goto retblock; } @@ -580,11 +560,9 @@ char *remote, *userName; closeSession(instance,(void*)my_session); dcb_close(dcb); free(my_session); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : tee: Allocating memory for" - "dummy upstream failed." - " Terminating session."))); + MXS_ERROR("tee: Allocating memory for" + "dummy upstream failed." + " Terminating session."); return NULL; } @@ -616,7 +594,7 @@ ROUTER_OBJECT *router; void *router_instance, *rsession; SESSION *bsession; #ifdef SS_DEBUG -skygw_log_write(LOGFILE_TRACE,"Tee close: %d", atomic_add(&debug_seq,1)); +MXS_INFO("Tee close: %d", atomic_add(&debug_seq,1)); #endif if (my_session->active) { @@ -649,7 +627,7 @@ skygw_log_write(LOGFILE_TRACE,"Tee close: %d", atomic_add(&debug_seq,1)); my_session->client_dcb && my_session->client_dcb->state == DCB_STATE_POLLING) { - skygw_log_write(LOGFILE_TRACE,"Tee session closed mid-query."); + MXS_INFO("Tee session closed mid-query."); GWBUF* errbuf = modutil_create_mysql_err_msg(1,0,1,"00000","Session closed."); my_session->client_dcb->func.write(my_session->client_dcb,errbuf); } @@ -673,7 +651,7 @@ TEE_SESSION *my_session = (TEE_SESSION *)session; SESSION* ses = my_session->branch_session; session_state_t state; #ifdef SS_DEBUG -skygw_log_write(LOGFILE_TRACE,"Tee free: %d", atomic_add(&debug_seq,1)); +MXS_INFO("Tee free: %d", atomic_add(&debug_seq,1)); #endif if (ses != NULL) { @@ -772,9 +750,10 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue) *((unsigned char*)queue->start + 4) : 1; #ifdef SS_DEBUG - skygw_log_write(LOGFILE_TRACE,"Tee routeQuery: %d : %s", - atomic_add(&debug_seq,1), - ((char*)queue->start + 5)); + int prev_debug_seq = atomic_add(&debug_seq,1); + MXS_INFO("Tee routeQuery: %d : %s", + prev_debug_seq, + ((char*)queue->start + 5)); #endif @@ -782,7 +761,7 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue) if(!my_session->active) { - skygw_log_write(LOGFILE_TRACE, "Tee: Received a reply when the session was closed."); + MXS_INFO("Tee: Received a reply when the session was closed."); gwbuf_free(queue); spinlock_release(&my_session->tee_lock); return 0; @@ -909,19 +888,20 @@ clientReply (FILTER* instance, void *session, GWBUF *reply) int min_eof = my_session->command != 0x04 ? 2 : 1; int more_results = 0; #ifdef SS_DEBUG + int prev_debug_seq = atomic_add(&debug_seq,1); ptr = (unsigned char*) reply->start; - skygw_log_write(LOGFILE_TRACE,"Tee clientReply [%s] [%s] [%s]: %d", - instance ? "parent":"child", - my_session->active ? "open" : "closed", - PTR_IS_ERR(ptr) ? "ERR" : PTR_IS_OK(ptr) ? "OK" : "RSET", - atomic_add(&debug_seq,1)); + MXS_INFO("Tee clientReply [%s] [%s] [%s]: %d", + instance ? "parent":"child", + my_session->active ? "open" : "closed", + PTR_IS_ERR(ptr) ? "ERR" : PTR_IS_OK(ptr) ? "OK" : "RSET", + prev_debug_seq); #endif spinlock_acquire(&my_session->tee_lock); if(!my_session->active) { - skygw_log_write(LOGFILE_TRACE,"Tee: Failed to return reply, session is closed"); + MXS_INFO("Tee: Failed to return reply, session is closed"); gwbuf_free(reply); rc = 0; if(my_session->waiting[PARENT]) @@ -944,8 +924,8 @@ clientReply (FILTER* instance, void *session, GWBUF *reply) if(complete == NULL) { /** Incomplete packet */ - skygw_log_write(LOGFILE_DEBUG,"tee.c: Incomplete packet, " - "waiting for a complete packet before forwarding."); + MXS_DEBUG("tee.c: Incomplete packet, " + "waiting for a complete packet before forwarding."); rc = 1; goto retblock; } @@ -963,7 +943,7 @@ clientReply (FILTER* instance, void *session, GWBUF *reply) if(my_session->replies[branch] == 0) { - skygw_log_write(LOGFILE_TRACE,"Tee: First reply to a query for [%s].",branch == PARENT ? "PARENT":"CHILD"); + MXS_INFO("Tee: First reply to a query for [%s].",branch == PARENT ? "PARENT":"CHILD"); /* Reply is in a single packet if it is an OK, ERR or LOCAL_INFILE packet. * Otherwise the reply is a result set and the amount of packets is unknown. */ @@ -978,17 +958,16 @@ clientReply (FILTER* instance, void *session, GWBUF *reply) more_results = (flags & 0x08) && my_session->client_multistatement; if(more_results) { - skygw_log_write(LOGFILE_TRACE, - "Tee: [%s] waiting for more results.",branch == PARENT ? "PARENT":"CHILD"); + MXS_INFO("Tee: [%s] waiting for more results.",branch == PARENT ? "PARENT":"CHILD"); } } } #ifdef SS_DEBUG else { - skygw_log_write_flush(LOGFILE_DEBUG,"tee.c: [%ld] Waiting for a result set from %s session.", - my_session->d_id, - branch == PARENT?"parent":"child"); + MXS_DEBUG("tee.c: [%ld] Waiting for a result set from %s session.", + my_session->d_id, + branch == PARENT?"parent":"child"); } #endif } @@ -1002,9 +981,9 @@ clientReply (FILTER* instance, void *session, GWBUF *reply) if(my_session->eof[branch] >= min_eof) { #ifdef SS_DEBUG - skygw_log_write_flush(LOGFILE_DEBUG,"tee.c [%ld] %s received last EOF packet", - my_session->d_id, - branch == PARENT?"parent":"child"); + MXS_DEBUG("tee.c [%ld] %s received last EOF packet", + my_session->d_id, + branch == PARENT?"parent":"child"); #endif my_session->waiting[branch] = more_results; if(more_results) @@ -1035,7 +1014,7 @@ clientReply (FILTER* instance, void *session, GWBUF *reply) rc = 0; gwbuf_free(my_session->tee_replybuf); my_session->tee_replybuf = NULL; - skygw_log_write_flush(LOGFILE_ERROR,"Error : Tee child session was closed."); + MXS_ERROR("Tee child session was closed."); } if(mpkt) @@ -1051,7 +1030,7 @@ clientReply (FILTER* instance, void *session, GWBUF *reply) { route = true; #ifdef SS_DEBUG - skygw_log_write_flush(LOGFILE_DEBUG,"tee.c:[%ld] Routing final packet of response set.",my_session->d_id); + MXS_DEBUG("tee.c:[%ld] Routing final packet of response set.",my_session->d_id); #endif } } @@ -1059,7 +1038,7 @@ clientReply (FILTER* instance, void *session, GWBUF *reply) !my_session->waiting[CHILD]) { #ifdef SS_DEBUG - skygw_log_write_flush(LOGFILE_DEBUG,"tee.c:[%ld] Routing single packet response.",my_session->d_id); + MXS_DEBUG("tee.c:[%ld] Routing single packet response.",my_session->d_id); #endif route = true; } @@ -1068,8 +1047,8 @@ clientReply (FILTER* instance, void *session, GWBUF *reply) if(route) { #ifdef SS_DEBUG - skygw_log_write_flush(LOGFILE_DEBUG, "tee.c:[%ld] Routing buffer '%p' parent(waiting [%s] replies [%d] eof[%d])" - " child(waiting [%s] replies[%d] eof [%d])", + MXS_DEBUG("tee.c:[%ld] Routing buffer '%p' parent(waiting [%s] replies [%d] eof[%d])" + " child(waiting [%s] replies[%d] eof [%d])", my_session->d_id, my_session->tee_replybuf, my_session->waiting[PARENT] ? "true":"false", @@ -1094,7 +1073,7 @@ clientReply (FILTER* instance, void *session, GWBUF *reply) GWBUF* clone = clone_query(my_session->instance,my_session,buffer); reset_session_state(my_session,buffer); route_single_query(my_session->instance,my_session,buffer,clone); - LOGIF(LT,(skygw_log_write(LT,"tee: routing queued query"))); + MXS_INFO("tee: routing queued query"); } @@ -1314,9 +1293,7 @@ int route_single_query(TEE_INSTANCE* my_instance, TEE_SESSION* my_session, GWBUF /** Close tee session */ my_session->active = 0; rval = 0; - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Closed tee filter session: Child session in invalid state."))); + MXS_INFO("Closed tee filter session: Child session in invalid state."); gwbuf_free(clone); } } @@ -1324,9 +1301,7 @@ int route_single_query(TEE_INSTANCE* my_instance, TEE_SESSION* my_session, GWBUF { if (my_session->active) { - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Closed tee filter session: Child session is NULL."))); + MXS_INFO("Closed tee filter session: Child session is NULL."); my_session->active = 0; rval = 0; } @@ -1352,8 +1327,8 @@ int reset_session_state(TEE_SESSION* my_session, GWBUF* buffer) { case 0x1b: my_session->client_multistatement = *((unsigned char*) buffer->start + 5); - LOGIF(LT,(skygw_log_write(LT,"Tee: client %s multistatements", - my_session->client_multistatement ? "enabled":"disabled"))); + MXS_INFO("tee: client %s multistatements", + my_session->client_multistatement ? "enabled":"disabled"); case 0x03: case 0x16: case 0x17: @@ -1380,9 +1355,9 @@ void create_orphan(SESSION* ses) orphan_session_t* orphan; if((orphan = malloc(sizeof(orphan_session_t))) == NULL) { - skygw_log_write(LOGFILE_ERROR,"Error : Failed to " - "allocate memory for orphan session struct, " - "child session might leak memory."); + MXS_ERROR("Failed to " + "allocate memory for orphan session struct, " + "child session might leak memory."); }else{ orphan->session = ses; spinlock_acquire(&orphanLock); diff --git a/server/modules/filter/test/harness_common.c b/server/modules/filter/test/harness_common.c index 0b8510263..12d0e40a8 100644 --- a/server/modules/filter/test/harness_common.c +++ b/server/modules/filter/test/harness_common.c @@ -23,7 +23,7 @@ int harness_init(int argc, char** argv, HARNESS_INSTANCE** inst){ if(!(instance.head = calloc(1,sizeof(FILTERCHAIN)))) { printf("Error: Out of memory\n"); - skygw_log_write(LOGFILE_ERROR,"Error: Out of memory\n"); + MXS_ERROR("Out of memory\n"); return 1; } @@ -57,7 +57,7 @@ int harness_init(int argc, char** argv, HARNESS_INSTANCE** inst){ if(!(instance.thrpool = malloc(instance.thrcount * sizeof(pthread_t)))){ printf("Error: Out of memory\n"); - skygw_log_write(LOGFILE_ERROR,"Error: Out of memory\n"); + MXS_ERROR("Out of memory\n"); return 1; } @@ -259,7 +259,7 @@ int routeQuery(void* ins, void* session, GWBUF* queue) }else{ printf("Error: cannot allocate enough memory.\n"); - skygw_log_write(LOGFILE_ERROR,"Error: cannot allocate enough memory.\n"); + MXS_ERROR("cannot allocate enough memory.\n"); return 0; } @@ -342,14 +342,14 @@ int load_query() buffer = (char*)calloc(4092,sizeof(char)); if(buffer == NULL){ printf("Error: cannot allocate enough memory.\n"); - skygw_log_write(LOGFILE_ERROR,"Error: cannot allocate enough memory.\n"); + MXS_ERROR("cannot allocate enough memory.\n"); return 1; } query_list = calloc(qbuff_sz,sizeof(char*)); if(query_list == NULL){ printf("Error: cannot allocate enough memory.\n"); - skygw_log_write(LOGFILE_ERROR,"Error: cannot allocate enough memory.\n"); + MXS_ERROR("cannot allocate enough memory.\n"); free(buffer); return 1; } @@ -361,7 +361,7 @@ int load_query() char** tmpbuff = realloc(query_list,sizeof(char*)*qbuff_sz*2); if(tmpbuff == NULL){ printf("Error: cannot allocate enough memory.\n"); - skygw_log_write(LOGFILE_ERROR,"Error: cannot allocate enough memory.\n"); + MXS_ERROR("cannot allocate enough memory.\n"); rval = 1; goto retblock; } @@ -388,7 +388,7 @@ int load_query() if(tmpbff[i] == NULL) { printf("Error: cannot allocate a new buffer.\n"); - skygw_log_write(LOGFILE_ERROR,"Error: cannot allocate a new buffer.\n"); + MXS_ERROR("cannot allocate a new buffer.\n"); int x; for(x = 0;xvalue); - skygw_log_write(LOGFILE_ERROR,"Error creating filter instance!\nModule: %s\n",item->value); + MXS_ERROR("Error creating filter instance!\nModule: %s\n",item->value); config_ok = 0; goto cleanup; @@ -737,8 +737,7 @@ int load_filter(FILTERCHAIN* fc, CONFIG* cnf) if(fc->instance->setUpstream && fc->instance->clientReply){ fc->instance->setUpstream(fc->filter, fc->session[i], fc->up[i]); }else{ - skygw_log_write(LOGFILE_MESSAGE, - "Warning: The filter %s does not support client replies.\n",fc->name); + MXS_WARNING("The filter %s does not support client replies.\n",fc->name); } if(fc->next && fc->next->next){ @@ -821,7 +820,7 @@ FILTERCHAIN* load_filter_module(char* str) if( (flt_ptr->instance = (FILTER_OBJECT*)load_module(str, MODULE_FILTER)) == NULL) { printf("Error: Module loading failed: %s\n",str); - skygw_log_write(LOGFILE_ERROR,"Error: Module loading failed: %s\n",str); + MXS_ERROR("Module loading failed: %s\n",str); free(flt_ptr->down); free(flt_ptr); return NULL; diff --git a/server/modules/filter/test/harness_ui.c b/server/modules/filter/test/harness_ui.c index b92182a37..4f84a8600 100644 --- a/server/modules/filter/test/harness_ui.c +++ b/server/modules/filter/test/harness_ui.c @@ -10,7 +10,7 @@ int main(int argc, char** argv){ if(harness_init(argc,argv,&hinstance)){ printf("Error: Initialization failed.\n"); - skygw_log_write(LOGFILE_ERROR,"Error: Initialization failed.\n"); + MXS_ERROR("Initialization failed.\n"); mxs_log_finish(); return 1; } @@ -48,7 +48,7 @@ int main(int argc, char** argv){ tmp_chn = load_filter_module(tk); if(!tmp_chn || !load_filter(tmp_chn,instance.conf)){ printf("Error creating filter instance.\n"); - skygw_log_write(LOGFILE_ERROR,"Error: Error creating filter instance.\n"); + MXS_ERROR("Error creating filter instance.\n"); }else{ instance.head = tmp_chn; } @@ -180,7 +180,7 @@ int main(int argc, char** argv){ if(!(t_thr_pool = realloc(instance.thrpool,instance.thrcount * sizeof(pthread_t)))){ printf("Error: Out of memory\n"); - skygw_log_write(LOGFILE_ERROR,"Error: Out of memory\n"); + MXS_ERROR("Out of memory\n"); instance.running = 0; break; } @@ -348,7 +348,7 @@ void manual_query() qlen = strnlen(query, 1024); if((tmpbuf = malloc(sizeof(GWBUF*)))== NULL){ printf("Error: cannot allocate enough memory.\n"); - skygw_log_write(LOGFILE_ERROR,"Error: cannot allocate enough memory.\n"); + MXS_ERROR("Cannot allocate enough memory.\n"); return; } instance.buffer = tmpbuf; diff --git a/server/modules/filter/test/harness_util.c b/server/modules/filter/test/harness_util.c index 16d10c8c4..c23e8c192 100644 --- a/server/modules/filter/test/harness_util.c +++ b/server/modules/filter/test/harness_util.c @@ -34,7 +34,7 @@ int main(int argc,char** argv) if(harness_init(argc,argv,&inst) || inst->error){ printf("Error: Initialization failed.\n"); - skygw_log_write(LOGFILE_ERROR,"Error: Initialization failed.\n"); + MXS_ERROR("Initialization failed.\n"); mxs_log_finish(); return 1; } diff --git a/server/modules/filter/topfilter.c b/server/modules/filter/topfilter.c index a8089b830..457375a83 100644 --- a/server/modules/filter/topfilter.c +++ b/server/modules/filter/topfilter.c @@ -217,48 +217,43 @@ TOPN_INSTANCE *my_instance; my_instance->user = strdup(params[i]->value); else if (!filter_standard_parameter(params[i]->name)) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "topfilter: Unexpected parameter '%s'.\n", - params[i]->name))); + MXS_ERROR("topfilter: Unexpected parameter '%s'.", + params[i]->name); } } if (options) { - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, - "topfilter: Options are not supported by this " - " filter. They will be ignored\n"))); + MXS_ERROR("topfilter: Options are not supported by this " + " filter. They will be ignored."); } my_instance->sessions = 0; if (my_instance->match && regcomp(&my_instance->re, my_instance->match, REG_ICASE)) { - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, - "topfilter: Invalid regular expression '%s'" - " for the match parameter.\n", - my_instance->match))); - free(my_instance->match); - free(my_instance->source); - free(my_instance->user); - free(my_instance->filebase); - free(my_instance); - return NULL; + MXS_ERROR("topfilter: Invalid regular expression '%s'" + " for the match parameter.", + my_instance->match); + free(my_instance->match); + free(my_instance->source); + free(my_instance->user); + free(my_instance->filebase); + free(my_instance); + return NULL; } if (my_instance->exclude && regcomp(&my_instance->exre, my_instance->exclude, REG_ICASE)) { - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, - "qlafilter: Invalid regular expression '%s'" - " for the nomatch paramter.\n", - my_instance->match))); - regfree(&my_instance->re); - free(my_instance->match); - free(my_instance->source); - free(my_instance->user); - free(my_instance->filebase); - free(my_instance); - return NULL; + MXS_ERROR("qlafilter: Invalid regular expression '%s'" + " for the nomatch paramter.\n", + my_instance->match); + regfree(&my_instance->re); + free(my_instance->match); + free(my_instance->source); + free(my_instance->user); + free(my_instance->filebase); + free(my_instance); + return NULL; } } return (FILTER *)my_instance;