Skip to content

Commit

Permalink
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 24, 2024
1 parent fbaa6df commit eebe543
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions dali/base/sysinfologger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,7 @@ class CSysInfoLoggerMsgFilter : public CSimpleInterfaceOf<ISysInfoLoggerMsgFilte
{
if (hiddenOnly && visibleOnly)
throw makeStringExceptionV(-1, "ISysInfoLoggerMsgFilter: cannot filter by both hiddenOnly and visibleOnly");
if (!_month && _day)
throw makeStringExceptionV(-1, "ISysInfoLoggerMsgFilter: month and year must be provided when filtering by day");
if (!_year && _month)
throw makeStringExceptionV(-1, "ISysInfoLoggerMsgFilter: year must be provided when filtering by month");
haveDateRange = false;
setDateRange(_year, _month, _day, _year, _month, _day);
}
virtual void setHiddenOnly() override
{
Expand Down Expand Up @@ -238,6 +234,15 @@ class CSysInfoLoggerMsgFilter : public CSimpleInterfaceOf<ISysInfoLoggerMsgFilte
}
virtual void setDateRange(unsigned startYear, unsigned startMonth, unsigned startDay, unsigned endYear, unsigned endMonth, unsigned endDay) override
{
if ( (startDay && (!startMonth||!startYear)) ||
(endDay && (!endMonth||!endYear)) )
throw makeStringExceptionV(-1, "ISysInfoLoggerMsgFilter: month and year must be provided when filtering by day");
if ((!startYear && startMonth) || (!endYear && endMonth))
throw makeStringExceptionV(-1, "ISysInfoLoggerMsgFilter: year must be provided when filtering by month");
// Make sure starts are on or before end dates
if ( (startYear > endYear) || (startMonth && (startYear == endYear && startMonth > endMonth))
|| (startDay && (startYear == endYear && startMonth == endMonth && startDay > endDay)) )
throw makeStringExceptionV(-1, "ISysInfoLoggerMsgFilter: invalid date range: %04u-%02u-%02u to %04u-%02u-%02u", startYear, startMonth, startDay, endYear, endMonth, endDay);
matchEndYear = endYear;
matchEndMonth = endMonth;
matchEndDay = endDay;
Expand Down Expand Up @@ -362,8 +367,8 @@ class CSysInfoLoggerMsgFilter : public CSimpleInterfaceOf<ISysInfoLoggerMsgFilte
virtual StringBuffer & getQualifierXPathFilter(StringBuffer & xpath) const override
{
bool fullDayMatch=false;
bool hardMatchYear = matchStartYear==matchEndYear;
bool hardMatchMonth = matchStartMonth==matchEndMonth;
bool hardMatchYear = matchStartYear && (matchStartYear==matchEndYear);
bool hardMatchMonth = matchStartMonth && (matchStartMonth==matchEndMonth);
if (hardMatchYear && hardMatchMonth)
{
xpath.appendf("m%04u%02u", matchStartYear, matchStartMonth);
Expand Down Expand Up @@ -433,7 +438,7 @@ 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)
{
unsigned mode = updateable ? RTM_LOCK_WRITE : RTM_LOCK_READ;
conn.setown(querySDS().connect(SYS_INFO_ROOT, myProcessSession(), mode, SDS_LOCK_TIMEOUT));
Expand Down

0 comments on commit eebe543

Please sign in to comment.