Skip to content

Commit

Permalink
HPCC-31775 Changes following review
Browse files Browse the repository at this point in the history
Signed-off-by: Shamser Ahmed <[email protected]>
  • Loading branch information
shamser committed Dec 9, 2024
1 parent 0ffdd7f commit acb2cc7
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 32 deletions.
5 changes: 3 additions & 2 deletions dali/base/daclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ bool initClientProcess(IGroup *servergrp, DaliClientRole role, unsigned mpport,
covengrp->Release();
queryLogMsgManager()->setSession(myProcessSession());

if (getGlobalConfigSP()->getPropBool("@enableGlobalSysLog", true))
UseDaliForOperatorMessages();
if (getComponentConfigSP()->getPropBool("logging/@enableGlobalSysLog") || getGlobalConfigSP()->getPropBool("logging/@enableGlobalSysLog"))
UseDaliForOperatorMessages(true);

if (!isContainerized()) // The Environment is bare-metal only
{
// auto install environment monitor for server roles
Expand Down
26 changes: 14 additions & 12 deletions dali/base/sysinfologger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ unsigned deleteOlderThanLogSysInfoMsg(bool visibleOnly, bool hiddenOnly, unsigne
return count;
}

class DaliMsgLoggerHandler : public CInterfaceOf<ILogMsgHandler>
class DaliMsgLoggerHandler : public CSimpleInterfaceOf<ILogMsgHandler>
{
public:
DaliMsgLoggerHandler(unsigned _messageFields=MSGFIELD_all) : messageFields(_messageFields)
Expand All @@ -708,7 +708,7 @@ class DaliMsgLoggerHandler : public CInterfaceOf<ILogMsgHandler>
unsigned __int64 ts = sysInfo.queryTime() * 1000000 + sysInfo.queryUSecs();
logSysInfoError(msg.queryCategory(), msg.queryCode(), queryComponentName(), msg.queryText(), ts);
}
virtual bool needsPrep() const override
virtual bool needsPrep() const override
{
return false;
}
Expand Down Expand Up @@ -746,23 +746,25 @@ class DaliMsgLoggerHandler : public CInterfaceOf<ILogMsgHandler>
unsigned messageFields = MSGFIELD_all;
};

static Owned<ILogMsgHandler> msgHandler;

void UseDaliForOperatorMessages(bool use)
{
static ILogMsgHandler *msgHandler=NULL;
if (use==(msgHandler!=NULL))
return;
if (use)
{
msgHandler = getDaliMsgLoggerHandler();
ILogMsgFilter * operatorFilter = getCategoryLogMsgFilter(MSGAUD_operator,
MSGCLS_disaster|MSGCLS_error|MSGCLS_warning,
WarnMsgThreshold);
queryLogMsgManager()->addMonitorOwn(msgHandler, operatorFilter);
if (!msgHandler)
{
msgHandler.setown(getDaliMsgLoggerHandler());
ILogMsgFilter * operatorFilter = getCategoryLogMsgFilter(MSGAUD_operator,
MSGCLS_disaster|MSGCLS_error|MSGCLS_warning,
WarnMsgThreshold);
queryLogMsgManager()->addMonitor(msgHandler, operatorFilter);
}
}
else
else if (msgHandler)
{
queryLogMsgManager()->removeMonitor(msgHandler);
msgHandler = NULL;
msgHandler.clear();
}
}

Expand Down
2 changes: 1 addition & 1 deletion dali/base/sysinfologger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,5 @@ SYSINFO_API bool deleteLogSysInfoMsg(unsigned __int64 msgId, const char *source=
SYSINFO_API unsigned deleteOlderThanLogSysInfoMsg(bool visibleOnly, bool hiddenOnly, unsigned year, unsigned month, unsigned day, const char *source=nullptr);

SYSINFO_API ILogMsgHandler * getDaliMsgLoggerHandler();
SYSINFO_API void UseDaliForOperatorMessages(bool use=true);
SYSINFO_API void UseDaliForOperatorMessages(bool use);
#endif
39 changes: 24 additions & 15 deletions esp/services/ws_workunits/ws_wudetails.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "jstatcodes.h"
#include "sysinfologger.hpp"

#define COMPONENT_NOTE_MASK 0xFFFFFC0
#define COMPONENT_NOTE_MASK 0x80000000

typedef std::pair<WuAttr, StringBuffer> AttribValuePair;
bool operator==(const AttribValuePair & p1, const AttribValuePair & p2)
Expand Down Expand Up @@ -517,21 +517,30 @@ void WUDetails::processRequest(IEspWUDetailsRequest &req, IEspWUDetailsResponse
}
Owned<ISysInfoLoggerMsgFilter> msgFilter = createSysInfoLoggerMsgFilter();
msgFilter->setVisibleOnly();
Owned<ISysInfoLoggerMsgIterator> msgIter = createSysInfoLoggerMsgIterator(msgFilter);
ForEach(*msgIter)
try
{
ISysInfoLoggerMsg & sysInfoMsg = msgIter->query();
Owned<IEspWUResponseNote> espWuResponseNote = createWUResponseNote("","");
StringBuffer tmpbuf;
encodeXML(sysInfoMsg.queryMsg(), tmpbuf, ENCODE_NEWLINES, strlen(sysInfoMsg.queryMsg()), true);
espWuResponseNote->setSource(sysInfoMsg.querySource());
espWuResponseNote->setMessage(tmpbuf.str());
espWuResponseNote->setErrorCode(sysInfoMsg.queryLogMsgCode());
espWuResponseNote->setSeverity(LogMsgClassToVarString(sysInfoMsg.queryClass()));
espWuResponseNote->setCost(0);
VStringBuffer idstr("%" I64F "u", sysInfoMsg.queryLogMsgId());
espWuResponseNote->setId(idstr.str());
espWuResponseNotes.append(*espWuResponseNote.getClear());
Owned<ISysInfoLoggerMsgIterator> msgIter = createSysInfoLoggerMsgIterator(msgFilter);
ForEach(*msgIter)
{
ISysInfoLoggerMsg & sysInfoMsg = msgIter->query();
Owned<IEspWUResponseNote> espWuResponseNote = createWUResponseNote("","");
StringBuffer tmpbuf;
encodeXML(sysInfoMsg.queryMsg(), tmpbuf, ENCODE_NEWLINES, strlen(sysInfoMsg.queryMsg()), true);
espWuResponseNote->setSource(sysInfoMsg.querySource());
espWuResponseNote->setMessage(tmpbuf.str());
espWuResponseNote->setErrorCode(sysInfoMsg.queryLogMsgCode());
espWuResponseNote->setSeverity(LogMsgClassToVarString(sysInfoMsg.queryClass()));
espWuResponseNote->setCost(0);
VStringBuffer idstr("%" I64F "u", sysInfoMsg.queryLogMsgId());
espWuResponseNote->setId(idstr.str());
espWuResponseNotes.append(*espWuResponseNote.getClear());
}
}
catch(IException *e)
{
// Non-existant global messages may mean that /SysInfoLogs hasn't been created
// so catch and ignore the exception
e->Release();
}
Owned<IEspWUResponseScope> respScope = createWUResponseScope("","");
respScope->setScopeName("");
Expand Down
6 changes: 5 additions & 1 deletion helm/hpcc/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,11 @@
"type": "string",
"description": "The data format used to report logging: xml|json|table(space delimited values)",
"enum": [ "xml", "json", "table"]
}
},
"enableGlobalSysLog": {
"type": "boolean",
"description" : "Enable the reporting of important user/operator messages in ECL Watch"
}
},
"additionalProperties": { "type": ["integer", "string", "boolean"] }
},
Expand Down
3 changes: 3 additions & 0 deletions helm/hpcc/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ global:
# logging sets the default logging information for all components. Can be overridden locally
logging:
detail: 80
# GlobalSysLog records user/operator messages to dali so that messages are reported in ECL Watch
# The following enables GlobalSysLog (default: disabled)
#enableGlobalSysLog: true

# tracing sets the default tracing information for all components. Can be overridden locally
tracing:
Expand Down
1 change: 0 additions & 1 deletion testing/unittests/dalitests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3182,7 +3182,6 @@ class DaliSysInfoLoggerTester : public CppUnit::TestFixture
void testInit()
{
daliClientInit();
UseDaliForOperatorMessages(false);
}
void testWrite()
{
Expand Down

0 comments on commit acb2cc7

Please sign in to comment.