diff --git a/c/crossmemory.c b/c/crossmemory.c index abd405155..260b80d0f 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -281,7 +281,7 @@ void wtoPrintf2(int consoleID, CART cart, char *formatString, ...) { } -static void printWithPrefix(LoggingContext *context, LoggingComponent *component, void *data, char *formatString, va_list argList); +static void printWithPrefix(LoggingContext *context, LoggingComponent *component, char* path, int line, int level, uint64 compID, void *data, char *formatString, va_list argList); static char *dumpWithEmptyMessageID(char *workBuffer, int workBufferSize, void *data, int dataSize, int lineNumber); void cmsInitializeLogging() { @@ -503,7 +503,7 @@ static void initLogMessagePrefix(LogMessagePrefix *prefix) { #define PREFIXED_LINE_MAX_COUNT 1000 #define PREFIXED_LINE_MAX_MSG_LENGTH 4096 -static void printWithPrefix(LoggingContext *context, LoggingComponent *component, void *data, char *formatString, va_list argList) { +static void printWithPrefix(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); @@ -2808,12 +2808,13 @@ static void printDisplayConfigCommandResponse(CrossMemoryServer *server, CMSWTOR int consoleID = routeInfo->consoleID; CrossMemoryServerGlobalArea *globalArea = server->globalArea; - zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_INFO, #ifdef CROSS_MEMORY_SERVER_DEBUG - CMS_LOG_DISP_CMD_RESULT_MSG"Server name - \'%16.16s\' (debug mode)\n" + char* formatStringPrefix = CMS_LOG_DISP_CMD_RESULT_MSG"Server name - \'%16.16s\' (debug mode)\n"; #else - CMS_LOG_DISP_CMD_RESULT_MSG"Server name - \'%16.16s\'\n" + char* formatStringPrefix = CMS_LOG_DISP_CMD_RESULT_MSG"Server name - \'%16.16s\'\n"; #endif + + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_INFO, strcat(formatStringPrefix, " Global area address = 0x%p\n" " Version = %d\n" " Key = %d\n" @@ -2828,7 +2829,7 @@ static void printDisplayConfigCommandResponse(CrossMemoryServer *server, CMSWTOR " PC-ss seq number = 0x%08X\n" " PC-cp PC number = 0x%08X\n" " PC-cp seq number = 0x%08X\n" - " PC log level = %d\n", + " PC log level = %d\n"), server->name.nameSpacePadded, globalArea, globalArea->version, diff --git a/c/logging.c b/c/logging.c index 82561a5a9..042648b3a 100644 --- a/c/logging.c +++ b/c/logging.c @@ -37,6 +37,11 @@ #include "logging.h" #include "printables_for_dump.h" +#include "timeutls.h" +#include "zos.h" +#include "openprims.h" +#include "zssLogging.h" + #ifdef __ZOWE_OS_ZOS #include "le.h" #endif @@ -311,7 +316,7 @@ static void lastResortLog(char *s){ } /* default dumper, based on dumpBufferToStream from utils.c */ -static char *standardDumperFunction(char *workBuffer, int workBufferSize, +char *standardDumperFunction(char *workBuffer, int workBufferSize, void *data, int dataSize, int lineNumber){ int formatWidth = 32; @@ -455,7 +460,7 @@ LoggingDestination *logConfigureDestination2(LoggingContext *context, return destination; } -void printStdout(LoggingContext *context, LoggingComponent *component, void *data, char *formatString, va_list argList){ +void printStdout(LoggingContext *context, LoggingComponent *component, char* path, int line, int level, uint64 compID, void *data, char *formatString, va_list argList){ #ifdef METTLE printf("broken printf in logging.c\n"); #else @@ -463,7 +468,7 @@ void printStdout(LoggingContext *context, LoggingComponent *component, void *dat #endif } -void printStderr(LoggingContext *context, LoggingComponent *component, void *data, char *formatString, va_list argList){ +void printStderr(LoggingContext *context, LoggingComponent *component, char* path, int line, int level, uint64 compID, void *data, char *formatString, va_list argList){ #ifdef METTLE printf("broken printf in logging.c\n"); #else @@ -647,7 +652,10 @@ int logGetLevel(LoggingContext *context, uint64 compID){ return component ? component->currentDetailLevel : ZOWE_LOG_NA; } -void zowelog(LoggingContext *context, uint64 compID, int level, char *formatString, ...){ + + +void _zowelog(LoggingContext *context, uint64 compID, char* path, int line, int level, char *formatString, ...){ +//void zowelog(LoggingContext *context, uint64 compID, int level, char *formatString, ...){ if (logShouldTrace(context, compID, level) == FALSE) { return; @@ -688,7 +696,7 @@ void zowelog(LoggingContext *context, uint64 compID, int level, char *formatStri /* here, pass to a var-args handler */ va_start(argPointer, formatString); - destination->handler(context,component,destination->data,formatString,argPointer); + destination->handler(context,component,path,line,level,compID,destination->data,formatString,argPointer); va_end(argPointer); } @@ -698,14 +706,16 @@ void zowelog(LoggingContext *context, uint64 compID, int level, char *formatStri static void printToDestination(LoggingDestination *destination, struct LoggingContext_tag *context, LoggingComponent *component, + char* path, int line, + int level, uint64 compID, void *data, char *formatString, ...){ va_list argPointer; va_start(argPointer, formatString); - destination->handler(context,component,destination->data,formatString,argPointer); + destination->handler(context,component,path,line,level,compID,destination->data,formatString,argPointer); va_end(argPointer); } -void zowedump(LoggingContext *context, uint64 compID, int level, void *data, int dataSize){ +void _zowedump(LoggingContext *context, uint64 compID, int level, void *data, int dataSize, char* path, int line){ if (logShouldTrace(context, compID, level) == FALSE) { return; @@ -746,7 +756,7 @@ void zowedump(LoggingContext *context, uint64 compID, int level, void *data, int for (int i = 0; ; i++){ char *result = destination->dumper(workBuffer, sizeof(workBuffer), data, dataSize, i); if (result != NULL){ - printToDestination(destination, context, component, destination->data, "%s\n", result); + printToDestination(destination, context, component, path, line, level, compID, destination->data, "%s\n", result); } else { break; diff --git a/h/logging.h b/h/logging.h index 69816a9f5..5c3037215 100644 --- a/h/logging.h +++ b/h/logging.h @@ -93,6 +93,23 @@ ZOWE_PRAGMA_PACK_RESET #define LOG_COMP_RESTDATASET 0x008F0001000E0000LLU #define LOG_COMP_RESTFILE 0x008F0001000F0000LLU + +#define LOG_COMP_TEXT_ALLOC "alloc" +#define LOG_COMP_TEXT_UTILS "utils" +#define LOG_COMP_TEXT_COLLECTIONS "collections" +#define LOG_COMP_TEXT_SERIALIZATION "serialization" +#define LOG_COMP_TEXT_ZLPARSER "zlparser" +#define LOG_COMP_TEXT_ZLCOMPILER "zlcompiler" +#define LOG_COMP_TEXT_ZLRUNTIME "zlruntime" +#define LOG_COMP_TEXT_STCBASE "stcbase" +#define LOG_COMP_TEXT_HTTPSERVER "httpserver" +#define LOG_COMP_TEXT_DISCOVERY "discovery" +#define LOG_COMP_TEXT_DATASERVICE "dataservice" +#define LOG_COMP_TEXT_CMS "cms" +#define LOG_COMP_TEXT_LPA "lpa" +#define LOG_COMP_TEXT_RESTDATASET "restdataset" +#define LOG_COMP_TEXT_RESTFILE "restfile" + #define LOG_DEST_DEV_NULL 0x008F0000 #define LOG_DEST_PRINTF_STDOUT 0x008F0001 #define LOG_DEST_PRINTF_STDERR 0x008F0002 @@ -100,7 +117,10 @@ ZOWE_PRAGMA_PACK_RESET struct LoggingContext_tag; typedef void (*LogHandler)(struct LoggingContext_tag *context, - LoggingComponent *component, + LoggingComponent *component, + char* path, int line, + int level, + uint64 compID, void *data, char *formatString, va_list argList); @@ -297,15 +317,23 @@ bool logShouldTraceInternal(LoggingContext *context, uint64 componentID, int lev /* this log message will be sent to the destination associated to the component */ +void _zowelog(LoggingContext *context, uint64 compID, char* path, int line, int level, char *formatString, ...); +void _zowedump(LoggingContext *context, uint64 compID, int level, void *data, int dataSize, char* path, int line); -void zowelog(LoggingContext *context, uint64 compID, int level, char *formatString, ...); -void zowedump(LoggingContext *context, uint64 compID, int level, void *data, int dataSize); - +char *standardDumperFunction(char *workBuffer, int workBufferSize, + void *data, int dataSize, int lineNumber); #define LOGCHECK(context,component,level) \ ((component > MAX_LOGGING_COMPONENTS) ? \ (context->applicationComponents[component].level >= level) : \ (context->coreComponents[component].level >= level) ) + +#define zowelog(context, compID, level, formatString, ...) \ + _zowelog(context, compID, __FILE__, __LINE__, level, formatString, ##__VA_ARGS__); + +#define zowedump(context, compID, level, data, dataSize) \ + _zowedump(context, compID, level, data, dataSize, __FILE__, __LINE__); + LoggingDestination *logConfigureDestination(LoggingContext *context, unsigned int id, char *name, @@ -332,8 +360,8 @@ int logGetLevel(LoggingContext *context, uint64 compID); extern int logSetExternalContext(LoggingContext *context); extern LoggingContext *logGetExternalContext(); -void printStdout(LoggingContext *context, LoggingComponent *component, void *data, char *formatString, va_list argList); -void printStderr(LoggingContext *context, LoggingComponent *component, void *data, char *formatString, va_list argList); +void printStdout(LoggingContext *context, LoggingComponent *component, char* path, int line, int level, uint64 compID, void *data, char *formatString, va_list argList); +void printStderr(LoggingContext *context, LoggingComponent *component, char* path, int line, int level, uint64 compID, void *data, char *formatString, va_list argList); #endif