| | |
| | | #include <string.h> |
| | | #include <algorithm> |
| | | |
| | | using namespace std; |
| | | |
| | | namespace license { |
| | | EventRegistry::EventRegistry() { |
| | | } |
| | |
| | | |
| | | void EventRegistry::turnLastEventIntoError() { |
| | | if (logs.size() > 0) { |
| | | logs.back().severity = SEVERITY_ERROR; |
| | | logs.back().severity = SVRT_ERROR; |
| | | } |
| | | } |
| | | |
| | |
| | | bool eventFound = false; |
| | | for (auto it = logs.begin(); it != logs.end(); ++it) { |
| | | if (it->event_type == event) { |
| | | it->severity = SEVERITY_ERROR; |
| | | it->severity = SVRT_ERROR; |
| | | eventFound = true; |
| | | } |
| | | } |
| | |
| | | auto it = logs.end(); |
| | | do { |
| | | --it; |
| | | if (it->severity == SEVERITY_ERROR) { |
| | | if (it->severity == SVRT_ERROR) { |
| | | result = &(*it); |
| | | break; |
| | | } |
| | |
| | | bool EventRegistry::isGood() const { |
| | | bool isGood = true; |
| | | for (auto it = logs.begin(); it != logs.end(); ++it) { |
| | | if (it->severity == SEVERITY_ERROR) { |
| | | if (it->severity == SVRT_ERROR) { |
| | | isGood = false; |
| | | break; |
| | | } |
| | |
| | | } |
| | | |
| | | void EventRegistry::addError(EVENT_TYPE event) { |
| | | addEvent(event, SEVERITY_ERROR); |
| | | addEvent(event, SVRT_ERROR); |
| | | } |
| | | |
| | | void EventRegistry::addEvent(EVENT_TYPE event, SEVERITY severity) { |
| | |
| | | bool EventRegistry::turnErrosIntoWarnings() { |
| | | bool eventFound = false; |
| | | for (auto it = logs.begin(); it != logs.end(); ++it) { |
| | | if (it->severity == SEVERITY_ERROR) { |
| | | it->severity = SEVERITY_WARN; |
| | | if (it->severity == SVRT_ERROR) { |
| | | it->severity = SVRT_WARN; |
| | | eventFound = true; |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | void EventRegistry::exportLastEvents(AuditEvent* auditEvents, int nlogs) { |
| | | int sizeToCopy = std::min(nlogs, (int) logs.size()); |
| | | int sizeToCopy = min(nlogs, (int) logs.size()); |
| | | std::copy(logs.begin(), logs.begin() + sizeToCopy, auditEvents); |
| | | } |
| | | } |