Changeset 52215d7 in nscp


Ignore:
Timestamp:
02/02/08 20:59:13 (5 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
035c51f
Parents:
bf6e9b4
Message:

+ Added %count% parameter to syntax which (when used with unique) will display the numbe of hits for each message displayed.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • changelog

    rbf6e9b4 r52215d7  
    882008-02-02 MickeM 
    99 * Might have fixed the "missing eventlog messages" problem. 
     10 + Added %count% parameter to syntax which (when used with unique) will display the numbe of hits for each message displayed. 
    1011 
    11122008-01-27 MickeM 
  • modules/CheckEventLog/CheckEventLog.cpp

    rbf6e9b4 r52215d7  
    312312  WORD category; 
    313313public: 
     314  std::wstring message; 
    314315  uniq_eventlog_record(EVENTLOGRECORD *pevlr) : ID(pevlr->EventID&0xffff), type(pevlr->EventType), category(pevlr->EventCategory) {} 
    315316  bool operator< (const uniq_eventlog_record &other) const {  
     
    320321  } 
    321322}; 
    322 typedef std::map<uniq_eventlog_record,bool> uniq_eventlog_map; 
     323typedef std::map<uniq_eventlog_record,unsigned int> uniq_eventlog_map; 
    323324 
    324325 
     
    514515        } 
    515516        if (match&&unique) { 
    516           uniq_eventlog_record record = pevlr; 
    517           uniq_eventlog_map::const_iterator cit = uniq_records.find(record); 
    518           if (cit != uniq_records.end()) { 
    519             match = false; 
     517          match = false; 
     518          uniq_eventlog_record uniq_record = pevlr; 
     519          uniq_eventlog_map::iterator it = uniq_records.find(uniq_record); 
     520          if (it != uniq_records.end()) { 
     521            (*it).second ++; 
     522            //match = false; 
    520523          } 
    521           else 
    522             uniq_records[record] = true; 
    523         } 
    524  
    525         if (match) { 
     524          else { 
     525            if (!syntax.empty()) { 
     526              uniq_record.message = record.render(bShowDescriptions, syntax); 
     527            } else if (!bShowDescriptions) { 
     528              uniq_record.message = record.eventSource(); 
     529            } else { 
     530              uniq_record.message = record.eventSource(); 
     531              uniq_record.message += _T("(") + EventLogRecord::translateType(record.eventType()) + _T(", ") +  
     532                strEx::itos(record.eventID()) + _T(", ") + EventLogRecord::translateSeverity(record.severity()) + _T(")"); 
     533              uniq_record.message += _T("[") + record.enumStrings() + _T("]"); 
     534              uniq_record.message += _T("{%count%}"); 
     535            } 
     536            uniq_records[uniq_record] = 1; 
     537          } 
     538          hit_count++; 
     539        } else if (match) { 
    526540          if (!syntax.empty()) { 
    527541            strEx::append_list(message, record.render(bShowDescriptions, syntax)); 
     
    542556    }  
    543557    CloseEventLog(hLog); 
     558    for (uniq_eventlog_map::const_iterator cit = uniq_records.begin(); cit != uniq_records.end(); ++cit) { 
     559      std::wstring msg = (*cit).first.message; 
     560      strEx::replace(msg, _T("%count%"), strEx::itos((*cit).second)); 
     561      strEx::append_list(message, msg); 
     562    } 
    544563  } 
    545564 
Note: See TracChangeset for help on using the changeset viewer.