Skip to content

Commit

Permalink
Fix some issues on logging
Browse files Browse the repository at this point in the history
  • Loading branch information
thamindumk committed Jan 1, 2025
1 parent 1a54450 commit 51ef85c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/frontend/JasmineGraphFrontEnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,7 @@ static void cypher_ast_command(int connFd, bool *loop_exit) {
if (semantic_analyzer.analyze(ast)) {
frontend_logger.log("AST is successfully analyzed", "log");
} else {
frontend_logger.log(user_res, "error");
frontend_logger.error("query isn't semantically correct");
frontend_logger.error("query isn't semantically correct: "+user_res_s);
}
}

Expand Down
15 changes: 5 additions & 10 deletions src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ limitations under the License.
#include "../util/Const.h"

using namespace std;

Logger semantic_logger;
// Constructor
SemanticAnalyzer::SemanticAnalyzer() {

Check warning on line 23 in src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp

View check run for this annotation

Codecov / codecov/patch

src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp#L23

Added line #L23 was not covered by tests
// Initialize the scope manager with the global scope
Expand Down Expand Up @@ -151,7 +151,7 @@ bool SemanticAnalyzer::analyze(ASTNode* root, bool canDefine, string type) {
pair<string, string> x = pair<string, string>(child->value, tempType);
temp->insert(x);
} else {

Check warning on line 153 in src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp

View check run for this annotation

Codecov / codecov/patch

src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp#L153

Added line #L153 was not covered by tests
reportError("use 'as' keyword to assign it to new variable" + node->value, node);
semantic_logger.error("use 'as' keyword to assign it to new variable: " + node->value);
return false;

Check warning on line 155 in src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp

View check run for this annotation

Codecov / codecov/patch

src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp#L155

Added line #L155 was not covered by tests
}
}
Expand All @@ -178,7 +178,7 @@ bool SemanticAnalyzer::checkVariableDeclarations(ASTNode* node, string type) {
} else if (scopeManager->lookup(node->value) == type) {
return true;

Check warning on line 179 in src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp

View check run for this annotation

Codecov / codecov/patch

src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp#L179

Added line #L179 was not covered by tests
} else {
reportError("Varmiable already declared: " + node->value, node);
semantic_logger.error("Variable already declared: " + node->value);
return false;

Check warning on line 182 in src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp

View check run for this annotation

Codecov / codecov/patch

src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp#L182

Added line #L182 was not covered by tests
}
return true;

Check warning on line 184 in src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp

View check run for this annotation

Codecov / codecov/patch

src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp#L184

Added line #L184 was not covered by tests
Expand All @@ -191,7 +191,7 @@ void SemanticAnalyzer::clearTemp() {

bool SemanticAnalyzer::checkVariableUsage(ASTNode* node, string type) {

Check warning on line 192 in src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp

View check run for this annotation

Codecov / codecov/patch

src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp#L192

Added line #L192 was not covered by tests
if (!(scopeManager->lookup(node->value))) {
reportError("Variable is not defined in this scope: " + node->value, node);
semantic_logger.error("Variable is not defined in this scope: " + node->value);
return false;

Check warning on line 195 in src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp

View check run for this annotation

Codecov / codecov/patch

src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp#L195

Added line #L195 was not covered by tests
} else if (scopeManager->lookup(node->value) && type == Const::ANY) {
return true;

Check warning on line 197 in src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp

View check run for this annotation

Codecov / codecov/patch

src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp#L197

Added line #L197 was not covered by tests
Expand All @@ -202,13 +202,8 @@ bool SemanticAnalyzer::checkVariableUsage(ASTNode* node, string type) {
scopeManager->lookup(node->value) == Const::MAP)) {
return true;

Check warning on line 203 in src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp

View check run for this annotation

Codecov / codecov/patch

src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp#L203

Added line #L203 was not covered by tests
} else {
reportError("Variable type mismatch: " + node->value, node);
semantic_logger.error("Variable type mismatch: " + node->value);
return false;

Check warning on line 206 in src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp

View check run for this annotation

Codecov / codecov/patch

src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp#L206

Added line #L206 was not covered by tests
}
}

// Report errors
void SemanticAnalyzer::reportError(const std::string &message, ASTNode* node) {
Logger logger;
logger.error(message);
}

0 comments on commit 51ef85c

Please sign in to comment.