From a1ecee6ab503df75a376aa8e04a1848bcef4efce Mon Sep 17 00:00:00 2001 From: sakeerthy Date: Wed, 26 Feb 2020 21:13:50 -0500 Subject: [PATCH 1/6] WIP zowelog zss format handler Signed-off-by: sakeerthy --- c/datasetService.c | 42 ++++---- c/rasService.c | 10 +- c/zss.c | 162 ++++++++++++++++--------------- c/zssLogging.c | 187 ++++++++++++++++++++++++++++++++++++ deps/zowe-common-c | 2 +- h/zssLogging.h | 3 +- zis-aux/include/aux-utils.h | 4 +- zis-aux/src/aux-utils.c | 4 +- 8 files changed, 303 insertions(+), 111 deletions(-) diff --git a/c/datasetService.c b/c/datasetService.c index 00d4d730d..461d7c38e 100644 --- a/c/datasetService.c +++ b/c/datasetService.c @@ -45,7 +45,7 @@ #ifdef __ZOWE_OS_ZOS static int serveDatasetMetadata(HttpService *service, HttpResponse *response) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); HttpRequest *request = response->request; if (!strcmp(request->method, methodGET)) { if (service->userPointer == NULL){ @@ -54,7 +54,7 @@ static int serveDatasetMetadata(HttpService *service, HttpResponse *response) { } char *l1 = stringListPrint(request->parsedFile, 1, 1, "/", 0); //expect name or hlq - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "l1=%s\n", l1); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "l1=%s\n", l1); if (!strcmp(l1, "name")){ respondWithDatasetMetadata(response); } @@ -81,12 +81,12 @@ static int serveDatasetMetadata(HttpService *service, HttpResponse *response) { finishResponse(response); } - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); return 0; } static int serveDatasetContents(HttpService *service, HttpResponse *response){ - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); HttpRequest *request = response->request; if (!strcmp(request->method, methodGET)) { @@ -94,7 +94,7 @@ static int serveDatasetContents(HttpService *service, HttpResponse *response){ char *percentDecoded = cleanURLParamValue(response->slh, l1); char *filenamep1 = stringConcatenate(response->slh, "//'", percentDecoded); char *filename = stringConcatenate(response->slh, filenamep1, "'"); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "Serving: %s\n", filename); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "Serving: %s\n", filename); fflush(stdout); respondWithDataset(response, filename, TRUE); } @@ -103,7 +103,7 @@ static int serveDatasetContents(HttpService *service, HttpResponse *response){ char *percentDecoded = cleanURLParamValue(response->slh, l1); char *filenamep1 = stringConcatenate(response->slh, "//'", percentDecoded); char *filename = stringConcatenate(response->slh, filenamep1, "'"); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "Updating if exists: %s\n", filename); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "Updating if exists: %s\n", filename); fflush(stdout); updateDataset(response, filename, TRUE); @@ -113,7 +113,7 @@ static int serveDatasetContents(HttpService *service, HttpResponse *response){ char *percentDecoded = cleanURLParamValue(response->slh, l1); char *filenamep1 = stringConcatenate(response->slh, "//'", percentDecoded); char *filename = stringConcatenate(response->slh, filenamep1, "'"); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "Deleting if exists: %s\n", filename); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "Deleting if exists: %s\n", filename); fflush(stdout); deleteDatasetOrMember(response, filename); } @@ -132,24 +132,24 @@ static int serveDatasetContents(HttpService *service, HttpResponse *response){ finishResponse(response); } - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "Returning from servedatasetcontents\n"); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "Returning from servedatasetcontents\n"); return 0; } static int serveVSAMDatasetContents(HttpService *service, HttpResponse *response){ - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); HttpRequest *request = response->request; serveVSAMCache *cache = (serveVSAMCache *)service->userPointer; if (!strcmp(request->method, methodGET)) { char *filename = stringListPrint(request->parsedFile, 1, 1, "/", 0); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "Serving: %s\n", filename); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "Serving: %s\n", filename); fflush(stdout); respondWithVSAMDataset(response, filename, cache->acbTable, TRUE); } else if (!strcmp(request->method, methodPOST)){ char *filename = stringListPrint(request->parsedFile, 1, 1, "/", 0); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "Updating if exists: %s\n", filename); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "Updating if exists: %s\n", filename); fflush(stdout); updateVSAMDataset(response, filename, cache->acbTable, TRUE); } @@ -158,7 +158,7 @@ static int serveVSAMDatasetContents(HttpService *service, HttpResponse *response char *percentDecoded = cleanURLParamValue(response->slh, l1); char *filenamep1 = stringConcatenate(response->slh, "//'", percentDecoded); char *filename = stringConcatenate(response->slh, filenamep1, "'"); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "Deleting if exists: %s\n", filename); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "Deleting if exists: %s\n", filename); fflush(stdout); deleteVSAMDataset(response, filename); } @@ -177,14 +177,14 @@ static int serveVSAMDatasetContents(HttpService *service, HttpResponse *response finishResponse(response); } - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "Returning from serveVSAMdatasetcontents\n"); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "Returning from serveVSAMdatasetcontents\n"); return 0; } void installDatasetContentsService(HttpServer *server) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "Installing dataset contents service\n"); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "Installing dataset contents service\n"); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); HttpService *httpService = makeGeneratedService("datasetContents", "/datasetContents/**"); httpService->authType = SERVICE_AUTH_NATIVE_WITH_SESSION_TOKEN; @@ -195,8 +195,8 @@ void installDatasetContentsService(HttpServer *server) { } void installVSAMDatasetContentsService(HttpServer *server) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "Installing VSAM dataset contents service\n"); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "Installing VSAM dataset contents service\n"); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); HttpService *httpService = makeGeneratedService("VSAMdatasetContents", "/VSAMdatasetContents/**"); httpService->authType = SERVICE_AUTH_NATIVE_WITH_SESSION_TOKEN; @@ -212,8 +212,8 @@ void installVSAMDatasetContentsService(HttpServer *server) { } void installDatasetMetadataService(HttpServer *server) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "Installing dataset metadata service\n"); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "Installing dataset metadata service\n"); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); HttpService *httpService = makeGeneratedService("datasetMetadata", "/datasetMetadata/**"); diff --git a/c/rasService.c b/c/rasService.c index 03729c4bf..8da3d822f 100644 --- a/c/rasService.c +++ b/c/rasService.c @@ -121,13 +121,13 @@ static int serveRASData(HttpService *service, HttpResponse *response) { char *command = stringListPrint(request->parsedFile, 1, 1, "/", 0); if (command == NULL) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_WARNING, "httpserver: error - RAS command not provided\n"); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_WARNING, "httpserver: error - RAS command not provided\n"); respondWithError(response, HTTP_STATUS_BAD_REQUEST, "RAS command not provided"); return 0; } if (strcmp(command, "traceLevel")) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_WARNING, "httpserver: error - unsupported RAS command, %s\n", command); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_WARNING, "httpserver: error - unsupported RAS command, %s\n", command); respondWithError(response, HTTP_STATUS_BAD_REQUEST, "unsupported RAS command"); return 0; } @@ -150,7 +150,7 @@ static int serveRASData(HttpService *service, HttpResponse *response) { return 0; } - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "%s: componentID=0x%016llX\n", __FUNCTION__, componentID); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "%s: componentID=0x%016llX\n", __FUNCTION__, componentID); if (!strcmp(request->method, methodPUT)) { @@ -223,7 +223,7 @@ static int serveRASData(HttpService *service, HttpResponse *response) { } int installRASService(HttpServer *server) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); HttpService *httpService = makeGeneratedService("RAS service", "/ras/**"); httpService->serviceFunction = serveRASData; httpService->runInSubtask = FALSE; @@ -233,7 +233,7 @@ int installRASService(HttpServer *server) { makeIntParamSpec("level", SERVICE_ARG_OPTIONAL, 0, 0, 0, 0, NULL)); registerHttpService(server, httpService); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); return 0; } diff --git a/c/zss.c b/c/zss.c index 1fe67bed0..7f510e280 100644 --- a/c/zss.c +++ b/c/zss.c @@ -104,7 +104,7 @@ static JsonObject *readServerSettings(ShortLivedHeap *slh, const char *filename) static InternalAPIMap *makeInternalAPIMap(void); static int servePluginDefinitions(HttpService *service, HttpResponse *response){ - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); WebPluginListElt *webPluginListElt = (WebPluginListElt*)service->userPointer; jsonPrinter *printer = respondWithJsonPrinter(response); HttpRequestParam *typeParam = getCheckedParam(response->request, "type"); @@ -141,34 +141,34 @@ static int servePluginDefinitions(HttpService *service, HttpResponse *response){ } jsonEnd(printer); finishResponse(response); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); return 0; } static int serveWebContent(HttpService *service, HttpResponse *response){ - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); char *targetDirectory = (char*) service->userPointer; HttpRequest *request = response->request; char *fileFrag = stringListPrint(request->parsedFile, 4 /* skip PRODUCT/plugins/baseURI/web */, 1000, "/", 0); char *filename = stringConcatenate(response->slh, targetDirectory, fileFrag); respondWithUnixFileContentsWithAutocvtMode(NULL, response, filename, FALSE, 0); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); return 0; } static int serveLibraryContent(HttpService *service, HttpResponse *response){ - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); char *targetDirectory = (char*) service->userPointer; HttpRequest *request = response->request; char *fileFrag = stringListPrint(request->parsedFile, 3 /* skip lib/identifier/libraryVersion */, 1000, "/", 0); char *filename = stringConcatenate(response->slh, targetDirectory, fileFrag); respondWithUnixFileContentsWithAutocvtMode(NULL, response, filename, FALSE, 0); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); return 0; } static int extractAuthorizationFromJson(HttpService *service, HttpRequest *request){ - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); /* should check content type */ char *inPtr = request->contentBody; char *nativeBody = copyStringToNative(request->slh, inPtr, strlen(inPtr)); @@ -202,7 +202,7 @@ static int extractAuthorizationFromJson(HttpService *service, HttpRequest *reque static int serveMainPage(HttpService *service, HttpResponse *response) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); char mainPage[2048]; snprintf(mainPage, 2048, "/%s/plugins/com.rs.mvd/web/index.html", PRODUCT); @@ -210,14 +210,14 @@ int serveMainPage(HttpService *service, HttpResponse *response) { addStringHeader(response, "Location", mainPage); addStringHeader(response, "Server", "jdmfws"); writeHeader(response); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); return 0; } int serveLoginWithSessionToken(HttpService *service, HttpResponse *response) { jsonPrinter *p = respondWithJsonPrinter(response); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "serveLoginWithSessionToken: start. response=0x%p; cookie=0x%p\n", response, response->sessionCookie); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "serveLoginWithSessionToken: start. response=0x%p; cookie=0x%p\n", response, response->sessionCookie); setResponseStatus(response,200,"OK"); setContentType(response,"text/html"); addStringHeader(response,"Server","jdmfws"); @@ -233,14 +233,14 @@ int serveLoginWithSessionToken(HttpService *service, HttpResponse *response) { jsonEnd(p); finishResponse(response); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "serveLoginWithSessionToken: end\n"); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "serveLoginWithSessionToken: end\n"); return HTTP_SERVICE_SUCCESS; } int serveLogoutByRemovingSessionToken(HttpService *service, HttpResponse *response) { jsonPrinter *p = respondWithJsonPrinter(response); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "serveLogoutByRemovingSessionToken: start. response=0x%p; cookie=0x%p\n", response, response->sessionCookie); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "serveLogoutByRemovingSessionToken: start. response=0x%p; cookie=0x%p\n", response, response->sessionCookie); setResponseStatus(response,200,"OK"); setContentType(response,"text/html"); addStringHeader(response,"Server","jdmfws"); @@ -260,7 +260,7 @@ int serveLogoutByRemovingSessionToken(HttpService *service, HttpResponse *respon jsonEnd(p); finishResponse(response); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "serveLogoutByRemovingSessionToken: end\n"); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "serveLogoutByRemovingSessionToken: end\n"); return HTTP_SERVICE_SUCCESS; } @@ -290,7 +290,7 @@ static void setPrivilegedServerName(HttpServer *server, JsonObject *mvdSettings, if (strlen(priviligedServerNameNullTerm) != 0) { *privilegedServerName = cmsMakeServerName(priviligedServerNameNullTerm); } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_WARNING, "warning: privileged server name not provided, falling back to default\n"); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_WARNING, "warning: privileged server name not provided, falling back to default\n"); *privilegedServerName = zisGetDefaultServerName(); } @@ -319,9 +319,9 @@ static int setMVDTrace(int toWhat) { int was = traceLevel; if (isLogLevelValid(toWhat)) { traceLevel = toWhat; - logSetLevel(NULL, LOG_COMP_ID_MVD_SERVER, toWhat); + logSetLevel(NULL, LOG_COMP_ID_ZSS, toWhat); } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_ALWAYS, "error: log level %d is incorrect\n", toWhat); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_ALWAYS, "error: log level %d is incorrect\n", toWhat); } return was; } @@ -358,13 +358,13 @@ static JsonObject *readServerSettings(ShortLivedHeap *slh, const char *filename) int jsonErrorBufferSize = sizeof(jsonErrorBuffer); Json *mvdSettings = NULL; JsonObject *mvdSettingsJsonObject = NULL; - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "reading server settings from %s\n", filename); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "reading server settings from %s\n", filename); mvdSettings = jsonParseFile(slh, filename, jsonErrorBuffer, jsonErrorBufferSize); if (mvdSettings) { if (jsonIsObject(mvdSettings)) { mvdSettingsJsonObject = jsonAsObject(mvdSettings); } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_WARNING, "error in file %s: expected top level object\n", filename); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_WARNING, "error in file %s: expected top level object\n", filename); } JsonObject *logLevels = jsonObjectGetObject(mvdSettingsJsonObject, "logLevels"); if (logLevels) { @@ -379,7 +379,7 @@ static JsonObject *readServerSettings(ShortLivedHeap *slh, const char *filename) } dumpJson(mvdSettings); } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_WARNING, "error while parsing ZSS settings from file %s: %s\n", filename, jsonErrorBuffer); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_WARNING, "error while parsing ZSS settings from file %s: %s\n", filename, jsonErrorBuffer); } return mvdSettingsJsonObject; } @@ -397,7 +397,7 @@ static int stringEndsWith(char *s, char *suffix) { } static void writeJsonMethod(struct jsonPrinter_tag *unusedPrinter, char *text, int len) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG, "%.*s", len, text); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG, "%.*s", len, text); } static void dumpJson(Json *json) { @@ -405,7 +405,7 @@ static void dumpJson(Json *json) { jsonEnablePrettyPrint(printer); jsonPrint(printer, json); freeJsonPrinter(printer); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG, "\n"); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG, "\n"); } typedef struct { @@ -451,7 +451,7 @@ static JsonObject *readPluginDefinition(ShortLivedHeap *slh, char *pluginIdentif int pluginLocationLen = strlen(pluginLocation); int needsSlash = (pluginLocation[pluginLocationLen - 1] != '/'); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "%s begin identifier %s location %s\n", __FUNCTION__, pluginIdentifier, pluginLocation); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "%s begin identifier %s location %s\n", __FUNCTION__, pluginIdentifier, pluginLocation); sprintf(path, "%s%s%s", pluginLocation, needsSlash ? "/" : "", "pluginDefinition.json"); Json *pluginDefinitionJson = jsonParseFile(slh, path, errorBuffer, sizeof (errorBuffer)); if (pluginDefinitionJson) { @@ -463,23 +463,23 @@ static JsonObject *readPluginDefinition(ShortLivedHeap *slh, char *pluginIdentif if (0 == strcmp(pluginIdentifier, identifier)) { pluginDefinition = pluginDefinitionJsonObject; } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "expected plugin identifier %s, got %s\n", pluginIdentifier, identifier); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "expected plugin identifier %s, got %s\n", pluginIdentifier, identifier); } } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "plugin identifier was not found in %s\n", path); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "plugin identifier was not found in %s\n", path); } } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "error in file %s: expected top level object\n", path); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "error in file %s: expected top level object\n", path); } } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "error while parsing file %s: %s\n", path, errorBuffer); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "error while parsing file %s: %s\n", path, errorBuffer); } - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "%s end result is %s\n", __FUNCTION__, pluginDefinition ? "not null" : "null"); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "%s end result is %s\n", __FUNCTION__, pluginDefinition ? "not null" : "null"); return pluginDefinition; } static void installWebPluginFilesServices(WebPlugin* plugin, HttpServer *server) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); int i = 0; JsonObject *pluginDefintion = plugin->pluginDefinition; int pluginLocationLen = strlen(plugin->pluginLocation); @@ -498,9 +498,9 @@ static void installWebPluginFilesServices(WebPlugin* plugin, HttpServer *server) char *targetDirectory = SLHAlloc(server->slh, pluginLocationLen + webDirectoryLen + pluginLocationNeedsSlash + 1); sprintf(targetDirectory, "%s%s%s", plugin->pluginLocation, pluginLocationNeedsSlash ? "/" : "", webDirectory); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "%s\n", uriMask); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "%s\n", identifier); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "%s\n", targetDirectory); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "%s\n", uriMask); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "%s\n", identifier); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "%s\n", targetDirectory); HttpService *httpService = makeGeneratedService(identifier, uriMask); httpService->userPointer = targetDirectory; @@ -508,7 +508,7 @@ static void installWebPluginFilesServices(WebPlugin* plugin, HttpServer *server) httpService->serviceFunction = serveWebContent; registerHttpService(server, httpService); } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "webContent wasn't found in plugin defintion for %s\n", plugin->identifier); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "webContent wasn't found in plugin defintion for %s\n", plugin->identifier); } } else if (WEB_PLUGIN_TYPE_LIBRARY == plugin->pluginType) { char *libraryVersion = jsonObjectGetString(pluginDefintion, "libraryVersion"); @@ -525,9 +525,9 @@ static void installWebPluginFilesServices(WebPlugin* plugin, HttpServer *server) char *targetDirectory = SLHAlloc(server->slh, pluginLocationLen + pluginLocationNeedsSlash + 1); sprintf(targetDirectory, "%s%s", plugin->pluginLocation, pluginLocationNeedsSlash ? "/" : ""); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "%s\n", uriMask); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "%s\n", identifier); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "%s\n", targetDirectory); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "%s\n", uriMask); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "%s\n", identifier); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "%s\n", targetDirectory); HttpService *httpService = makeGeneratedService(identifier, uriMask); httpService->userPointer = targetDirectory; @@ -535,14 +535,14 @@ static void installWebPluginFilesServices(WebPlugin* plugin, HttpServer *server) httpService->serviceFunction = serveLibraryContent; registerHttpService(server, httpService); } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "libraryVersion wasn't found in plugin defintion for %s\n", plugin->identifier); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "libraryVersion wasn't found in plugin defintion for %s\n", plugin->identifier); } } - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); } static void installLoginService(HttpServer *server) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); HttpService *httpService = makeGeneratedService("com.rs.mvd.login", "/login/**"); httpService->authType = SERVICE_AUTH_NATIVE_WITH_SESSION_TOKEN; @@ -552,7 +552,7 @@ static void installLoginService(HttpServer *server) { } static void installLogoutService(HttpServer *server) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); HttpService *httpService = makeGeneratedService("com.rs.mvd.logout", "/logout/**"); httpService->authType = SERVICE_AUTH_NATIVE_WITH_SESSION_TOKEN; @@ -561,15 +561,15 @@ static void installLogoutService(HttpServer *server) { } static void installWebPluginDefintionsService(WebPluginListElt *webPlugins, HttpServer *server) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG, "installing plugin definitions service\n"); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "begin %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG, "installing plugin definitions service\n"); HttpService *httpService = makeGeneratedService("plugin definitions service", "/plugins"); httpService->serviceFunction = servePluginDefinitions; httpService->userPointer = webPlugins; httpService->paramSpecList = makeStringParamSpec("type", SERVICE_ARG_OPTIONAL, NULL); httpService->authType = SERVICE_AUTH_NONE; registerHttpService(server, httpService); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "end %s\n", __FUNCTION__); } static int checkLoggingVerbosity(const char *serverConfigFile, char *pluginIdentifier, ShortLivedHeap *slh) { @@ -619,7 +619,7 @@ static WebPluginListElt* readWebPluginDefinitions(HttpServer *server, ShortLived WebPluginListElt *webPluginListTail = NULL; unsigned int idMultiplier = 1; /* multiplier for the dynamic logging id */ - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "%s begin dirname %s\n", __FUNCTION__, dirname); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "%s begin dirname %s\n", __FUNCTION__, dirname); if (directory) { while ((entriesRead = directoryRead(directory, directoryDataBuffer, DIR_BUFFER_SIZE, &returnCode, &reasonCode)) > 0) { char *entryStart = directoryDataBuffer; @@ -628,7 +628,7 @@ static WebPluginListElt* readWebPluginDefinitions(HttpServer *server, ShortLived char *name = entryStart + 4; int isJsonFile = stringEndsWith(name, jsonExt); if (isJsonFile) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG, "found JSON file %s\n", name); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG, "found JSON file %s\n", name); memset(path, 0, sizeof(path)); sprintf(path, "%s%s%s", dirname, needsSlash ? "/" : "", name); Json *json = jsonParseFile(slh, path, errorBuffer, sizeof (errorBuffer)); @@ -658,17 +658,17 @@ static WebPluginListElt* readWebPluginDefinitions(HttpServer *server, ShortLived webPluginListTail = pluginListElt; } } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_WARNING, "plugin id=%s is NULL and cannot be loaded.\n", identifier); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_WARNING, "plugin id=%s is NULL and cannot be loaded.\n", identifier); } } } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "plugin identifier or/and pluginLocation was not found in %s\n", path); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "plugin identifier or/and pluginLocation was not found in %s\n", path); } } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_WARNING, "error in file %s: expected top level object\n", path); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_WARNING, "error in file %s: expected top level object\n", path); } } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_WARNING, "error while parsing %s: %s\n", errorBuffer); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_WARNING, "error while parsing %s: %s\n", errorBuffer); } } entryStart += entryLength; @@ -678,12 +678,12 @@ static WebPluginListElt* readWebPluginDefinitions(HttpServer *server, ShortLived directoryClose(directory, &returnCode, &reasonCode); directory = NULL; } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_WARNING, "couldn't open directory '%s' returnCode=%d reasonCode=0x%x\n", dirname, returnCode, reasonCode); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_WARNING, "couldn't open directory '%s' returnCode=%d reasonCode=0x%x\n", dirname, returnCode, reasonCode); } if (webPluginListHead) { installWebPluginDefintionsService(webPluginListHead, server); } - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG2, "%s end result %d\n", __FUNCTION__, pluginDefinitionCount); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_DEBUG2, "%s end result %d\n", __FUNCTION__, pluginDefinitionCount); return webPluginListHead; } @@ -698,9 +698,9 @@ void checkAndSetVariable(JsonObject *mvdSettings, const char* tempString = jsonObjectGetString(mvdSettings, configVariableName); if (tempString){ snprintf(target, targetMax, "%s", tempString); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "%s is '%s'\n", configVariableName, target); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "%s is '%s'\n", configVariableName, target); } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "%s is not specified, or is NULL.\n", configVariableName); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "%s is not specified, or is NULL.\n", configVariableName); } } @@ -721,26 +721,30 @@ void checkAndSetVariableWithEnvOverride(JsonObject *mvdSettings, if (tempString){ snprintf(target, targetMax, "%s", tempString); if(override){ - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "%s override with env %s is '%s'\n", configVariableName, envConfigVariableName, target); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "%s override with env %s is '%s'\n", configVariableName, envConfigVariableName, target); } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "%s is '%s'\n", configVariableName, target); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "%s is '%s'\n", configVariableName, target); } } else { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "%s or env %s is not specified, or is NULL.\n", configVariableName, envConfigVariableName); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "%s or env %s is not specified, or is NULL.\n", configVariableName, envConfigVariableName); } } + + + static void initLoggingComponents(void) { + logConfigureDestination2(NULL, LOG_DEST_PRINTF_STDOUT, "printf(stdout)", NULL, zssFormatter, standardDumperFunction); logConfigureComponent(NULL, LOG_COMP_ID_SECURITY, "ZSS Security API", LOG_DEST_PRINTF_STDOUT, ZOWE_LOG_INFO); logConfigureComponent(NULL, LOG_COMP_DISCOVERY, "Zowe Discovery", LOG_DEST_PRINTF_STDOUT, ZOWE_LOG_INFO); logConfigureComponent(NULL, LOG_COMP_RESTDATASET, "Zowe Dataset REST", LOG_DEST_PRINTF_STDOUT, ZOWE_LOG_INFO); logConfigureComponent(NULL, LOG_COMP_RESTFILE, "Zowe UNIX REST", LOG_DEST_PRINTF_STDOUT, ZOWE_LOG_INFO); logConfigureComponent(NULL, LOG_COMP_ID_UNIXFILE, "ZSS UNIX REST", LOG_DEST_PRINTF_STDOUT, ZOWE_LOG_INFO); logConfigureComponent(NULL, LOG_COMP_DATASERVICE, "ZSS dataservices", LOG_DEST_PRINTF_STDOUT, ZOWE_LOG_INFO); - logConfigureComponent(NULL, LOG_COMP_ID_MVD_SERVER, "ZSS server", LOG_DEST_PRINTF_STDOUT, ZOWE_LOG_INFO); + logConfigureComponent(NULL, LOG_COMP_ID_ZSS, "ZSS server", LOG_DEST_PRINTF_STDOUT, ZOWE_LOG_INFO); logConfigureComponent(NULL, LOG_COMP_ID_CTDS, "CT/DS", LOG_DEST_PRINTF_STDOUT, ZOWE_LOG_INFO); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "zssServer startup, version %s\n", productVersion); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "zssServer startup, version %s\n", productVersion); } static void initVersionComponents(void){ @@ -762,7 +766,7 @@ static void printZISStatus(HttpServer *server) { shortDescription = "Failure"; } - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_ALWAYS, + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_ALWAYS, "ZIS status - %s (name='%.16s', cmsRC=%d, description='%s', " "clientVersion=%d)\n", shortDescription, @@ -808,7 +812,7 @@ static void readAgentAddressAndPort(JsonObject *serverConfig, JsonObject *envCon static int validateAddress(char *address, InetAddr **inetAddress, int *requiredTLSFlag) { *inetAddress = getAddressByName(address); if (strcmp(address,"127.0.0.1") && strcmp(address,"localhost")) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_WARNING, + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_WARNING, "*** WARNING: Server doesn't implement HTTPS! ***\n*** In production only use localhost or 127.0.0.1! Server using: %s ***\n", address); *requiredTLSFlag = RS_TLS_WANT_TLS; @@ -831,7 +835,7 @@ static const int FORBIDDEN_OTHER_PERMISSION = 0x07; /* validates permissions for a given path */ static int validateConfigPermissionsInner(const char *path) { if (!path) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_SEVERE, + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_SEVERE, "Cannot validate file permission, path is not defined.\n"); return 8; } @@ -841,15 +845,15 @@ static int validateConfigPermissionsInner(const char *path) { int reasonCode = 0; int returnValue = fileInfo(path, &stat, &returnCode, &reasonCode); if (returnValue != 0) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_SEVERE, + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_SEVERE, "Couldnt stat config path=%s. return=%d, reason=%d\n",path,returnCode, reasonCode); return 8; } else if (((stat.fileType == BPXSTA_FILETYPE_DIRECTORY) && (stat.flags3 & FORBIDDEN_GROUP_DIR_PERMISSION)) || ((stat.fileType != BPXSTA_FILETYPE_DIRECTORY) && (stat.flags3 & FORBIDDEN_GROUP_FILE_PERMISSION)) || (stat.flags3 & FORBIDDEN_OTHER_PERMISSION)) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_SEVERE, + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_SEVERE, "Config path=%s has group & other permissions that are too open! Refusing to start.\n",path); - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_SEVERE, + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_SEVERE, "Ensure group has no write (or execute, if file) permission. Ensure other has no permissions. Then, restart zssServer to retry.\n"); return 8; } @@ -859,7 +863,7 @@ static int validateConfigPermissionsInner(const char *path) { #ifdef ZSS_IGNORE_PERMISSION_PROBLEMS static int validateFilePermissions(const char *filePath) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_SEVERE, + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_SEVERE, "Skipping validation of file permissions: disabled during compilation, " "file %s.\n", filePath); return 0; @@ -870,14 +874,14 @@ static int validateFilePermissions(const char *filePath) { /* Validates that both file AND parent folder meet requirements */ static int validateFilePermissions(const char *filePath) { if (!filePath) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_SEVERE, + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_SEVERE, "Cannot validate file permission, path is not defined.\n"); return 8; } int filePathLen = strlen(filePath); int lastSlashPos = lastIndexOf(filePath, filePathLen, '/'); if (lastSlashPos == filePathLen-1) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_SEVERE, + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_SEVERE, "Cannot validate file permission, path was for a directory not a file.\n"); return 8; } @@ -927,7 +931,7 @@ int initializeJwtKeystoreIfConfigured(JsonObject *const serverConfig, JsonObject *const agentSettings = jsonObjectGetObject(serverConfig, "agent"); if (agentSettings == NULL) { zowelog(NULL, - LOG_COMP_ID_MVD_SERVER, + LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "Will not accept JWTs: agent configuration missing\n"); return 0; @@ -936,7 +940,7 @@ int initializeJwtKeystoreIfConfigured(JsonObject *const serverConfig, JsonObject *const jwtSettings = jsonObjectGetObject(agentSettings, "jwt"); if (jwtSettings == NULL) { zowelog(NULL, - LOG_COMP_ID_MVD_SERVER, + LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "Will not accept JWTs: JWT keystore configuration missing\n"); return 0; @@ -944,7 +948,7 @@ int initializeJwtKeystoreIfConfigured(JsonObject *const serverConfig, if (!jsonObjectGetBoolean(jwtSettings, "enabled")) { zowelog(NULL, - LOG_COMP_ID_MVD_SERVER, + LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "Will not accept JWTs: disabled in the configuration\n"); return 0; @@ -955,7 +959,7 @@ int initializeJwtKeystoreIfConfigured(JsonObject *const serverConfig, JsonObject *const jwtKeyConfig = jsonObjectGetObject(jwtSettings, "key"); if (jwtKeyConfig == NULL) { zowelog(NULL, - LOG_COMP_ID_MVD_SERVER, + LOG_COMP_ID_ZSS, ZOWE_LOG_SEVERE, "JWT keystore configuration missing\n"); return 1; @@ -970,19 +974,19 @@ int initializeJwtKeystoreIfConfigured(JsonObject *const serverConfig, if (keystoreType != NULL && strcmp(keystoreType, "pkcs11") != 0) { zowelog(NULL, - LOG_COMP_ID_MVD_SERVER, + LOG_COMP_ID_ZSS, ZOWE_LOG_SEVERE, "Invalid JWT configuration: unknown keystore type %s\n", keystoreType); return 1; } else if (keystoreName == NULL) { zowelog(NULL, - LOG_COMP_ID_MVD_SERVER, + LOG_COMP_ID_ZSS, ZOWE_LOG_SEVERE, "Invalid JWT configuration: keystore name missing\n"); return 1; } else { zowelog(NULL, - LOG_COMP_ID_MVD_SERVER, + LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "Will use JWT using PKCS#11 token '%s', key id '%s'," " %s fallback to legacy tokens\n", @@ -1000,7 +1004,7 @@ int initializeJwtKeystoreIfConfigured(JsonObject *const serverConfig, CKO_PUBLIC_KEY, &initTokenRc, &p11rc, &p11Rsn); if (contextInitRc != 0) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_WARNING, + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_WARNING, "Server startup problem: could not load the JWT key %s from token %s:" " rc %d, p11rc %d, p11Rsn %d\n", keyId, @@ -1050,7 +1054,7 @@ int main(int argc, char **argv){ serverConfigFile = argv[1]; } } - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "Server config file=%s\n", serverConfigFile); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "Server config file=%s\n", serverConfigFile); int invalid = validateFilePermissions(serverConfigFile); if (invalid) { return invalid; @@ -1077,11 +1081,11 @@ int main(int argc, char **argv){ InetAddr *inetAddress = NULL; int requiredTLSFlag = 0; if (!validateAddress(address, &inetAddress, &requiredTLSFlag)) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_WARNING, "server startup problem, address %s not valid\n", address); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_WARNING, "server startup problem, address %s not valid\n", address); return 8; } - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "ZSS server settings: address=%s, port=%d\n", address, port); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_INFO, "ZSS server settings: address=%s, port=%d\n", address, port); server = makeHttpServer2(base,inetAddress,port,requiredTLSFlag,&returnCode,&reasonCode); if (server){ if (0 != initializeJwtKeystoreIfConfigured(mvdSettings, server)) { @@ -1113,9 +1117,9 @@ int main(int argc, char **argv){ mainHttpLoop(server); } else{ - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_WARNING, "Server startup problem ret=%d reason=0x%x\n", returnCode, reasonCode); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_WARNING, "Server startup problem ret=%d reason=0x%x\n", returnCode, reasonCode); if (returnCode==EADDRINUSE) { - zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_WARNING, "This is usually due to the server port (%d) already being occupied. Is ZSS running twice?\n",port); + zowelog(NULL, LOG_COMP_ID_ZSS, ZOWE_LOG_WARNING, "This is usually due to the server port (%d) already being occupied. Is ZSS running twice?\n",port); } } } diff --git a/c/zssLogging.c b/c/zssLogging.c index bcc88aee5..b385efc5d 100644 --- a/c/zssLogging.c +++ b/c/zssLogging.c @@ -33,6 +33,8 @@ #include "zowetypes.h" #include "logging.h" +#include "zos.h" +#include "zssLogging.h" bool isLogLevelValid(int level) { @@ -43,6 +45,191 @@ bool isLogLevelValid(int level) { return TRUE; } +#define PREFIXED_LINE_MAX_COUNT 1000 +#define PREFIXED_LINE_MAX_MSG_LENGTH 4096 +#define LOG_MSG_PREFIX_SIZE 57 + +typedef struct LogMessagePrefix_tag { + char text[LOG_MSG_PREFIX_SIZE]; +} LogMessagePrefix; + +typedef struct LogTimestamp_tag { + union { + struct { + char year[4]; + char delim00[1]; + char month[2]; + char delim01[1]; + char day[2]; + char delim02[1]; + char hour[2]; + char delim03[1]; + char minute[2]; + char delim04[1]; + char second[2]; + char delim05[1]; + char hundredth[2]; + } dateAndTime; + char text[22]; + }; +} LogTimestamp; + + +static void getCurrentLogTimestamp(LogTimestamp *timestamp) { + + uint64 stck = 0; + getSTCKU(&stck); + + stck += getLocalTimeOffset(); + + stckToLogTimestamp(stck, timestamp); + +} + +static void getLocationData(char *path, int line, char **locationInfo, uint64 compID, LoggingComponent *component) { + + char prefix[128]; + char suffix[128]; + + unsigned int id = compID & 0xFFFFFFFF; + if(compID >= LOG_PROD_COMMON && compID < LOG_PROD_ZIS) { + snprintf(prefix,5,"_zcc"); + switch (id) { // most of these don't actally log, but are defined in logging.h + case LOG_COMP_ALLOC: snprintf(suffix,6,"alloc"); + break; + case LOG_COMP_UTILS: snprintf(suffix,6,"utils"); + break; + case LOG_COMP_COLLECTIONS: snprintf(suffix,12,"collections"); + break; + case LOG_COMP_SERIALIZATION: snprintf(suffix,14,"serialization"); + break; + case LOG_COMP_ZLPARSER: snprintf(suffix,9,"zlparser"); + break; + case LOG_COMP_ZLCOMPILER: snprintf(suffix,11,"zlcompiler"); + break; + case LOG_COMP_ZLRUNTIME: snprintf(suffix,10,"zlruntime"); + break; + case LOG_COMP_STCBASE: snprintf(suffix,8,"stcbase"); + break; + case LOG_COMP_HTTPSERVER: snprintf(suffix,11,"httpserver"); + break; + case LOG_COMP_DISCOVERY: snprintf(suffix,10,"discovery"); + break; + case LOG_COMP_DATASERVICE: snprintf(suffix,12,"dataservice"); + break; + case LOG_COMP_CMS: snprintf(suffix,4,"cms"); + break; + case 0xC0001: snprintf(suffix,4,"cms"); + break; + case 0xC0002: snprintf(suffix,6,"cmspc"); + break; + case LOG_COMP_LPA: snprintf(suffix,4,"lpa"); + break; + case LOG_COMP_RESTDATASET: snprintf(suffix,12,"restdataset"); + break; + case LOG_COMP_RESTFILE: snprintf(suffix,9,"restfile"); + break; + } + } + else if (compID >= LOG_PROD_ZIS && compID < LOG_PROD_ZSS) { + snprintf(prefix,5,"_zis"); + } + else if (compID >= LOG_PROD_ZSS && compID < LOG_PROD_PLUGINS ) { + snprintf(prefix,5,"_zss"); + switch (id) { + case LOG_COMP_ID_ZSS: snprintf(suffix,4,"zss"); + break; + case LOG_COMP_ID_CTDS: snprintf(suffix,5,"ctds"); + break; + case LOG_COMP_ID_SECURITY: snprintf(suffix,9,"security"); + break; + case LOG_COMP_ID_UNIXFILE: snprintf(suffix,9, "unixfile"); + break; + } + } + else if (compID > LOG_PROD_PLUGINS) { + snprintf(suffix,strlen(component->name),"%s",(strrchr(component->name, '/')+1)); // given more characters than it writes + snprintf(prefix,strlen(component->name)-strlen(suffix),"%s",component->name); + } + + char *filename; + filename = strrchr(path, '/'); // returns a pointer to the last occurence of '/' + filename+=1; + // formatting + prefix + suffix + filename + line number + int locationSize = 7 + strlen(prefix) + strlen(suffix) + strlen(filename) + 5; + *locationInfo = (char*) safeMalloc(locationSize,"locationInfo"); + snprintf(*locationInfo,locationSize+1," (%s:%s,%s:%d) ",prefix,suffix,filename,line); +} + +void initLogMessagePrefix(LogMessagePrefix *prefix, LoggingComponent *component, char* path, int line, int level, uint64 compID) { + LogTimestamp currentTime; + getCurrentLogTimestamp(¤tTime); + ASCB *ascb = getASCB(); + char *jobName = getASCBJobname(ascb); +// TCB *tcb = getTCB(); + + ACEE *acee; + acee = getAddressSpaceAcee(); + char user[7] = { 0 }; // wil this always be 7? + snprintf(user,7,acee->aceeuser+1); + + pthread_t threadID = pthread_self(); + char thread[10]; + snprintf(thread,10,"%d",threadID); + + char *logLevel; + + switch(level) { + case 0: snprintf(logLevel,7,"SEVERE"); + break; + case 1: snprintf(logLevel,8,"WARN"); + break; + case 2: snprintf(logLevel,5,"INFO"); + break; + case 3: snprintf(logLevel,5,"DEBUG"); + break; + case 4: snprintf(logLevel,6,"DEBUG"); + break; + case 5: snprintf(logLevel,7,"TRACE"); + break; + } + + char *locationInfo; // largest possible variation in size + getLocationData(path,line,&locationInfo,compID,component); // location info is allocated in getLocationData + + + snprintf(prefix->text, sizeof(prefix->text), "%22.22s <%8.8s:%s> %s %s (%s) ", currentTime.text, jobName, thread, user, logLevel, locationInfo); + prefix->text[sizeof(prefix->text) - 1] = ' '; +} + +void zssFormatter(LoggingContext *context, LoggingComponent *component, char* path, int line, int level, uint64 compID, void *data, char *formatString, va_list argList) { + char messageBuffer[PREFIXED_LINE_MAX_MSG_LENGTH]; + size_t messageLength = vsnprintf(messageBuffer, sizeof(messageBuffer), formatString, argList); + + if (messageLength > sizeof(messageBuffer) - 1) { + messageLength = sizeof(messageBuffer) - 1; + } + + LogMessagePrefix prefix; + + char *nextLine = messageBuffer; + char *lastLine = messageBuffer + messageLength; + for (int lineIdx = 0; lineIdx < PREFIXED_LINE_MAX_COUNT; lineIdx++) { + if (nextLine >= lastLine) { + break; + } + char *endOfLine = strchr(nextLine, '\n'); + size_t nextLineLength = endOfLine ? (endOfLine - nextLine) : (lastLine - nextLine); + memset(prefix.text, ' ', sizeof(prefix.text)); + if (lineIdx == 0) { + initLogMessagePrefix(&prefix, component, path, line, level, compID); + } + printf("%.*s%.*s\n", sizeof(prefix.text), prefix.text, nextLineLength, nextLine); + nextLine += (nextLineLength + 1); + } + +} + /* This program and the accompanying materials are diff --git a/deps/zowe-common-c b/deps/zowe-common-c index fbd8d446a..958767030 160000 --- a/deps/zowe-common-c +++ b/deps/zowe-common-c @@ -1 +1 @@ -Subproject commit fbd8d446a84186df3a996c1f0ced58dcad7717c5 +Subproject commit 9587670300dfb59bb03465358e41737c8ee2975a diff --git a/h/zssLogging.h b/h/zssLogging.h index d88d74fea..73cafe152 100644 --- a/h/zssLogging.h +++ b/h/zssLogging.h @@ -13,12 +13,13 @@ #ifndef MVD_H_ZSSLOGGING_H_ #define MVD_H_ZSSLOGGING_H_ -#define LOG_COMP_ID_MVD_SERVER 0x008F000300010000 +#define LOG_COMP_ID_ZSS 0x008F000300010000 #define LOG_COMP_ID_CTDS 0x008F000300020000 #define LOG_COMP_ID_SECURITY 0x008F000300030000 #define LOG_COMP_ID_UNIXFILE 0x008F000300040000 bool isLogLevelValid(int level); +void zssFormatter(LoggingContext *context, LoggingComponent *component, char* path, int line, int level, uint64 compID, void *data, char *formatString, va_list argList); #endif /* MVD_H_ZSSLOGGING_H_ */ diff --git a/zis-aux/include/aux-utils.h b/zis-aux/include/aux-utils.h index 8cdc3adda..7a59c80a2 100644 --- a/zis-aux/include/aux-utils.h +++ b/zis-aux/include/aux-utils.h @@ -85,10 +85,10 @@ ZOWE_PRAGMA_PACK_RESET /* Logging fucntion */ -void auxutilPrintWithPrefix(LoggingContext *context, LoggingComponent *component, +void auxutilPrintWithPrefix(LoggingContext *context, LoggingComponent *component, char* path, int line, int level, uint64 compID, void *data, char *formatString, va_list argList); char *auxutilDumpWithEmptyMessageID(char *workBuffer, int workBufferSize, - void *data, int dataSize, int lineNumber); + void *data, int dataSize, int lineNumber, char* path, int line); /* Misc string util functions for... utils.c */ int auxutilTokenizeString(ShortLivedHeap *slh, diff --git a/zis-aux/src/aux-utils.c b/zis-aux/src/aux-utils.c index db2210163..1f1d7ca6a 100644 --- a/zis-aux/src/aux-utils.c +++ b/zis-aux/src/aux-utils.c @@ -231,7 +231,7 @@ static void initLogMessagePrefix(LogMessagePrefix *prefix) { #define PREFIXED_LINE_MAX_COUNT 1000 #define PREFIXED_LINE_MAX_MSG_LENGTH 4096 -void auxutilPrintWithPrefix(LoggingContext *context, LoggingComponent *component, +void auxutilPrintWithPrefix(LoggingContext *context, LoggingComponent *component, char* path, int line, int level, uint64 compID, void *data, char *formatString, va_list argList) { char messageBuffer[PREFIXED_LINE_MAX_MSG_LENGTH]; @@ -266,7 +266,7 @@ void auxutilPrintWithPrefix(LoggingContext *context, LoggingComponent *component #define DUMP_MSG_ID ZIS_LOG_DUMP_MSG_ID char *auxutilDumpWithEmptyMessageID(char *workBuffer, int workBufferSize, - void *data, int dataSize, int lineNumber) { + void *data, int dataSize, int lineNumber, char* path, int line) { int formatWidth = 16; int index = lineNumber * formatWidth; From 6c41c011a8c9823a971f5fec27dc46277e69a5c7 Mon Sep 17 00:00:00 2001 From: sakeerthy Date: Thu, 27 Feb 2020 22:38:56 -0500 Subject: [PATCH 2/6] removed some constants Signed-off-by: sakeerthy --- c/zssLogging.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/c/zssLogging.c b/c/zssLogging.c index b385efc5d..4b94ab64c 100644 --- a/c/zssLogging.c +++ b/c/zssLogging.c @@ -48,6 +48,8 @@ bool isLogLevelValid(int level) { #define PREFIXED_LINE_MAX_COUNT 1000 #define PREFIXED_LINE_MAX_MSG_LENGTH 4096 #define LOG_MSG_PREFIX_SIZE 57 +#define LOCATION_PREFIX_PADDING 7 +#define LOCATION_SUFFIX_PADDING 5 typedef struct LogMessagePrefix_tag { char text[LOG_MSG_PREFIX_SIZE]; @@ -148,17 +150,17 @@ static void getLocationData(char *path, int line, char **locationInfo, uint64 co } } else if (compID > LOG_PROD_PLUGINS) { - snprintf(suffix,strlen(component->name),"%s",(strrchr(component->name, '/')+1)); // given more characters than it writes - snprintf(prefix,strlen(component->name)-strlen(suffix),"%s",component->name); + snprintf(suffix,sizeof(component->name),"%s",(strrchr(component->name, '/')+1)); // given more characters than it writes + snprintf(prefix,sizeof(component->name)-sizeof(suffix),"%s",component->name); } char *filename; filename = strrchr(path, '/'); // returns a pointer to the last occurence of '/' filename+=1; // formatting + prefix + suffix + filename + line number - int locationSize = 7 + strlen(prefix) + strlen(suffix) + strlen(filename) + 5; + int locationSize = LOCATION_PREFIX_PADDING + strlen(prefix) + strlen(suffix) + strlen(filename) + LOCATION_SUFFIX_PADDING; *locationInfo = (char*) safeMalloc(locationSize,"locationInfo"); - snprintf(*locationInfo,locationSize+1," (%s:%s,%s:%d) ",prefix,suffix,filename,line); + snprintf(*locationInfo,locationSize," (%s:%s,%s:%d) ",prefix,suffix,filename,line); } void initLogMessagePrefix(LogMessagePrefix *prefix, LoggingComponent *component, char* path, int line, int level, uint64 compID) { @@ -171,11 +173,11 @@ void initLogMessagePrefix(LogMessagePrefix *prefix, LoggingComponent *component, ACEE *acee; acee = getAddressSpaceAcee(); char user[7] = { 0 }; // wil this always be 7? - snprintf(user,7,acee->aceeuser+1); + snprintf(user,sizeof(user),acee->aceeuser+1); pthread_t threadID = pthread_self(); char thread[10]; - snprintf(thread,10,"%d",threadID); + snprintf(thread,sizeof(thread),"%d",threadID); char *logLevel; From aa2b71dd758084942cac9f0e5babc15d9e292e4c Mon Sep 17 00:00:00 2001 From: sakeerthy Date: Fri, 28 Feb 2020 14:32:13 -0500 Subject: [PATCH 3/6] Fixed some hard codings Signed-off-by: sakeerthy --- c/zssLogging.c | 83 ++++++++++++++++++++-------------------------- deps/zowe-common-c | 2 +- h/zssLogging.h | 21 ++++++++++++ 3 files changed, 58 insertions(+), 48 deletions(-) diff --git a/c/zssLogging.c b/c/zssLogging.c index 4b94ab64c..0b09ea973 100644 --- a/c/zssLogging.c +++ b/c/zssLogging.c @@ -45,12 +45,6 @@ bool isLogLevelValid(int level) { return TRUE; } -#define PREFIXED_LINE_MAX_COUNT 1000 -#define PREFIXED_LINE_MAX_MSG_LENGTH 4096 -#define LOG_MSG_PREFIX_SIZE 57 -#define LOCATION_PREFIX_PADDING 7 -#define LOCATION_SUFFIX_PADDING 5 - typedef struct LogMessagePrefix_tag { char text[LOG_MSG_PREFIX_SIZE]; } LogMessagePrefix; @@ -95,57 +89,57 @@ static void getLocationData(char *path, int line, char **locationInfo, uint64 co unsigned int id = compID & 0xFFFFFFFF; if(compID >= LOG_PROD_COMMON && compID < LOG_PROD_ZIS) { - snprintf(prefix,5,"_zcc"); + snprintf(prefix,sizeof(LOG_PREFIX_ZCC),LOG_PREFIX_ZCC); switch (id) { // most of these don't actally log, but are defined in logging.h - case LOG_COMP_ALLOC: snprintf(suffix,6,"alloc"); + case LOG_COMP_ALLOC: snprintf(suffix,sizeof(LOG_COMP_TEXT_ALLOC),LOG_COMP_TEXT_ALLOC); break; - case LOG_COMP_UTILS: snprintf(suffix,6,"utils"); + case LOG_COMP_UTILS: snprintf(suffix,sizeof(LOG_COMP_TEXT_UTILS),LOG_COMP_TEXT_UTILS); break; - case LOG_COMP_COLLECTIONS: snprintf(suffix,12,"collections"); + case LOG_COMP_COLLECTIONS: snprintf(suffix,sizeof(LOG_COMP_TEXT_COLLECTIONS),LOG_COMP_TEXT_COLLECTIONS); break; - case LOG_COMP_SERIALIZATION: snprintf(suffix,14,"serialization"); + case LOG_COMP_SERIALIZATION: snprintf(suffix,sizeof(LOG_COMP_TEXT_SERIALIZATION),LOG_COMP_TEXT_SERIALIZATION); break; - case LOG_COMP_ZLPARSER: snprintf(suffix,9,"zlparser"); + case LOG_COMP_ZLPARSER: snprintf(suffix,sizeof(LOG_COMP_TEXT_ZLPARSER),LOG_COMP_TEXT_ZLPARSER); break; - case LOG_COMP_ZLCOMPILER: snprintf(suffix,11,"zlcompiler"); + case LOG_COMP_ZLCOMPILER: snprintf(suffix,sizeof(LOG_COMP_TEXT_ZLCOMPILER),LOG_COMP_TEXT_ZLCOMPILER); break; - case LOG_COMP_ZLRUNTIME: snprintf(suffix,10,"zlruntime"); + case LOG_COMP_ZLRUNTIME: snprintf(suffix,sizeof(LOG_COMP_TEXT_ZLRUNTIME),LOG_COMP_TEXT_ZLRUNTIME); break; - case LOG_COMP_STCBASE: snprintf(suffix,8,"stcbase"); + case LOG_COMP_STCBASE: snprintf(suffix,sizeof(LOG_COMP_TEXT_STCBASE),LOG_COMP_TEXT_STCBASE); break; - case LOG_COMP_HTTPSERVER: snprintf(suffix,11,"httpserver"); + case LOG_COMP_HTTPSERVER: snprintf(suffix,sizeof(LOG_COMP_TEXT_HTTPSERVER),LOG_COMP_TEXT_HTTPSERVER); break; - case LOG_COMP_DISCOVERY: snprintf(suffix,10,"discovery"); + case LOG_COMP_DISCOVERY: snprintf(suffix,sizeof(LOG_COMP_TEXT_DISCOVERY),LOG_COMP_TEXT_DISCOVERY); break; - case LOG_COMP_DATASERVICE: snprintf(suffix,12,"dataservice"); + case LOG_COMP_DATASERVICE: snprintf(suffix,sizeof(LOG_COMP_TEXT_DATASERVICE),LOG_COMP_TEXT_DATASERVICE); break; - case LOG_COMP_CMS: snprintf(suffix,4,"cms"); + case LOG_COMP_CMS: snprintf(suffix,sizeof(LOG_COMP_TEXT_CMS),LOG_COMP_TEXT_CMS); break; - case 0xC0001: snprintf(suffix,4,"cms"); + case 0xC0001: snprintf(suffix,sizeof(LOG_COMP_TEXT_CMS),LOG_COMP_TEXT_CMS); break; case 0xC0002: snprintf(suffix,6,"cmspc"); break; - case LOG_COMP_LPA: snprintf(suffix,4,"lpa"); + case LOG_COMP_LPA: snprintf(suffix,sizeof(LOG_COMP_TEXT_LPA),LOG_COMP_TEXT_LPA); break; - case LOG_COMP_RESTDATASET: snprintf(suffix,12,"restdataset"); + case LOG_COMP_RESTDATASET: snprintf(suffix,sizeof(LOG_COMP_TEXT_RESTDATASET),LOG_COMP_TEXT_RESTDATASET); break; - case LOG_COMP_RESTFILE: snprintf(suffix,9,"restfile"); + case LOG_COMP_RESTFILE: snprintf(suffix,sizeof(LOG_COMP_TEXT_RESTFILE),LOG_COMP_TEXT_RESTFILE); break; } } else if (compID >= LOG_PROD_ZIS && compID < LOG_PROD_ZSS) { - snprintf(prefix,5,"_zis"); + snprintf(prefix,sizeof(LOG_PREFIX_ZIS),LOG_PREFIX_ZIS); } else if (compID >= LOG_PROD_ZSS && compID < LOG_PROD_PLUGINS ) { - snprintf(prefix,5,"_zss"); + snprintf(prefix,sizeof(LOG_PREFIX_ZSS),LOG_PREFIX_ZSS); switch (id) { - case LOG_COMP_ID_ZSS: snprintf(suffix,4,"zss"); + case LOG_COMP_ID_ZSS: snprintf(suffix,sizeof(LOG_COMP_ID_TEXT_ZSS),LOG_COMP_ID_TEXT_ZSS); break; - case LOG_COMP_ID_CTDS: snprintf(suffix,5,"ctds"); + case LOG_COMP_ID_CTDS: snprintf(suffix,sizeof(LOG_COMP_ID_TEXT_CTDS),LOG_COMP_ID_TEXT_CTDS); break; - case LOG_COMP_ID_SECURITY: snprintf(suffix,9,"security"); + case LOG_COMP_ID_SECURITY: snprintf(suffix,sizeof(LOG_COMP_ID_TEXT_SECURITY),LOG_COMP_ID_TEXT_SECURITY); break; - case LOG_COMP_ID_UNIXFILE: snprintf(suffix,9, "unixfile"); + case LOG_COMP_ID_UNIXFILE: snprintf(suffix,sizeof(LOG_COMP_ID_TEXT_UNIXFILE), LOG_COMP_ID_TEXT_UNIXFILE); break; } } @@ -160,47 +154,43 @@ static void getLocationData(char *path, int line, char **locationInfo, uint64 co // formatting + prefix + suffix + filename + line number int locationSize = LOCATION_PREFIX_PADDING + strlen(prefix) + strlen(suffix) + strlen(filename) + LOCATION_SUFFIX_PADDING; *locationInfo = (char*) safeMalloc(locationSize,"locationInfo"); - snprintf(*locationInfo,locationSize," (%s:%s,%s:%d) ",prefix,suffix,filename,line); + snprintf(*locationInfo,locationSize,"(%s:%s,%s:%d)",prefix,suffix,filename,line); } -void initLogMessagePrefix(LogMessagePrefix *prefix, LoggingComponent *component, char* path, int line, int level, uint64 compID) { +static void initZssLogMessagePrefix(LogMessagePrefix *prefix, LoggingComponent *component, char* path, int line, int level, uint64 compID) { LogTimestamp currentTime; getCurrentLogTimestamp(¤tTime); ASCB *ascb = getASCB(); char *jobName = getASCBJobname(ascb); -// TCB *tcb = getTCB(); ACEE *acee; acee = getAddressSpaceAcee(); - char user[7] = { 0 }; // wil this always be 7? + char user[7] = { 0 }; // will this always be 7? snprintf(user,sizeof(user),acee->aceeuser+1); - pthread_t threadID = pthread_self(); char thread[10]; snprintf(thread,sizeof(thread),"%d",threadID); - - char *logLevel; + char logLevel[16]; switch(level) { - case 0: snprintf(logLevel,7,"SEVERE"); + case 0: snprintf(logLevel,sizeof(LOG_LEVEL_SERVER),LOG_LEVEL_SERVER); break; - case 1: snprintf(logLevel,8,"WARN"); + case 1: snprintf(logLevel,sizeof(LOG_LEVEL_WARN),LOG_LEVEL_WARN); break; - case 2: snprintf(logLevel,5,"INFO"); + case 2: snprintf(logLevel,sizeof(LOG_LEVEL_INFO),LOG_LEVEL_INFO); break; - case 3: snprintf(logLevel,5,"DEBUG"); + case 3: snprintf(logLevel,sizeof(LOG_LEVEL_DEBUG),LOG_LEVEL_DEBUG); break; - case 4: snprintf(logLevel,6,"DEBUG"); + case 4: snprintf(logLevel,sizeof(LOG_LEVEL_DEBUG),LOG_LEVEL_DEBUG); break; - case 5: snprintf(logLevel,7,"TRACE"); + case 5: snprintf(logLevel,sizeof(LOG_LEVEL_TRACE),LOG_LEVEL_TRACE); break; } char *locationInfo; // largest possible variation in size getLocationData(path,line,&locationInfo,compID,component); // location info is allocated in getLocationData - - snprintf(prefix->text, sizeof(prefix->text), "%22.22s <%8.8s:%s> %s %s (%s) ", currentTime.text, jobName, thread, user, logLevel, locationInfo); + snprintf(prefix->text, sizeof(prefix->text), "%22.22s <%8.8s:%s> %s %s %s ", currentTime.text, jobName, thread, user, logLevel, locationInfo); prefix->text[sizeof(prefix->text) - 1] = ' '; } @@ -212,7 +202,7 @@ void zssFormatter(LoggingContext *context, LoggingComponent *component, char* pa messageLength = sizeof(messageBuffer) - 1; } - LogMessagePrefix prefix; + LogMessagePrefix prefix = {0}; char *nextLine = messageBuffer; char *lastLine = messageBuffer + messageLength; @@ -224,12 +214,11 @@ void zssFormatter(LoggingContext *context, LoggingComponent *component, char* pa size_t nextLineLength = endOfLine ? (endOfLine - nextLine) : (lastLine - nextLine); memset(prefix.text, ' ', sizeof(prefix.text)); if (lineIdx == 0) { - initLogMessagePrefix(&prefix, component, path, line, level, compID); + initZssLogMessagePrefix(&prefix, component, path, line, level, compID); } printf("%.*s%.*s\n", sizeof(prefix.text), prefix.text, nextLineLength, nextLine); nextLine += (nextLineLength + 1); } - } diff --git a/deps/zowe-common-c b/deps/zowe-common-c index 958767030..98252ff85 160000 --- a/deps/zowe-common-c +++ b/deps/zowe-common-c @@ -1 +1 @@ -Subproject commit 9587670300dfb59bb03465358e41737c8ee2975a +Subproject commit 98252ff85f3b217084f63ebf743064534ac3057b diff --git a/h/zssLogging.h b/h/zssLogging.h index 73cafe152..7bd36665f 100644 --- a/h/zssLogging.h +++ b/h/zssLogging.h @@ -18,6 +18,27 @@ #define LOG_COMP_ID_SECURITY 0x008F000300030000 #define LOG_COMP_ID_UNIXFILE 0x008F000300040000 +#define LOG_COMP_ID_TEXT_ZSS "zss" +#define LOG_COMP_ID_TEXT_CTDS "ctds" +#define LOG_COMP_ID_TEXT_SECURITY "security" +#define LOG_COMP_ID_TEXT_UNIXFILE "unixfile" + +#define LOG_PREFIX_ZSS "_zss" +#define LOG_PREFIX_ZCC "_zcc" +#define LOG_PREFIX_ZIS "_zis" + +#define LOG_LEVEL_SERVER "SEVERE" +#define LOG_LEVEL_WARN "WARN" +#define LOG_LEVEL_INFO "INFO" +#define LOG_LEVEL_DEBUG "DEBUG" +#define LOG_LEVEL_TRACE "TRACE" + +#define PREFIXED_LINE_MAX_COUNT 1000 +#define PREFIXED_LINE_MAX_MSG_LENGTH 4096 +#define LOG_MSG_PREFIX_SIZE 1000 +#define LOCATION_PREFIX_PADDING 7 +#define LOCATION_SUFFIX_PADDING 5 + bool isLogLevelValid(int level); void zssFormatter(LoggingContext *context, LoggingComponent *component, char* path, int line, int level, uint64 compID, void *data, char *formatString, va_list argList); From 3928564c79aa04f0deedf583798b3e830e0898f5 Mon Sep 17 00:00:00 2001 From: sakeerthy Date: Fri, 28 Feb 2020 14:47:26 -0500 Subject: [PATCH 4/6] Removed unneeded passed args Signed-off-by: sakeerthy --- deps/zowe-common-c | 2 +- zis-aux/include/aux-utils.h | 2 +- zis-aux/src/aux-utils.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deps/zowe-common-c b/deps/zowe-common-c index 98252ff85..994754bec 160000 --- a/deps/zowe-common-c +++ b/deps/zowe-common-c @@ -1 +1 @@ -Subproject commit 98252ff85f3b217084f63ebf743064534ac3057b +Subproject commit 994754bec961c074a202270855f296c6799a97e0 diff --git a/zis-aux/include/aux-utils.h b/zis-aux/include/aux-utils.h index 7a59c80a2..2906748ab 100644 --- a/zis-aux/include/aux-utils.h +++ b/zis-aux/include/aux-utils.h @@ -88,7 +88,7 @@ ZOWE_PRAGMA_PACK_RESET void auxutilPrintWithPrefix(LoggingContext *context, LoggingComponent *component, char* path, int line, int level, uint64 compID, void *data, char *formatString, va_list argList); char *auxutilDumpWithEmptyMessageID(char *workBuffer, int workBufferSize, - void *data, int dataSize, int lineNumber, char* path, int line); + void *data, int dataSize, int lineNumber); /* Misc string util functions for... utils.c */ int auxutilTokenizeString(ShortLivedHeap *slh, diff --git a/zis-aux/src/aux-utils.c b/zis-aux/src/aux-utils.c index 1f1d7ca6a..a80ce98e5 100644 --- a/zis-aux/src/aux-utils.c +++ b/zis-aux/src/aux-utils.c @@ -266,7 +266,7 @@ void auxutilPrintWithPrefix(LoggingContext *context, LoggingComponent *component #define DUMP_MSG_ID ZIS_LOG_DUMP_MSG_ID char *auxutilDumpWithEmptyMessageID(char *workBuffer, int workBufferSize, - void *data, int dataSize, int lineNumber, char* path, int line) { + void *data, int dataSize, int lineNumber) { int formatWidth = 16; int index = lineNumber * formatWidth; From c6e04c818a1951581bda6c4720a91ca34192b742 Mon Sep 17 00:00:00 2001 From: sakeerthy Date: Fri, 28 Feb 2020 14:56:30 -0500 Subject: [PATCH 5/6] Fixed some hard coded values Signed-off-by: sakeerthy --- c/zssLogging.c | 22 +++++++++++----------- h/zssLogging.h | 13 ++++++++++++- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/c/zssLogging.c b/c/zssLogging.c index 0b09ea973..807430eda 100644 --- a/c/zssLogging.c +++ b/c/zssLogging.c @@ -84,8 +84,8 @@ static void getCurrentLogTimestamp(LogTimestamp *timestamp) { static void getLocationData(char *path, int line, char **locationInfo, uint64 compID, LoggingComponent *component) { - char prefix[128]; - char suffix[128]; + char prefix[PREFIX_SUFFIX_SIZE]; + char suffix[PREFIX_SUFFIX_SIZE]; unsigned int id = compID & 0xFFFFFFFF; if(compID >= LOG_PROD_COMMON && compID < LOG_PROD_ZIS) { @@ -165,25 +165,25 @@ static void initZssLogMessagePrefix(LogMessagePrefix *prefix, LoggingComponent * ACEE *acee; acee = getAddressSpaceAcee(); - char user[7] = { 0 }; // will this always be 7? + char user[USER_SIZE] = { 0 }; snprintf(user,sizeof(user),acee->aceeuser+1); pthread_t threadID = pthread_self(); - char thread[10]; + char thread[THREAD_SIZE]; snprintf(thread,sizeof(thread),"%d",threadID); - char logLevel[16]; + char logLevel[LOG_LEVEL_MAX_SIZE]; switch(level) { - case 0: snprintf(logLevel,sizeof(LOG_LEVEL_SERVER),LOG_LEVEL_SERVER); + case LOG_LEVEL_ID_SEVERE: snprintf(logLevel,sizeof(LOG_LEVEL_SEVERE),LOG_LEVEL_SEVERE); break; - case 1: snprintf(logLevel,sizeof(LOG_LEVEL_WARN),LOG_LEVEL_WARN); + case LOG_LEVEL_ID_WARN: snprintf(logLevel,sizeof(LOG_LEVEL_WARN),LOG_LEVEL_WARN); break; - case 2: snprintf(logLevel,sizeof(LOG_LEVEL_INFO),LOG_LEVEL_INFO); + case LOG_LEVEL_ID_INFO: snprintf(logLevel,sizeof(LOG_LEVEL_INFO),LOG_LEVEL_INFO); break; - case 3: snprintf(logLevel,sizeof(LOG_LEVEL_DEBUG),LOG_LEVEL_DEBUG); + case LOG_LEVEL_ID_DEBUG: snprintf(logLevel,sizeof(LOG_LEVEL_DEBUG),LOG_LEVEL_DEBUG); break; - case 4: snprintf(logLevel,sizeof(LOG_LEVEL_DEBUG),LOG_LEVEL_DEBUG); + case LOG_LEVEL_ID_DEBUG2: snprintf(logLevel,sizeof(LOG_LEVEL_DEBUG),LOG_LEVEL_DEBUG); break; - case 5: snprintf(logLevel,sizeof(LOG_LEVEL_TRACE),LOG_LEVEL_TRACE); + case LOG_LEVEL_ID_TRACE: snprintf(logLevel,sizeof(LOG_LEVEL_TRACE),LOG_LEVEL_TRACE); break; } diff --git a/h/zssLogging.h b/h/zssLogging.h index 7bd36665f..993b235c9 100644 --- a/h/zssLogging.h +++ b/h/zssLogging.h @@ -27,17 +27,28 @@ #define LOG_PREFIX_ZCC "_zcc" #define LOG_PREFIX_ZIS "_zis" -#define LOG_LEVEL_SERVER "SEVERE" +#define LOG_LEVEL_SEVERE "SEVERE" #define LOG_LEVEL_WARN "WARN" #define LOG_LEVEL_INFO "INFO" #define LOG_LEVEL_DEBUG "DEBUG" #define LOG_LEVEL_TRACE "TRACE" +#define LOG_LEVEL_ID_SEVERE 0 +#define LOG_LEVEL_ID_WARN 1 +#define LOG_LEVEL_ID_INFO 2 +#define LOG_LEVEL_ID_DEBUG 3 +#define LOG_LEVEL_ID_DEBUG2 4 +#define LOG_LEVEL_ID_TRACE 5 + #define PREFIXED_LINE_MAX_COUNT 1000 #define PREFIXED_LINE_MAX_MSG_LENGTH 4096 #define LOG_MSG_PREFIX_SIZE 1000 #define LOCATION_PREFIX_PADDING 7 #define LOCATION_SUFFIX_PADDING 5 +#define USER_SIZE 7 //Will this always be 7? +#define THREAD_SIZE 10 +#define LOG_LEVEL_MAX_SIZE 16 +#define PREFIX_SUFFIX_SIZE 128 bool isLogLevelValid(int level); void zssFormatter(LoggingContext *context, LoggingComponent *component, char* path, int line, int level, uint64 compID, void *data, char *formatString, va_list argList); From 8329a284ba3fa90633d749306d53a64f29cb55fd Mon Sep 17 00:00:00 2001 From: sakeerthy Date: Fri, 28 Feb 2020 15:07:33 -0500 Subject: [PATCH 6/6] pointing to zowe common c branch for same issue Signed-off-by: sakeerthy --- deps/zowe-common-c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/zowe-common-c b/deps/zowe-common-c index 994754bec..e74f43c11 160000 --- a/deps/zowe-common-c +++ b/deps/zowe-common-c @@ -1 +1 @@ -Subproject commit 994754bec961c074a202270855f296c6799a97e0 +Subproject commit e74f43c11b98e0381859152cf26362fd7e528c9c