Bläddra i källkod

HPCC-19389 Expose global and local IDs to ECL via lib_logging

Global and Local IDs will be accessable to the ECL developer.

For Example:

output(std.system.log.getGlobalId(), named('globalid'));
output(std.system.log.getLocalId(), named('localid'));

Signed-off-by: Anthony Fishbeck <anthony.fishbeck@lexisnexis.com>
Anthony Fishbeck 7 år sedan
förälder
incheckning
dfcf0af40d

+ 17 - 0
ecllibrary/std/system/Log.ecl

@@ -49,4 +49,21 @@ EXPORT addWorkunitWarning(varstring text, unsigned code=0) := lib_logging.Loggin
 
 EXPORT addWorkunitError(varstring text, unsigned code=0) := lib_logging.Logging.addWorkunitError(text, code, 2);
 
+/*
+ * Gets the Global Id associated with the current query or workunit.
+ *
+ * Returns the Global Id
+ */
+
+EXPORT getGlobalId() := lib_logging.Logging.getGlobalId();
+
+/*
+ * Gets the Local Id associated with the current query or workunit.
+ *
+ * Returns the Local Id
+ */
+
+EXPORT getLocalId() := lib_logging.Logging.getLocalId();
+
+
 END;

+ 1 - 0
plugins/logging/CMakeLists.txt

@@ -31,6 +31,7 @@ set (    SRCS
 include_directories ( 
          ./../../system/include 
          ./../../system/jlib 
+         ./../../rtl/include
     )
 
 ADD_DEFINITIONS( -D_USRDLL -DLOGGING_EXPORTS )

+ 13 - 0
plugins/logging/logging.cpp

@@ -34,6 +34,8 @@ static const char * EclDefinition =
 "  addWorkunitInformation(const varstring txt, unsigned code=0, unsigned severity=0, const varstring source='user') : ctxmethod,action,entrypoint='addWuException'; \n"
 "  addWorkunitWarning(const varstring txt, unsigned code=0, unsigned severity=1, const varstring source='user') : ctxmethod,action,entrypoint='addWuException'; \n"
 "  addWorkunitError(const varstring txt, unsigned code=0, unsigned severity=2, const varstring source='user') : ctxmethod,action,entrypoint='addWuException'; \n"
+"  varstring getGlobalId() : c,context,entrypoint='logGetGlobalId'; \n"
+"  varstring getLocalId() : c,context,entrypoint='logGetLocalId'; \n"
 "END;";
 
 LOGGING_API bool getECLPluginDefinition(ECLPluginDefinitionBlock *pb) 
@@ -61,3 +63,14 @@ LOGGING_API void LOGGING_CALL logDbgLog(unsigned srcLen, const char * src)
     DBGLOG("%.*s", srcLen, src);
 }
 
+LOGGING_API char *  LOGGING_CALL logGetGlobalId(ICodeContext *ctx)
+{
+    StringBuffer ret = ctx->queryContextLogger().queryGlobalId();
+    return ret.detach();
+}
+
+LOGGING_API char *  LOGGING_CALL logGetLocalId(ICodeContext *ctx)
+{
+    StringBuffer ret = ctx->queryContextLogger().queryLocalId();
+    return ret.detach();
+}

+ 3 - 0
plugins/logging/logging.hpp

@@ -31,10 +31,13 @@
 #endif
 
 #include "hqlplugins.hpp"
+#include "eclhelper.hpp"
 
 extern "C" {
 LOGGING_API bool getECLPluginDefinition(ECLPluginDefinitionBlock *pb);
 LOGGING_API void LOGGING_CALL logDbgLog(unsigned srcLen, const char * src);
+LOGGING_API char * LOGGING_CALL logGetGlobalId(ICodeContext *ctx);
+LOGGING_API char * LOGGING_CALL logGetLocalId(ICodeContext *ctx);
 }
 
 #endif