From 30d56791741d0b1fad9bd558b47f35da956c8f4b Mon Sep 17 00:00:00 2001 From: Leanid Astrakou Date: Tue, 1 Aug 2023 09:28:23 -0400 Subject: [PATCH 01/11] Test commit for WTO/message logic Signed-off-by: Leanid Astrakou --- src/main.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/main.c b/src/main.c index 11c220f..aed6bf5 100644 --- a/src/main.c +++ b/src/main.c @@ -335,6 +335,41 @@ static bool is_valid_key(char *key) { return true; } +typedef struct WTOCommon31_tag{ + char replyBufferLength; /* 31-bit WTOR only, else 0 */ + char length; /* message length +4 */ + char mcsFlags1; + char mcsFlags2; +} WTOCommon31; + +void message(char *message){ + + ALLOC_STRUCT31( + STRUCT31_NAME(below2G), + STRUCT31_FIELDS( + WTOCommon31 common; + char text[126]; /* Maximum length of WTO text is 126 - ABEND D23-xxxx0005 if longer than 126 */ + ) + ); + + int len = strlen(message); + if (len>sizeof(below2G->text)) + len=sizeof(below2G->text); + + below2G->common.length = len+sizeof(below2G->common); /* +4 for header */ + memcpy(below2G->text,message,len); + + __asm(ASM_PREFIX + " WTO MF=(E,(%[wtobuf])) \n" + : + :[wtobuf]"NR:r1"(&below2G->common) + :"r0","r1","r15"); + + FREE_STRUCT31( + STRUCT31_NAME(below2G) + ); +} + static void set_shared_uss_env(ConfigManager *configmgr) { Json *env = NULL; int cfgGetStatus = cfgGetAnyC(configmgr, ZOWE_CONFIG_NAME, &env, 2, "zowe", "environments"); @@ -848,6 +883,8 @@ static int start_component(zl_comp_t *comp) { comp->clean_stop = false; INFO(MSG_COMP_STARTED, comp->name); + INFO("THIS IS A TEST AND SHOULD BE REMOVED!!!!!!!!!!!!!!!!!"); + message("SYSLOG POSSIBLY????????????????????"); if (pthread_create(&comp->comm_thid, NULL, handle_comp_comm, comp) != 0) { DEBUG("comm thread not started for %s - %s\n", comp->name, strerror(errno)); From 461ab2f7e5a87f0a1a11bd1f523150bdd42ecb13 Mon Sep 17 00:00:00 2001 From: Leanid Astrakou Date: Tue, 1 Aug 2023 10:19:44 -0400 Subject: [PATCH 02/11] Added better wtoPrintF code Signed-off-by: Leanid Astrakou --- src/main.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index aed6bf5..deb159b 100644 --- a/src/main.c +++ b/src/main.c @@ -370,6 +370,47 @@ void message(char *message){ ); } +#define WTO_MAX_SIZE 126 +void wtoPrintf(char *formatString, ...){ + char text[WTO_MAX_SIZE+1]; /* Allow for trailing null character */ + va_list argPointer; + int cnt; + + for (int pass=0; pass<2; pass++){ + + /* The resulting text string from vsnprintf is unpredictable if + there is an error in the format string or arguments. In that + case we will set the output text area to null, repeat the + vsnprintf, and then find the length of the null terminated + string. This avoids initializing the output text area prior + to every successful request. + */ + + va_start(argPointer,formatString); + cnt = vsnprintf(text,sizeof(text),formatString,argPointer); + va_end(argPointer); + + if (cnt<0){ + if (pass==0) + memset(text,0,sizeof(text)); /* Clear the text buffer before retrying the vsnprint request */ + else { + text[WTO_MAX_SIZE] = 0; /* Ensure strlen stops at the end of the text buffer */ + cnt = strlen(text); /* Find the end of the text string */ + } + } else + break; /* vsnprintf did not return an error - cnt was set */ + } + if (cnt>WTO_MAX_SIZE) /* If more data to format than the text buffer length */ + cnt = WTO_MAX_SIZE; /* Truncate the formatted length to the text buffer length */ + + /* We never want to include a final \n character in the WTO text */ + + if (cnt>0 && text[cnt-1] == '\n') /* If text ends with \n */ + text[cnt-1] = 0; /* Change it into a null character */ + + message(text); +} + static void set_shared_uss_env(ConfigManager *configmgr) { Json *env = NULL; int cfgGetStatus = cfgGetAnyC(configmgr, ZOWE_CONFIG_NAME, &env, 2, "zowe", "environments"); @@ -884,7 +925,7 @@ static int start_component(zl_comp_t *comp) { INFO(MSG_COMP_STARTED, comp->name); INFO("THIS IS A TEST AND SHOULD BE REMOVED!!!!!!!!!!!!!!!!!"); - message("SYSLOG POSSIBLY????????????????????"); + wtoPrintf("SYSLOG POSSIBLY????????????????????"); if (pthread_create(&comp->comm_thid, NULL, handle_comp_comm, comp) != 0) { DEBUG("comm thread not started for %s - %s\n", comp->name, strerror(errno)); From dd536c04f77799993844ad05e74ccee5ac3219ba Mon Sep 17 00:00:00 2001 From: Leanid Astrakou Date: Sun, 20 Aug 2023 23:10:44 -0400 Subject: [PATCH 03/11] Prototype for Zowe.yaml syslog check by id + print message to syslog Signed-off-by: Leanid Astrakou --- src/main.c | 157 +++++++++++++++++++++++++---------------------------- 1 file changed, 73 insertions(+), 84 deletions(-) diff --git a/src/main.c b/src/main.c index deb159b..669a2a9 100644 --- a/src/main.c +++ b/src/main.c @@ -38,6 +38,7 @@ #include "configmgr.h" #include "logging.h" #include "stcbase.h" +#include "zos.h" extern char ** environ; /* @@ -162,7 +163,7 @@ struct { char parm_member[8+1]; char *root_dir; char *workspace_dir; - + JsonArray *sys_messages; char ha_instance_id[64]; pid_t pid; @@ -170,13 +171,75 @@ struct { } zl_context = {.config = {.debug_mode = false}, .userid = "(NONE)"} ; +static void set_sys_messages(ConfigManager *configmgr) { + Json *env = NULL; + int cfgGetStatus = cfgGetAnyC(configmgr, ZOWE_CONFIG_NAME, &env, 2, "zowe", "sysMessages"); + JsonArray *sys_messages = NULL; + ArrayList *list = makeArrayList(); + + if (cfgGetStatus == ZCFG_SUCCESS) { + sys_messages = jsonAsArray(env); + } + + if (sys_messages) { + zl_context.sys_messages = sys_messages; + } +} +static void check_for_and_print_sys_message(const char* fmt, ...) { + + char input_string[1024]; // buffer to store the formatted message + + va_list args; + va_start(args, fmt); + vsnprintf(input_string, sizeof(input_string), fmt, args); + va_end(args); + + printf("IS THIS EVEN FORMATTED %s ????????", input_string); + + // Extract the ID from input_string + char msg_id[256]; // assuming the ID will not exceed 255 characters + const char* spacePos = strchr(input_string, ' '); + if (spacePos) { + int length = spacePos - input_string; + strncpy(msg_id, input_string, length); + msg_id[length] = '\0'; + } else { + // If no space found, use the whole input_string as the ID + //strncpy(msg_id, input_string, sizeof(msg_id) - 1); + //msg_id[sizeof(msg_id) - 1] = '\0'; // ensure null termination + + // If no space found, end + return; + } + + printf("AND WHAT IS ID?%s END", msg_id); + + if (!zl_context.sys_messages) { + return; // return if input_string or sys_messages is NULL + } + + + int count = jsonArrayGetCount(zl_context.sys_messages); + for (int i = 0; i < count; i++) { + const char *sys_message = jsonArrayGetString(zl_context.sys_messages, i); + if (sys_message && strstr(sys_message, msg_id) == 0) { + printf("%s\nAT LEAST ONE MATCH!", input_string); + wtoPrintfMetal(input_string); + break; // break out of loop once a match is found + } + } +} -#define INFO(fmt, ...) printf("%s <%s:%d> %s INFO "fmt, gettime().value, COMP_ID, zl_context.pid, zl_context.userid, ##__VA_ARGS__) -#define WARN(fmt, ...) printf("%s <%s:%d> %s WARN "fmt, gettime().value, COMP_ID, zl_context.pid, zl_context.userid, ##__VA_ARGS__) -#define DEBUG(fmt, ...) if (zl_context.config.debug_mode) \ +#define INFO(fmt, ...) check_for_and_print_sys_message(fmt, ##__VA_ARGS__); \ + printf("%s <%s:%d> %s INFO "fmt, gettime().value, COMP_ID, zl_context.pid, zl_context.userid, ##__VA_ARGS__) +#define WARN(fmt, ...) check_for_and_print_sys_message(fmt, ##__VA_ARGS__); \ + printf("%s <%s:%d> %s WARN "fmt, gettime().value, COMP_ID, zl_context.pid, zl_context.userid, ##__VA_ARGS__) +#define DEBUG(fmt, ...) check_for_and_print_sys_message(fmt, ##__VA_ARGS__); \ + if (zl_context.config.debug_mode) \ printf("%s <%s:%d> %s DEBUG "fmt, gettime().value, COMP_ID, zl_context.pid, zl_context.userid, ##__VA_ARGS__) -#define ERROR(fmt, ...) printf("%s <%s:%d> %s ERROR "fmt, gettime().value, COMP_ID, zl_context.pid, zl_context.userid, ##__VA_ARGS__) +#define ERROR(fmt, ...) check_for_and_print_sys_message(fmt, ##__VA_ARGS__); \ + printf("%s <%s:%d> %s ERROR "fmt, gettime().value, COMP_ID, zl_context.pid, zl_context.userid, ##__VA_ARGS__) static int mkdir_all(const char *path, mode_t mode) { // test if path exists @@ -335,82 +398,6 @@ static bool is_valid_key(char *key) { return true; } -typedef struct WTOCommon31_tag{ - char replyBufferLength; /* 31-bit WTOR only, else 0 */ - char length; /* message length +4 */ - char mcsFlags1; - char mcsFlags2; -} WTOCommon31; - -void message(char *message){ - - ALLOC_STRUCT31( - STRUCT31_NAME(below2G), - STRUCT31_FIELDS( - WTOCommon31 common; - char text[126]; /* Maximum length of WTO text is 126 - ABEND D23-xxxx0005 if longer than 126 */ - ) - ); - - int len = strlen(message); - if (len>sizeof(below2G->text)) - len=sizeof(below2G->text); - - below2G->common.length = len+sizeof(below2G->common); /* +4 for header */ - memcpy(below2G->text,message,len); - - __asm(ASM_PREFIX - " WTO MF=(E,(%[wtobuf])) \n" - : - :[wtobuf]"NR:r1"(&below2G->common) - :"r0","r1","r15"); - - FREE_STRUCT31( - STRUCT31_NAME(below2G) - ); -} - -#define WTO_MAX_SIZE 126 -void wtoPrintf(char *formatString, ...){ - char text[WTO_MAX_SIZE+1]; /* Allow for trailing null character */ - va_list argPointer; - int cnt; - - for (int pass=0; pass<2; pass++){ - - /* The resulting text string from vsnprintf is unpredictable if - there is an error in the format string or arguments. In that - case we will set the output text area to null, repeat the - vsnprintf, and then find the length of the null terminated - string. This avoids initializing the output text area prior - to every successful request. - */ - - va_start(argPointer,formatString); - cnt = vsnprintf(text,sizeof(text),formatString,argPointer); - va_end(argPointer); - - if (cnt<0){ - if (pass==0) - memset(text,0,sizeof(text)); /* Clear the text buffer before retrying the vsnprint request */ - else { - text[WTO_MAX_SIZE] = 0; /* Ensure strlen stops at the end of the text buffer */ - cnt = strlen(text); /* Find the end of the text string */ - } - } else - break; /* vsnprintf did not return an error - cnt was set */ - } - if (cnt>WTO_MAX_SIZE) /* If more data to format than the text buffer length */ - cnt = WTO_MAX_SIZE; /* Truncate the formatted length to the text buffer length */ - - /* We never want to include a final \n character in the WTO text */ - - if (cnt>0 && text[cnt-1] == '\n') /* If text ends with \n */ - text[cnt-1] = 0; /* Change it into a null character */ - - message(text); -} - static void set_shared_uss_env(ConfigManager *configmgr) { Json *env = NULL; int cfgGetStatus = cfgGetAnyC(configmgr, ZOWE_CONFIG_NAME, &env, 2, "zowe", "environments"); @@ -788,7 +775,7 @@ static void *handle_comp_comm(void *args) { char *next_line = strtok(msg, "\n"); while (next_line) { - printf("%s\n", next_line); + printf("SHEESH%s\n", next_line); next_line = strtok(NULL, "\n"); } @@ -924,8 +911,7 @@ static int start_component(zl_comp_t *comp) { comp->clean_stop = false; INFO(MSG_COMP_STARTED, comp->name); - INFO("THIS IS A TEST AND SHOULD BE REMOVED!!!!!!!!!!!!!!!!!"); - wtoPrintf("SYSLOG POSSIBLY????????????????????"); + wtoPrintfMetal("SYSLOG POSSIBLY????????????????????"); if (pthread_create(&comp->comm_thid, NULL, handle_comp_comm, comp) != 0) { DEBUG("comm thread not started for %s - %s\n", comp->name, strerror(errno)); @@ -1654,6 +1640,9 @@ int main(int argc, char **argv) { ERROR(MSG_CTX_INIT_FAILED); exit(EXIT_FAILURE); } + /* TODO(?): sys_messages could be set earlier than this w/ known sysMessages w/o having + config manager available to check zowe.yaml? */ + set_sys_messages(configmgr); cfgSetConfigPath(configmgr, ZOWE_CONFIG_NAME, zl_context.configmgr_path); int parm_member_len = strlen(zl_context.parm_member); From d94402687e91e591a0b0e51a3b14ef7fb73d3a01 Mon Sep 17 00:00:00 2001 From: Leanid Astrakou Date: Sun, 20 Aug 2023 23:14:25 -0400 Subject: [PATCH 04/11] Removing silly log, will need more removals Signed-off-by: Leanid Astrakou --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 669a2a9..1962a0b 100644 --- a/src/main.c +++ b/src/main.c @@ -775,7 +775,7 @@ static void *handle_comp_comm(void *args) { char *next_line = strtok(msg, "\n"); while (next_line) { - printf("SHEESH%s\n", next_line); + printf("%s\n", next_line); next_line = strtok(NULL, "\n"); } From 391f2571022708e62e2cfefe030cba977daaf5db Mon Sep 17 00:00:00 2001 From: Leanid Astrakou Date: Mon, 21 Aug 2023 15:17:01 -0400 Subject: [PATCH 05/11] Big bugfix, but still has printf's Signed-off-by: Leanid Astrakou --- src/main.c | 74 +++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/src/main.c b/src/main.c index 1962a0b..bcb727b 100644 --- a/src/main.c +++ b/src/main.c @@ -172,13 +172,19 @@ struct { } zl_context = {.config = {.debug_mode = false}, .userid = "(NONE)"} ; static void set_sys_messages(ConfigManager *configmgr) { - Json *env = NULL; + Json *env; int cfgGetStatus = cfgGetAnyC(configmgr, ZOWE_CONFIG_NAME, &env, 2, "zowe", "sysMessages"); - JsonArray *sys_messages = NULL; - ArrayList *list = makeArrayList(); - if (cfgGetStatus == ZCFG_SUCCESS) { - sys_messages = jsonAsArray(env); + if (cfgGetStatus != ZCFG_SUCCESS) { // No sysMessages found in Zowe configuration + return; + } + JsonArray *sys_messages = jsonAsArray(env); + + int count = jsonArrayGetCount(sys_messages); + printf("\nWHATS OUR SYSMSG COUNT %d?", count); + for (int i = 0; i < count; i++) { + char *sys_message = jsonArrayGetString(sys_messages, i); + printf("SYS MESSAGE HERE: %s\n", sys_message); } if (sys_messages) { @@ -188,6 +194,10 @@ static void set_sys_messages(ConfigManager *configmgr) { static void check_for_and_print_sys_message(const char* fmt, ...) { + if (!zl_context.sys_messages) { + return; + } + char input_string[1024]; // buffer to store the formatted message va_list args; @@ -195,40 +205,34 @@ static void check_for_and_print_sys_message(const char* fmt, ...) { vsnprintf(input_string, sizeof(input_string), fmt, args); va_end(args); - printf("IS THIS EVEN FORMATTED %s ????????", input_string); + printf("\nIS THIS EVEN FORMATTED %s ", input_string); // Extract the ID from input_string - char msg_id[256]; // assuming the ID will not exceed 255 characters - const char* spacePos = strchr(input_string, ' '); - if (spacePos) { - int length = spacePos - input_string; - strncpy(msg_id, input_string, length); - msg_id[length] = '\0'; - } else { - // If no space found, use the whole input_string as the ID - //strncpy(msg_id, input_string, sizeof(msg_id) - 1); - //msg_id[sizeof(msg_id) - 1] = '\0'; // ensure null termination - - // If no space found, end - return; - } - - printf("AND WHAT IS ID?%s END", msg_id); - - if (!zl_context.sys_messages) { - return; // return if input_string or sys_messages is NULL + char msg_id[256]; // assuming the ID will not exceed 255 characters + const char* spacePos = strchr(input_string, ' '); + if (spacePos) { + int length = spacePos - input_string; + strncpy(msg_id, input_string, length); + msg_id[length] = '\0'; + } else { + // If no space found, use the whole input_string as the ID + //strncpy(msg_id, input_string, sizeof(msg_id) - 1); + //msg_id[sizeof(msg_id) - 1] = '\0'; // ensure null termination + + // If no space found, end + return; } - int count = jsonArrayGetCount(zl_context.sys_messages); for (int i = 0; i < count; i++) { - const char *sys_message = jsonArrayGetString(zl_context.sys_messages, i); - if (sys_message && strstr(sys_message, msg_id) == 0) { - printf("%s\nAT LEAST ONE MATCH!", input_string); - wtoPrintfMetal(input_string); - break; // break out of loop once a match is found + const char *sys_message_id = jsonArrayGetString(zl_context.sys_messages, i); + if (sys_message_id && strstr(msg_id, sys_message_id)) { // TODO: Maybe this should compare the whole formatted string? + printf("\nMATCH - SYS MESSAGE ID: |%s| MESSAGE ID FROM EXTRACTED OUTPUT |%s|", sys_message_id, msg_id); + wtoPrintfMetal(input_string); // Print our match to the syslog + break; } } + } #define INFO(fmt, ...) check_for_and_print_sys_message(fmt, ##__VA_ARGS__); \ @@ -1640,9 +1644,6 @@ int main(int argc, char **argv) { ERROR(MSG_CTX_INIT_FAILED); exit(EXIT_FAILURE); } - /* TODO(?): sys_messages could be set earlier than this w/ known sysMessages w/o having - config manager available to check zowe.yaml? */ - set_sys_messages(configmgr); cfgSetConfigPath(configmgr, ZOWE_CONFIG_NAME, zl_context.configmgr_path); int parm_member_len = strlen(zl_context.parm_member); @@ -1663,6 +1664,10 @@ int main(int argc, char **argv) { if (process_root_dir(configmgr)) { exit(EXIT_FAILURE); } + + /* TODO(?): sys_messages could be set earlier than this w/ known sysMessages w/o having + config manager available to check zowe.yaml? */ + set_sys_messages(configmgr); //got root dir, can now load up the schemas from it char schemaList[PATH_MAX*2 + 4] = {0}; @@ -1677,6 +1682,7 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } + set_shared_uss_env(configmgr); if (process_workspace_dir(configmgr)) { From 907ceaff6e7011afe0a868b506ad8684296dc320 Mon Sep 17 00:00:00 2001 From: Leanid Astrakou Date: Mon, 21 Aug 2023 15:25:09 -0400 Subject: [PATCH 06/11] More comment Signed-off-by: Leanid Astrakou --- src/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index bcb727b..8829287 100644 --- a/src/main.c +++ b/src/main.c @@ -198,8 +198,9 @@ static void check_for_and_print_sys_message(const char* fmt, ...) { return; } - char input_string[1024]; // buffer to store the formatted message - + /* All of this stuff here is because I can't do + #define INFO(fmt, ...) check_for_and_print_sys_message(fmt, ...) so let's make a string */ + char input_string[1024]; va_list args; va_start(args, fmt); vsnprintf(input_string, sizeof(input_string), fmt, args); From ada2dce81e76d7fe2e686954c6f465418ac117f1 Mon Sep 17 00:00:00 2001 From: Leanid Astrakou Date: Thu, 24 Aug 2023 04:47:36 -0400 Subject: [PATCH 07/11] Check every component log too if it's syslog important Signed-off-by: Leanid Astrakou --- src/main.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main.c b/src/main.c index 8829287..ae5f077 100644 --- a/src/main.c +++ b/src/main.c @@ -206,8 +206,9 @@ static void check_for_and_print_sys_message(const char* fmt, ...) { vsnprintf(input_string, sizeof(input_string), fmt, args); va_end(args); - printf("\nIS THIS EVEN FORMATTED %s ", input_string); + //printf("\nIS THIS EVEN FORMATTED %s ", input_string); + /* Uncomment code to try to pull ID from input_string // Extract the ID from input_string char msg_id[256]; // assuming the ID will not exceed 255 characters const char* spacePos = strchr(input_string, ' '); @@ -222,14 +223,14 @@ static void check_for_and_print_sys_message(const char* fmt, ...) { // If no space found, end return; - } + } */ int count = jsonArrayGetCount(zl_context.sys_messages); for (int i = 0; i < count; i++) { const char *sys_message_id = jsonArrayGetString(zl_context.sys_messages, i); - if (sys_message_id && strstr(msg_id, sys_message_id)) { // TODO: Maybe this should compare the whole formatted string? - printf("\nMATCH - SYS MESSAGE ID: |%s| MESSAGE ID FROM EXTRACTED OUTPUT |%s|", sys_message_id, msg_id); - wtoPrintfMetal(input_string); // Print our match to the syslog + if (sys_message_id && strstr(input_string, sys_message_id)) { + printf("\nMATCH - SYS MESSAGE ID: |%s| MESSAGE ID FROM EXTRACTED OUTPUT |%s|", sys_message_id, input_string); + wtoPrintf3(input_string); // Print our match to the syslog break; } } @@ -916,7 +917,6 @@ static int start_component(zl_comp_t *comp) { comp->clean_stop = false; INFO(MSG_COMP_STARTED, comp->name); - wtoPrintfMetal("SYSLOG POSSIBLY????????????????????"); if (pthread_create(&comp->comm_thid, NULL, handle_comp_comm, comp) != 0) { DEBUG("comm thread not started for %s - %s\n", comp->name, strerror(errno)); @@ -1526,7 +1526,8 @@ static int process_workspace_dir(ConfigManager *configmgr) { } static void print_line(void *data, const char *line) { - printf("%s", line); + printf("YEEEEET?%s", line); + check_for_and_print_sys_message(line); } static char* get_start_prepare_cmd(char *sharedenv) { From 74b0811db3dbe84203bcf3bef56ff272d2a91751 Mon Sep 17 00:00:00 2001 From: Leanid Astrakou Date: Thu, 24 Aug 2023 05:35:13 -0400 Subject: [PATCH 08/11] Clean-up Signed-off-by: Leanid Astrakou --- src/main.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/main.c b/src/main.c index b19786e..4e77bd9 100644 --- a/src/main.c +++ b/src/main.c @@ -179,13 +179,6 @@ static void set_sys_messages(ConfigManager *configmgr) { return; } JsonArray *sys_messages = jsonAsArray(env); - - int count = jsonArrayGetCount(sys_messages); - printf("\nWHATS OUR SYSMSG COUNT %d?", count); - for (int i = 0; i < count; i++) { - char *sys_message = jsonArrayGetString(sys_messages, i); - printf("SYS MESSAGE HERE: %s\n", sys_message); - } if (sys_messages) { zl_context.sys_messages = sys_messages; @@ -206,8 +199,6 @@ static void check_for_and_print_sys_message(const char* fmt, ...) { vsnprintf(input_string, sizeof(input_string), fmt, args); va_end(args); - //printf("\nIS THIS EVEN FORMATTED %s ", input_string); - /* Uncomment code to try to pull ID from input_string // Extract the ID from input_string char msg_id[256]; // assuming the ID will not exceed 255 characters @@ -229,7 +220,6 @@ static void check_for_and_print_sys_message(const char* fmt, ...) { for (int i = 0; i < count; i++) { const char *sys_message_id = jsonArrayGetString(zl_context.sys_messages, i); if (sys_message_id && strstr(input_string, sys_message_id)) { - printf("\nMATCH - SYS MESSAGE ID: |%s| MESSAGE ID FROM EXTRACTED OUTPUT |%s|", sys_message_id, input_string); wtoPrintf3(input_string); // Print our match to the syslog break; } @@ -1529,7 +1519,7 @@ static int process_workspace_dir(ConfigManager *configmgr) { } static void print_line(void *data, const char *line) { - printf("YEEEEET?%s", line); + printf("%s", line); check_for_and_print_sys_message(line); } From 961ab573349755cd6bd3a535c021bd31c15d2dfe Mon Sep 17 00:00:00 2001 From: Leanid Astrakou Date: Mon, 28 Aug 2023 14:33:14 -0400 Subject: [PATCH 09/11] Addressed more code review Signed-off-by: Leanid Astrakou --- src/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 4e77bd9..f011e90 100644 --- a/src/main.c +++ b/src/main.c @@ -1620,6 +1620,7 @@ int main(int argc, char **argv) { } INFO(MSG_LAUNCHER_START); + wtoPrintf3(MSG_LAUNCHER_START); // Manual sys log print (messages not set here yet) zl_config_t config = read_config(argc, argv); zl_context.config = config; @@ -1627,6 +1628,7 @@ int main(int argc, char **argv) { LoggingContext *logContext = makeLoggingContext(); if (!logContext) { ERROR(MSG_NO_LOG_CONTEXT); + wtoPrintf3(MSG_NO_LOG_CONTEXT); // Manual sys log print (messages not set here yet) exit(EXIT_FAILURE); } logConfigureStandardDestinations(logContext); @@ -1637,6 +1639,7 @@ int main(int argc, char **argv) { cfgSetTraceLevel(configmgr, zl_context.config.debug_mode ? 2 : 0); if (init_context(argc, argv, &config, configmgr)) { ERROR(MSG_CTX_INIT_FAILED); + wtoPrintf3(MSG_CTX_INIT_FAILED); // Manual sys log print (messages not set here yet) exit(EXIT_FAILURE); } @@ -1648,11 +1651,13 @@ int main(int argc, char **argv) { if (cfgLoadConfiguration(configmgr, ZOWE_CONFIG_NAME) != 0){ ERROR(MSG_CFG_LOAD_FAIL); + wtoPrintf3(MSG_CFG_LOAD_FAIL); // Manual sys log print (messages not set here yet) exit(EXIT_FAILURE); } if (setup_signal_handlers()) { ERROR(MSG_SIGNAL_ERR); + wtoPrintf3(MSG_SIGNAL_ERR); // Manual sys log print (messages not set here yet) exit(EXIT_FAILURE); } @@ -1660,8 +1665,6 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } - /* TODO(?): sys_messages could be set earlier than this w/ known sysMessages w/o having - config manager available to check zowe.yaml? */ set_sys_messages(configmgr); //got root dir, can now load up the schemas from it From 9dd57122804bd9a75f262e081b41007a1e121a7b Mon Sep 17 00:00:00 2001 From: Leanid Astrakou Date: Tue, 29 Aug 2023 13:46:20 -0400 Subject: [PATCH 10/11] Removed syslog check for launcher debug messages Signed-off-by: Leanid Astrakou --- src/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index f011e90..3ad3919 100644 --- a/src/main.c +++ b/src/main.c @@ -231,8 +231,7 @@ static void check_for_and_print_sys_message(const char* fmt, ...) { printf("%s <%s:%d> %s INFO "fmt, gettime().value, COMP_ID, zl_context.pid, zl_context.userid, ##__VA_ARGS__) #define WARN(fmt, ...) check_for_and_print_sys_message(fmt, ##__VA_ARGS__); \ printf("%s <%s:%d> %s WARN "fmt, gettime().value, COMP_ID, zl_context.pid, zl_context.userid, ##__VA_ARGS__) -#define DEBUG(fmt, ...) check_for_and_print_sys_message(fmt, ##__VA_ARGS__); \ - if (zl_context.config.debug_mode) \ +#define DEBUG(fmt, ...) if (zl_context.config.debug_mode) \ printf("%s <%s:%d> %s DEBUG "fmt, gettime().value, COMP_ID, zl_context.pid, zl_context.userid, ##__VA_ARGS__) #define ERROR(fmt, ...) check_for_and_print_sys_message(fmt, ##__VA_ARGS__); \ printf("%s <%s:%d> %s ERROR "fmt, gettime().value, COMP_ID, zl_context.pid, zl_context.userid, ##__VA_ARGS__) From f7719d5eed93360a19a6e41d59d8b48d9d838b47 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Tue, 29 Aug 2023 12:50:34 -0500 Subject: [PATCH 11/11] point workflow at zcc staging because new syslog code is in there but not master. Signed-off-by: 1000TurquoisePogs --- .github/workflows/build_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 6b5eb82..643f338 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -92,7 +92,7 @@ jobs: with: repository: zowe/zowe-common-c path: deps/launcher/common - ref: 'v2.x/master' + ref: 'v2.x/staging' - name: '[Prep 2] Setup jFrog CLI' uses: jfrog/setup-jfrog-cli@v2