Skip to content

Commit

Permalink
add debug levels
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnyz32 committed Aug 22, 2024
1 parent b0086b4 commit 68befda
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 54 deletions.
90 changes: 48 additions & 42 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,53 @@
// Testing tasks
"version": "2.0.0",
"tasks": [
{
"label": "deploy",
"type": "shell",
"command": "./deploy.sh",
"problemMatcher": []
},
{
"label": "deployAndBuildAll",
"type": "shell",
"command": "./deployAndBuildAll.sh",
"problemMatcher": []
},
{
"label": "deployAndBuildCamel",
"type": "shell",
"command": "./deployAndBuildCamel.sh",
"problemMatcher": []
},
{
"label": "deployAndTest",
"type": "shell",
"command": "./deployAndTest.sh",
"problemMatcher": []
},
{
"label": "deployBuildAllAndTest",
"type": "shell",
"command": "./deployBuildAllAndTest.sh",
"problemMatcher": []
},
{
"label": "deployBuildCamelAndTest",
"type": "shell",
"command": "./deployBuildCamelAndTest.sh",
"problemMatcher": []
},
{
"label": "ileUnitTest",
"type": "shell",
"command": "bazel test --cxxopt=-std=c++14 --verbose_failures --test_output=all //:test_util",
"problemMatcher": []
}
{
"label": "deploy",
"type": "shell",
"command": "./deploy.sh",
"problemMatcher": []
},
{
"label": "deployAndBuildAll",
"type": "shell",
"command": "./deployAndBuildAll.sh",
"problemMatcher": []
},
{
"label": "deployAndBuildIle",
"type": "shell",
"command": "./deployAndBuildIle.sh",
"problemMatcher": []
},
{
"label": "deployAndBuildCamel",
"type": "shell",
"command": "./deployAndBuildCamel.sh",
"problemMatcher": []
},
{
"label": "deployAndTest",
"type": "shell",
"command": "./deployAndTest.sh",
"problemMatcher": []
},
{
"label": "deployBuildAllAndTest",
"type": "shell",
"command": "./deployBuildAllAndTest.sh",
"problemMatcher": []
},
{
"label": "deployBuildCamelAndTest",
"type": "shell",
"command": "./deployBuildCamelAndTest.sh",
"problemMatcher": []
},
{
"label": "ileUnitTest",
"type": "shell",
"command": "bazel test --cxxopt=-std=c++14 --verbose_failures --test_output=all //:test_util",
"problemMatcher": []
}
]
}
6 changes: 6 additions & 0 deletions deployAndBuildIle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# Deploy Manzan to IBM i, and build the java and ile code

source ./.env
./deploy.sh
ssh $USER@$HOST "cd /home/$USER/mnzntest; gmake ile" | tee ile.out
1 change: 0 additions & 1 deletion ile/src/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ int main(int _argc, char **argv)
BUFSTRN(watch_option, argv[1], 10);
BUFSTRN(session_id, argv[2], 10);

DEBUG_INFO("HELLO..........");
DEBUG_INFO("watch program called. Watch option setting is '%s'\n", watch_option.c_str());
publisher_info_set *publishers = conf_get_publisher_info(session_id.c_str());
int num_publishers = publishers->num_publishers;
Expand Down
40 changes: 35 additions & 5 deletions ile/src/manzan.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,41 @@ extern "C"

#define DEBUG_ENABLED 1
#ifdef DEBUG_ENABLED
#define DEBUG(...) \
if (NULL != debug_fd) \
{ \
fprintf(debug_fd, __VA_ARGS__); \
fflush(debug_fd); \

#define DEBUG_INFO(...) \
if (getenv("MANZAN_DEBUG_LEVEL") != NULL && \
strcmp(getenv("MANZAN_DEBUG_LEVEL"), "3") == 0) \
{ \
if (NULL != debug_fd) \
{ \
fprintf(debug_fd, "[INFO] " __VA_ARGS__); \
fflush(debug_fd); \
} \
}

#define DEBUG_WARNING(...) \
if (getenv("MANZAN_DEBUG_LEVEL") != NULL && \
strcmp(getenv("MANZAN_DEBUG_LEVEL"), "2") == 0 || \
strcmp(getenv("MANZAN_DEBUG_LEVEL"), "3") == 0) \
{ \
if (NULL != debug_fd) \
{ \
fprintf(debug_fd, "[WARNING] " __VA_ARGS__); \
fflush(debug_fd); \
} \
}

#define DEBUG_ERROR(...) \
if (getenv("MANZAN_DEBUG_LEVEL") != NULL && \
strcmp(getenv("MANZAN_DEBUG_LEVEL"), "1") == 0 || \
strcmp(getenv("MANZAN_DEBUG_LEVEL"), "2") == 0 || \
strcmp(getenv("MANZAN_DEBUG_LEVEL"), "3") == 0) \
{ \
if (NULL != debug_fd) \
{ \
fprintf(debug_fd, "[ERROR] " __VA_ARGS__); \
fflush(debug_fd); \
} \
}
#else
#define STRDBG()
Expand Down
12 changes: 6 additions & 6 deletions ile/src/pub_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int to_utf8(char *out, size_t out_len, const char *in)
int rc = iconv(cd, &input, &inleft, &output, &outleft);
if (rc == -1)
{
DEBUG("Error in converting characters\n");
DEBUG_ERROR("Error in converting characters\n");
return 9;
}
return iconv_close(cd);
Expand Down Expand Up @@ -97,8 +97,8 @@ int json_publish(const char *_session_id, std::string &_json)
char *utf8 = (char *)malloc(56 + _json.length() * 2);

to_utf8(utf8, json_len, _json.c_str());
DEBUG("Publishing JSON\n");
DEBUG("%s\n", _json.c_str());
DEBUG_INFO("Publishing JSON\n");
DEBUG_INFO("%s\n", _json.c_str());

__attribute__((aligned(16))) char dtaq_key[11];
memset(dtaq_key, ' ', 11);
Expand All @@ -108,16 +108,16 @@ int json_publish(const char *_session_id, std::string &_json)
len2 += strlen(utf8);
_DecimalT<3,0> keyLen = __D("10.0");

DEBUG("About to call QSNDDTAQ\n");
DEBUG_INFO("About to call QSNDDTAQ\n");
QSNDDTAQ("MANZANDTAQ",
"MANZAN ", // TODO: How to properly resolve the library here?
len2,
utf8,
keyLen,
&dtaq_key);
DEBUG("About to free up stuff\n");
DEBUG_INFO("About to free up stuff\n");
free(utf8);
DEBUG("Done publishing JSON\n");
DEBUG_INFO("Done publishing JSON\n");
return 0;
}

Expand Down

0 comments on commit 68befda

Please sign in to comment.