Skip to content

Commit

Permalink
HPCC-19389 Expose global and local IDs to ECL via lib_logging
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
afishbeck committed Jul 25, 2018
1 parent 102f202 commit dfcf0af
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ecllibrary/std/system/Log.ecl
Expand Up @@ -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 change: 1 addition & 0 deletions plugins/logging/CMakeLists.txt
Expand Up @@ -31,6 +31,7 @@ set ( SRCS
include_directories (
./../../system/include
./../../system/jlib
./../../rtl/include
)

ADD_DEFINITIONS( -D_USRDLL -DLOGGING_EXPORTS )
Expand Down
13 changes: 13 additions & 0 deletions plugins/logging/logging.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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 changes: 3 additions & 0 deletions plugins/logging/logging.hpp
Expand Up @@ -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

0 comments on commit dfcf0af

Please sign in to comment.