Skip to content

Commit

Permalink
HPCC-31774 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 Sep 16, 2024
1 parent a83bf6c commit 4874eab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
34 changes: 12 additions & 22 deletions dali/base/sysinfologger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class CSysInfoLoggerMsg : implements ISysInfoLoggerMsg
{
msgPtree.setown(createPTree(MSG_NODE));
msgPtree->setPropInt64(ATTR_ID, id);
msgPtree->setPropBool(ATTR_HIDDEN, false);
msgPtree->setPropBool(ATTR_HIDDEN, hidden);
msgPtree->setPropInt64(ATTR_TIMESTAMP, ts);
msgPtree->setPropInt(ATTR_CODE, code);
msgPtree->setProp(ATTR_AUDIENCE, LogMsgAudienceToFixString(cat.queryAudience()));
Expand Down Expand Up @@ -343,18 +343,6 @@ class CSysInfoLoggerMsgFilter : public CSimpleInterfaceOf<ISysInfoLoggerMsgFilte
{
return matchEndDay;
}
virtual unsigned queryMatchYear() const override
{
return (matchStartYear==matchEndYear ? matchStartYear : 0);
}
virtual unsigned queryMatchMonth() const override
{
return (matchStartMonth==matchEndMonth ? matchStartMonth : 0);
}
virtual unsigned queryMatchDay() const override
{
return (matchStartDay==matchEndDay ? matchStartDay : 0);
}
virtual const char * queryMatchSource() const override
{
return matchSource.str();
Expand All @@ -374,12 +362,14 @@ class CSysInfoLoggerMsgFilter : public CSimpleInterfaceOf<ISysInfoLoggerMsgFilte
virtual StringBuffer & getQualifierXPathFilter(StringBuffer & xpath) const override
{
bool fullDayMatch=false;
if (queryMatchYear() && queryMatchMonth())
bool hardMatchYear = matchStartYear==matchEndYear;
bool hardMatchMonth = matchStartMonth==matchEndMonth;
if (hardMatchYear && hardMatchMonth)
{
xpath.appendf("m%04u%02u", queryMatchYear(), queryMatchMonth());
if (queryMatchDay())
xpath.appendf("m%04u%02u", matchStartYear, matchStartMonth);
if (matchStartDay==matchEndDay)
{
xpath.appendf("/d%02u", queryMatchDay());
xpath.appendf("/d%02u", matchStartDay);
fullDayMatch = true;
}
}
Expand Down Expand Up @@ -443,9 +433,9 @@ class CSysInfoLoggerMsgIterator : public CSimpleInterfaceOf<ISysInfoLoggerMsgIte
public:
CSysInfoLoggerMsgIterator(IConstSysInfoLoggerMsgFilter * _filter, bool _updateable=false, IRemoteConnection *_conn=nullptr) : filter(_filter), updateable(_updateable), conn(_conn)
{
if (_conn==nullptr)
if (conn==nullptr)
{
unsigned mode = RTM_LOCK_READ | (updateable?RTM_LOCK_WRITE : 0);
unsigned mode = updateable ? RTM_LOCK_WRITE : RTM_LOCK_READ;
conn.setown(querySDS().connect(SYS_INFO_ROOT, myProcessSession(), mode, SDS_LOCK_TIMEOUT));
if (!conn)
throw makeStringExceptionV(-1, "CSysInfoLoggerMsgIterator: unable to create connection to '%s'", SYS_INFO_ROOT);
Expand Down Expand Up @@ -506,7 +496,7 @@ unsigned __int64 logSysInfoError(const LogMsgCategory & cat, LogMsgCode code, co

IPropertyTree * root = conn->queryRoot();
unsigned id = root->getPropInt(ATTR_NEXTID, 1);
if (id==INT_MAX) // wrap id to reuse id numbers (shouldn't wrap but no harm in doing this for safety)
if (id==UINT_MAX) // wrap id to reuse id numbers (shouldn't wrap but no harm in doing this for safety)
id=1;
root->setPropInt(ATTR_NEXTID, id+1);

Expand Down Expand Up @@ -580,7 +570,7 @@ unsigned deleteLogSysInfoMsg(IConstSysInfoLoggerMsgFilter * msgFilter)
}
IPropertyTree * root = conn->queryRoot();
unsigned count = 0;
for (auto xpath: deleteXpathList)
for (auto & xpath: deleteXpathList)
{
if (root->removeProp(xpath.c_str()));
++count;
Expand Down Expand Up @@ -677,7 +667,7 @@ unsigned deleteOlderThanLogSysInfoMsg(bool visibleOnly, bool hiddenOnly, unsigne
}

unsigned count = 0;
for (auto xpath: deleteXpathList)
for (auto & xpath: deleteXpathList)
{
if (root->removeProp(xpath.c_str()));
++count;
Expand Down
3 changes: 0 additions & 3 deletions dali/base/sysinfologger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ interface IConstSysInfoLoggerMsgFilter : public IInterface
virtual unsigned queryEndYear() const = 0;
virtual unsigned queryEndMonth() const = 0;
virtual unsigned queryEndDay() const = 0;
virtual unsigned queryMatchYear() const = 0;
virtual unsigned queryMatchMonth() const = 0;
virtual unsigned queryMatchDay() const = 0;
virtual const char * queryMatchSource() const = 0;
virtual LogMsgCode queryMatchCode() const = 0;
virtual LogMsgAudience queryMatchAudience() const = 0;
Expand Down

0 comments on commit 4874eab

Please sign in to comment.