Lumiera  0.pre.03
»edityourfreedom«
event-log.hpp
Go to the documentation of this file.
1 /*
2  EVENT-LOG.hpp - test facility to verify the occurrence of expected events
3 
4  Copyright (C) Lumiera.org
5  2015, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
42 #ifndef LIB_TEST_EVENT_LOG_H
43 #define LIB_TEST_EVENT_LOG_H
44 
45 
46 #include "lib/error.hpp"
47 #include "lib/idi/entry-id.hpp"
49 #include "lib/iter-cursor.hpp"
50 #include "lib/format-util.hpp"
51 #include "lib/format-cout.hpp"
52 #include "lib/diff/record.hpp"
53 #include "lib/symbol.hpp"
54 #include "lib/util.hpp"
55 
56 #include <memory>
57 #include <vector>
58 #include <string>
59 #include <regex>
60 
61 
62 
63 namespace lib {
64 namespace test{
65  namespace error = lumiera::error;
66 
67  using util::stringify;
68  using util::contains;
69  using util::isnil;
70  using lib::Symbol;
71  using std::string;
72 
73  namespace {
74  using Entry = lib::diff::Record<string>;
75  using Log = std::vector<Entry>;
76 
77  auto
78  buildSearchFilter(Log const& srcSeq)
79  {
81  return treeExplore (Cursor{srcSeq.begin(), srcSeq.end()})
82  .mutableFilter();
83  }
84  }
85 
86 
96  class EventMatch
97  {
98  using Filter = decltype( buildSearchFilter (std::declval<Log const&>()) );
99 
101  using RExSeq = std::vector<std::regex>;
102 
103 
106 
108  string lastMatch_;
109 
112 
114  string violation_;
115 
120  bool
122  {
123  return not isnil (solution_);
124  }
125 
135  void
136  evaluateQuery (string matchSpec, Literal rel = "after")
137  {
138  if (look_for_match_ and not isnil (violation_)) return;
139  // already failed, no further check necessary
140 
141  if (foundSolution()) // NOTE this pulls the filter
142  {
143  lastMatch_ = matchSpec+" @ "+string(*solution_)
144  + (isnil(lastMatch_)? ""
145  : "\n.."+rel+" "+lastMatch_);
146  if (not look_for_match_)
147  violation_ = "FOUND at least "+lastMatch_;
148  }
149  else
150  {
151  if (look_for_match_)
152  violation_ = "FAILED to "+matchSpec
153  + "\n.."+rel
154  + " "+lastMatch_;
155  else
156  violation_ = "";
157  }
158  }
159 
160 
162  EventMatch(Log const& srcSeq)
163  : solution_{buildSearchFilter (srcSeq)}
164  , lastMatch_{"HEAD "+ solution_->get("this")}
165  , look_for_match_{true}
166  , violation_{}
167  { }
168 
169  friend class EventLog;
170 
171 
172 
173  /* == elementary matchers == */
174 
175  auto
176  find (string match)
177  {
178  return [=](Entry const& entry)
179  {
180  return contains (string(entry), match);
181  };
182  }
183 
184  auto
185  findRegExp (string regExpDef)
186  {
187  std::regex regExp(regExpDef);
188  return [=](Entry const& entry)
189  {
190  return std::regex_search(string(entry), regExp);
191  };
192  }
193 
194  auto
195  findEvent (string match)
196  {
197  return [=](Entry const& entry)
198  {
199  return ( entry.getType() == "event"
200  or entry.getType() == "error"
201  or entry.getType() == "create"
202  or entry.getType() == "destroy"
203  or entry.getType() == "logJoin"
204  )
205  and !isnil(entry.scope())
206  and contains (*entry.scope(), match);
207  };
208  }
209 
210  auto
211  findEvent (string classifier, string match)
212  {
213  return [=](Entry const& entry)
214  {
215  return ( entry.getType() == classifier
216  or (entry.hasAttribute("ID") and contains (entry.get("ID"), classifier))
217  )
218  and !isnil(entry.scope())
219  and contains (*entry.scope(), match);
220  };
221  }
222 
223  auto
224  findCall (string match)
225  {
226  return [=](Entry const& entry)
227  {
228  return entry.getType() == "call"
229  and contains (entry.get("fun"), match);
230  };
231  }
232 
233 
242  auto
244  {
245  return [=](Entry const& entry)
246  {
247  auto scope = entry.scope();
248  for (auto const& match : argSeq)
249  if (isnil (scope) or not contains(*scope, match))
250  return false;
251  else
252  ++scope;
253 
254  return isnil(scope); // must be exhausted by now
255  }; // otherwise the sizes do not match...
256  }
257 
258 
268  auto
269  matchArgsRegExp (RExSeq&& regExpSeq)
270  {
271  return [=](Entry const& entry)
272  {
273  auto scope = entry.scope();
274  for (auto const& rex : regExpSeq)
275  {
276  if (isnil (scope)) return false;
277  while (scope and std::regex_search(*scope, rex))
278  ++scope;
279  }
280 
281  return isnil(scope); // must be exhausted by now
282  }; // otherwise we didn't get full coverage...
283  }
284 
285 
287  auto
288  matchType (string typeID)
289  {
290  return [=](Entry const& entry)
291  {
292  return contains (entry.getType(), typeID);
293  };
294  }
295 
296 
298  auto
299  ensureAttribute (string key)
300  {
301  return [=](Entry const& entry)
302  {
303  return entry.hasAttribute(key);
304  };
305  }
306 
307 
309  auto
310  matchAttribute (string key, string valueMatch)
311  {
312  return [=](Entry const& entry)
313  {
314  return entry.hasAttribute(key)
315  and contains (entry.get(key), valueMatch);
316  };
317  }
318 
319 
320  /* === configure the underlying search engine === */
321 
322  enum Direction {
323  FORWARD, BACKWARD
324  };
325 
326  template<typename COND>
327  void
328  attachNextSerchStep (COND&& filter, Direction direction)
329  {
330  solution_.reverse (BACKWARD == direction);
331  solution_.setNewFilter (forward<COND> (filter));
332  }
333 
334  template<typename COND>
335  void
336  refineSerach (COND&& additionalFilter)
337  {
338  solution_.andFilter (forward<COND> (additionalFilter));
339  }
340 
341 
342 
343  public:
348  operator bool() const
349  {
350  if (!isnil (violation_))
351  {
352  cerr << "__Log_condition_violated__\n"+violation_ <<"\n";
353  return false;
354  }
355  return true;
356  }
357 
358 
367  EventMatch&
368  before (string match)
369  {
370  attachNextSerchStep (find(match), FORWARD);
371  evaluateQuery ("match(\""+match+"\")");
372  return *this;
373  }
374 
376  EventMatch&
377  beforeMatch (string regExp)
378  {
379  attachNextSerchStep (findRegExp(regExp), FORWARD);
380  evaluateQuery ("find-RegExp(\""+regExp+"\")");
381  return *this;
382  }
383 
397  EventMatch&
398  beforeEvent (string match)
399  {
400  attachNextSerchStep (findEvent(match), FORWARD);
401  evaluateQuery ("match-event(\""+match+"\")");
402  return *this;
403  }
404 
405  EventMatch&
406  beforeEvent (string classifier, string match)
407  {
408  attachNextSerchStep (findEvent(classifier,match), FORWARD);
409  evaluateQuery ("match-event(ID=\""+classifier+"\", \""+match+"\")");
410  return *this;
411  }
412 
417  EventMatch&
418  beforeCall (string match)
419  {
420  attachNextSerchStep (findCall(match), FORWARD);
421  evaluateQuery ("match-call(\""+match+"\")");
422  return *this;
423  }
424 
425  EventMatch&
426  after (string match)
427  {
428  attachNextSerchStep (find(match), BACKWARD);
429  evaluateQuery ("match(\""+match+"\")", "before");
430  return *this;
431  }
432 
433  EventMatch&
434  afterMatch (string regExp)
435  {
436  attachNextSerchStep (findRegExp(regExp), BACKWARD);
437  evaluateQuery ("find-RegExp(\""+regExp+"\")", "before");
438  return *this;
439  }
440 
441  EventMatch&
442  afterEvent (string match)
443  {
444  attachNextSerchStep (findEvent(match), BACKWARD);
445  evaluateQuery ("match-event(\""+match+"\")", "before");
446  return *this;
447  }
448 
449  EventMatch&
450  afterEvent (string classifier, string match)
451  {
452  attachNextSerchStep (findEvent(classifier,match), BACKWARD);
453  evaluateQuery ("match-event(ID=\""+classifier+"\", \""+match+"\")", "before");
454  return *this;
455  }
456 
458  EventMatch&
459  afterCall (string match)
460  {
461  attachNextSerchStep (findCall(match), BACKWARD);
462  evaluateQuery ("match-call(\""+match+"\")", "before");
463  return *this;
464  }
465 
472  template<typename...ARGS>
473  EventMatch&
474  arg (ARGS const& ...args)
475  {
476  ArgSeq argSeq(stringify<ArgSeq> (args...));
477  string argList(util::join(argSeq));
478 
479  refineSerach (matchArguments(move(argSeq)));
480  evaluateQuery ("match-arguments("+argList+")");
481  return *this;
482  }
483 
494  template<typename...ARGS>
495  EventMatch&
496  argMatch (ARGS const& ...regExps)
497  {
498  refineSerach (matchArgsRegExp (stringify<RExSeq> (regExps...)));
499  evaluateQuery ("match-args-RegExp("+util::join(stringify<ArgSeq>(regExps...))+")");
500  return *this;
501  }
502 
504  EventMatch&
505  type (string typeID)
506  {
507  refineSerach (matchType(typeID));
508  evaluateQuery ("match-type("+typeID+")");
509  return *this;
510  }
511 
513  EventMatch&
514  key (string key)
515  {
516  refineSerach (ensureAttribute(key));
517  evaluateQuery ("ensure-attribute("+key+")");
518  return *this;
519  }
520 
522  EventMatch&
523  attrib (string key, string valueMatch)
524  {
525  refineSerach (matchAttribute(key,valueMatch));
526  evaluateQuery ("match-attribute("+key+"=\""+valueMatch+"\")");
527  return *this;
528  }
529 
531  EventMatch&
532  id (string classifier)
533  {
534  refineSerach (matchAttribute("ID",classifier));
535  evaluateQuery ("match-ID(\""+classifier+"\")");
536  return *this;
537  }
538 
540  EventMatch&
541  on (string targetID)
542  {
543  refineSerach (matchAttribute("this",targetID));
544  evaluateQuery ("match-this(\""+targetID+"\")");
545  return *this;
546  }
547 
548  EventMatch&
549  on (const char* targetID)
550  {
551  refineSerach (matchAttribute("this",targetID));
552  evaluateQuery ("match-this(\""+string(targetID)+"\")");
553  return *this;
554  }
555 
556  template<typename X>
557  EventMatch&
558  on (const X *const targetObj)
559  {
560  string targetID = idi::instanceTypeID (targetObj);
561  refineSerach (matchAttribute("this",targetID));
562  evaluateQuery ("match-this(\""+targetID+"\")");
563  return *this;
564  }
565  };
566 
567 
568 
569 
570 
571  /****************************************************************/
579  class EventLog
580  {
581 
583 
584 
585  void
586  log (std::initializer_list<string> const& ili)
587  {
588  log_->emplace_back(ili);
589  }
590 
591  template<typename ATTR, typename ARGS>
592  void
593  log (Symbol typeID, ATTR&& attribs, ARGS&& args)
594  {
595  log_->emplace_back(typeID, std::forward<ATTR>(attribs)
596  , std::forward<ARGS>(args));
597  }
598 
599  string
600  getID() const
601  {
602  return log_->front().get("this");
603  }
604 
605 
606  public:
607  explicit
608  EventLog (string logID)
609  : log_(new Log)
610  {
611  log({"type=EventLogHeader", "this="+logID});
612  }
613 
614  explicit
615  EventLog (const char* logID)
616  : EventLog(string(logID))
617  { }
618 
619  template<class X>
620  explicit
621  EventLog (const X *const obj)
622  : EventLog(idi::instanceTypeID (obj))
623  { }
624 
625 
626  // standard copy operations acceptable
627 
628 
645  EventLog&
646  joinInto (EventLog& otherLog)
647  {
648  Log& target = *otherLog.log_;
649  target.reserve (target.size() + log_->size() + 1);
650  target.emplace_back (log_->front());
651  auto p = log_->begin();
652  while (++p != log_->end()) // move our log's content into the other log
653  target.emplace_back(std::move(*p));
654  this->log_->resize(1);
655  this->log({"type=joined", otherLog.getID()}); // leave a tag to indicate
656  otherLog.log({"type=logJoin", this->getID()}); // where the `joinInto` took place,
657  this->log_ = otherLog.log_; // connect this to the other storage
658  return *this;
659  }
660 
661 
663  EventLog&
665  {
666  string originalLogID = this->getID();
667  return this->clear (originalLogID);
668  }
669 
678  EventLog&
679  clear (string alteredLogID)
680  {
681  log_.reset (new Log);
682  log({"type=EventLogHeader", "this="+alteredLogID});
683  return *this;
684  }
685 
686  EventLog&
687  clear (const char* alteredLogID)
688  {
689  return clear (string{alteredLogID});
690  }
691 
692  template<class X>
693  EventLog&
694  clear (const X *const obj)
695  {
696  return clear (idi::instanceTypeID (obj));
697  }
698 
699 
700 
701  /* ==== Logging API ==== */
702 
704 
705  EventLog&
706  event (string text)
707  {
708  log ("event", ArgSeq{}, ArgSeq{text}); // we use this ctor variant to ensure
709  return *this; // that text is not misinterpreted as attribute,
710  } // which might happen when text contains a '='
711 
716  EventLog&
717  event (string classifier, string text)
718  {
719  log ("event", ArgSeq{"ID="+classifier}, ArgSeq{text});
720  return *this;
721  }
722 
727  EventLog&
728  call (string target, string function)
729  {
730  return call(target, function, ArgSeq());
731  }
732 
734  EventLog&
735  call (string target, string function, ArgSeq&& args)
736  {
737  log ("call", ArgSeq{"fun="+function, "this="+target}, std::forward<ArgSeq>(args));
738  return *this;
739  }
740 
741  EventLog&
742  call (const char* target, const char* function, ArgSeq&& args)
743  {
744  return call (string(target), string(function), std::forward<ArgSeq>(args));
745  }
746 
748  template<typename...ARGS>
749  EventLog&
750  call (string target, string function, ARGS const& ...args)
751  {
752  return call (target, function, stringify<ArgSeq>(args...));
753  }
754 
756  template<class X, typename...ARGS>
757  EventLog&
758  call (const X *const targetObj, string function, ARGS const& ...args)
759  {
760  return call (idi::instanceTypeID (targetObj), function, args...);
761  }
762 
763  template<typename...ARGS>
764  EventLog&
765  call (const char* target, string function, ARGS const& ...args)
766  {
767  return call (string(target), function, args...);
768  }
769 
770  template<typename...ELMS>
771  EventLog&
772  note (ELMS const& ...initialiser)
773  {
774  log_->emplace_back(stringify<ArgSeq> (initialiser...));
775  return *this;
776  }
777 
778 
780  EventLog&
781  warn (string text)
782  {
783  log({"type=warn", text});
784  return *this;
785  }
786 
787 
789  EventLog&
790  error (string text)
791  {
792  log({"type=error", text});
793  return *this;
794  }
795 
796 
798  EventLog&
799  fatal (string text)
800  {
801  log({"type=fatal", text});
802  return *this;
803  }
804 
805 
808  EventLog&
809  create (string text)
810  {
811  log({"type=create", text});
812  return *this;
813  }
814 
815 
818  EventLog&
819  destroy (string text)
820  {
821  log({"type=destroy", text});
822  return *this;
823  }
824 
825 
826 
827  /* ==== Iteration ==== */
828 
829  bool
830  empty() const
831  {
832  return 1 >= log_->size(); // do not count the log header
833  }
834 
835 
837 
839  typedef const Entry value_type;
840 
841  const_iterator begin() const { return Iter(log_->begin(), log_->end()); }
842  const_iterator end() const { return Iter(); }
843 
844  friend const_iterator begin (EventLog const& log) { return log.begin(); }
845  friend const_iterator end (EventLog const& log) { return log.end(); }
846 
847 
848 
849 
850  /* ==== Query/Verification API ==== */
851 
859  EventMatch
860  verify (string match) const
861  {
862  EventMatch matcher(*log_);
863  matcher.before (match); // "the start of the log is before the match"
864  return matcher;
865  }
866 
873  EventMatch
874  verifyMatch (string regExp) const
875  {
876  EventMatch matcher(*log_);
877  matcher.beforeMatch (regExp);
878  return matcher;
879  }
880 
888  EventMatch
889  verifyEvent (string match) const
890  {
891  EventMatch matcher(*log_);
892  matcher.beforeEvent (match);
893  return matcher;
894  }
895 
896  EventMatch
897  verifyEvent (string classifier, string match) const
898  {
899  EventMatch matcher(*log_);
900  matcher.beforeEvent (classifier, match);
901  return matcher;
902  }
903 
904  template<typename X>
905  EventMatch
906  verifyEvent (string classifier, X const& something) const
907  {
908  return verifyEvent (classifier, util::toString (something));
909  }
910 
914  EventMatch
915  verifyCall (string match) const
916  {
917  EventMatch matcher(*log_);
918  matcher.beforeCall (match);
919  return matcher;
920  }
921 
931  EventMatch
932  ensureNot (string match) const
933  {
934  EventMatch matcher(*log_);
935  matcher.look_for_match_ = false; // flip logic; fail if match succeeds
936  matcher.before (match);
937  return matcher;
938  }
939 
940 
942  friend bool
943  operator== (EventLog const& l1, EventLog const& l2)
944  {
945  return l1.log_ == l2.log_
946  or (l1.log_ and l2.log_
947  and *l1.log_ == *l2.log_);
948  }
949  friend bool
950  operator!= (EventLog const& l1, EventLog const& l2)
951  {
952  return not (l1 == l2);
953  }
954  };
955 
956 
957 
958 }} // namespace lib::test
959 #endif /*LIB_TEST_EVENT_LOG_H*/
auto matchArgsRegExp(RExSeq &&regExpSeq)
refinement filter, to cover all arguments by regular expression(s)
Definition: event-log.hpp:269
EventLog & warn(string text)
Log a warning entry.
Definition: event-log.hpp:781
auto ensureAttribute(string key)
refinement filter to ensure a specific attribute is present on the log entry
Definition: event-log.hpp:299
std::vector< std::regex > RExSeq
Definition: event-log.hpp:101
EventMatch & on(const char *targetID)
Definition: event-log.hpp:549
const_iterator end() const
Definition: event-log.hpp:842
lib::diff::RecordSetup< string >::Storage ArgSeq
Definition: event-log.hpp:703
string violation_
record when the underlying query has failed
Definition: event-log.hpp:114
Automatically use custom string conversion in C++ stream output.
bool operator!=(PtrDerefIter< I1 > const &il, PtrDerefIter< I2 > const &ir)
Filter solution_
match predicate evaluator
Definition: event-log.hpp:105
EventMatch & attrib(string key, string valueMatch)
refine filter to additionally match on a specific attribute
Definition: event-log.hpp:523
EventLog(const char *logID)
Definition: event-log.hpp:615
std::string toString(TY const &val) noexcept
get some string representation of any object, reliably.
Definition: format-obj.hpp:174
EventMatch & on(const X *const targetObj)
Definition: event-log.hpp:558
Definition: run.hpp:49
friend const_iterator end(EventLog const &log)
Definition: event-log.hpp:845
auto matchType(string typeID)
refinement filter to match on the given typeID
Definition: event-log.hpp:288
EventLog & clear(const char *alteredLogID)
Definition: event-log.hpp:687
EventMatch & id(string classifier)
refine filter to additionally match on the ID attribute
Definition: event-log.hpp:532
decltype(buildSearchFilter(std::declval< Log const & >())) Filter
Definition: event-log.hpp:98
auto findCall(string match)
Definition: event-log.hpp:224
inline string literal This is a marker type to indicate that
Definition: symbol.hpp:75
EventLog & create(string text)
Log the creation of an object.
Definition: event-log.hpp:809
Helper to log and verify the occurrence of events.
Definition: event-log.hpp:579
void refineSerach(COND &&additionalFilter)
Definition: event-log.hpp:336
EventMatch verifyEvent(string classifier, X const &something) const
Definition: event-log.hpp:906
const_iterator begin() const
Definition: event-log.hpp:841
bool operator==(PtrDerefIter< I1 > const &il, PtrDerefIter< I2 > const &ir)
Supporting equality comparisons...
auto treeExplore(IT &&srcSeq)
start building a TreeExplorer by suitably wrapping the given iterable source.
EventMatch & afterCall(string match)
find a function invocation backwards, before the current point of reference
Definition: event-log.hpp:459
void attachNextSerchStep(COND &&filter, Direction direction)
Definition: event-log.hpp:328
An iterator with the ability to switch direction.
EventMatch & arg(ARGS const &...args)
refine filter to additionally require specific arguments
Definition: event-log.hpp:474
string join(CON &&coll, string const &delim=", ")
enumerate a collection&#39;s contents, separated by delimiter.
EventLog & call(string target, string function, ArgSeq &&args)
Log a function call with a sequence of stringified arguments.
Definition: event-log.hpp:735
EventMatch verifyEvent(string match) const
start a query to match for some event.
Definition: event-log.hpp:889
auto matchArguments(ArgSeq &&argSeq)
this filter functor is for refinement of an existing filter
Definition: event-log.hpp:243
lib::diff::RecordSetup< string >::Storage ArgSeq
Definition: event-log.hpp:100
EventLog & clear(string alteredLogID)
purge log contents and also reset Header-ID
Definition: event-log.hpp:679
Building tree expanding and backtracking evaluations within hierarchical scopes.
void log(Symbol typeID, ATTR &&attribs, ARGS &&args)
Definition: event-log.hpp:593
EventLog & call(const char *target, const char *function, ArgSeq &&args)
Definition: event-log.hpp:742
Implementation namespace for support and library code.
EventMatch & beforeCall(string match)
find a match for some function invocation after the current point of reference
Definition: event-log.hpp:418
bool find(Query< Pipe > &q)
shortcut: run just a query without creating new instances
auto findEvent(string classifier, string match)
Definition: event-log.hpp:211
void evaluateQuery(string matchSpec, Literal rel="after")
this is actually called after each refinement of the filter and matching conditions.
Definition: event-log.hpp:136
EventMatch & before(string match)
find a match (substring match) of the given text in an EventLog entry after the current position ...
Definition: event-log.hpp:368
EventMatch(Log const &srcSeq)
Definition: event-log.hpp:162
Token or Atom with distinct identity.
Definition: symbol.hpp:116
EventMatch verifyCall(string match) const
start a query to match especially a function call
Definition: event-log.hpp:915
EventMatch & key(string key)
refine filter to additionally require the presence an attribute
Definition: event-log.hpp:514
bool contains(MAP &map, typename MAP::key_type const &key)
shortcut for containment test on a map
Definition: util.hpp:205
EventLog(string logID)
Definition: event-log.hpp:608
Special collection to represent object-like data.
EventMatch ensureNot(string match) const
start a query to ensure the given expression does not match.
Definition: event-log.hpp:932
const Entry value_type
Definition: event-log.hpp:839
bool foundSolution()
core of the evaluation machinery: apply a filter predicate and then pull through the log to find a ac...
Definition: event-log.hpp:121
Marker types to indicate a literal string and a Symbol.
EventLog & call(const char *target, string function, ARGS const &...args)
Definition: event-log.hpp:765
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
EventLog & error(string text)
Log an error note.
Definition: event-log.hpp:790
EventMatch & beforeMatch(string regExp)
find a match with the given regular expression
Definition: event-log.hpp:377
EventLog(const X *const obj)
Definition: event-log.hpp:621
EventLog & call(string target, string function)
Log occurrence of a function call with no arguments.
Definition: event-log.hpp:728
EventMatch & beforeEvent(string classifier, string match)
Definition: event-log.hpp:406
bool look_for_match_
support for positive and negative queries.
Definition: event-log.hpp:111
EventMatch & argMatch(ARGS const &...regExps)
refine filter to additionally cover all arguments with a series of regular expressions.
Definition: event-log.hpp:496
EventMatch & afterEvent(string classifier, string match)
Definition: event-log.hpp:450
bool isnil(lib::time::Duration const &dur)
Definition: timevalue.hpp:642
EventMatch & afterMatch(string regExp)
Definition: event-log.hpp:434
auto find(string match)
Definition: event-log.hpp:176
EventLog & fatal(string text)
Log a fatal failure.
Definition: event-log.hpp:799
CON stringify(ELMS const &...elms)
convert a sequence of elements to string
Lumiera error handling (C++ interface).
string instanceTypeID(const TY *const obj)
designation of an distinct object instance
Definition: genfunc.hpp:125
EventLog & destroy(string text)
Log the destruction of an object.
Definition: event-log.hpp:819
EventLog & clear(const X *const obj)
Definition: event-log.hpp:694
EventLog & event(string classifier, string text)
log some event, with additional ID or classifier
Definition: event-log.hpp:717
EventLog & call(const X *const targetObj, string function, ARGS const &...args)
Log a function call on given object ("`this`")...
Definition: event-log.hpp:758
EventLog & joinInto(EventLog &otherLog)
Merge this log into another log, forming a combined log.
Definition: event-log.hpp:646
Collection of small helpers and convenience shortcuts for diagnostics & formatting.
std::shared_ptr< Log > log_
Definition: event-log.hpp:582
EventMatch verify(string match) const
start a query to match for some substring.
Definition: event-log.hpp:860
bool empty() const
Definition: event-log.hpp:830
EventLog & note(ELMS const &...initialiser)
Definition: event-log.hpp:772
Bare symbolic and hash ID used for accounting of asset like entries.
EventMatch verifyMatch(string regExp) const
start a query to match with a regular expression
Definition: event-log.hpp:874
Accessing a STL element range through a Lumiera forward iterator, An instance of this iterator adapte...
EventLog & clear()
purge log contents while retaining just the original Header-ID
Definition: event-log.hpp:664
EventLog & call(string target, string function, ARGS const &...args)
Log a function call with arbitrary arguments.
Definition: event-log.hpp:750
void log(std::initializer_list< string > const &ili)
Definition: event-log.hpp:586
EventMatch & afterEvent(string match)
Definition: event-log.hpp:442
EventMatch & after(string match)
Definition: event-log.hpp:426
EventMatch & type(string typeID)
refine filter to additionally require a matching log entry type
Definition: event-log.hpp:505
EventMatch & beforeEvent(string match)
find a match for an "event" after the current point of reference
Definition: event-log.hpp:398
object-like record of data.
Definition: record.hpp:143
EventMatch verifyEvent(string classifier, string match) const
Definition: event-log.hpp:897
auto matchAttribute(string key, string valueMatch)
refinement filter to ensure a specific attribute is present on the log entry
Definition: event-log.hpp:310
EventLog & event(string text)
Definition: event-log.hpp:706
auto findRegExp(string regExpDef)
Definition: event-log.hpp:185
string lastMatch_
record last match for diagnostics
Definition: event-log.hpp:108
string getID() const
Definition: event-log.hpp:600
auto findEvent(string match)
Definition: event-log.hpp:195
friend const_iterator begin(EventLog const &log)
Definition: event-log.hpp:844
EventMatch & on(string targetID)
refine filter to additionally match the &#39;this&#39; attribute
Definition: event-log.hpp:541