Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3786)

Unified Diff: flower/include/warn.hh

Issue 341270043: Issue 5322: simplify logging with an optional input location (Closed)
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lily/context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: flower/include/warn.hh
diff --git a/flower/include/warn.hh b/flower/include/warn.hh
index f52d3818cc11ae91569fa467b6128170673ffe13..9c017c3284c732fb9acc9cd4e42efa4a7730a2e8 100644
--- a/flower/include/warn.hh
+++ b/flower/include/warn.hh
@@ -65,4 +65,70 @@ void set_loglevel (string level);
void expect_warning (const string &msg);
void check_expected_warnings ();
+// The following templates accept any kind of object in place of the location
+// parameter. All that is required to use this feature is to overload
+// source_location (const Whatever &X), returning the location string from X.
+
+// Automatically follow a pointer looking for the source location.
+template <class Bearer>
+inline string source_location (const Bearer *bearer)
+{
+ return bearer ? source_location (*bearer) : string ();
+}
+
+template <class LocationBearer>
+inline void error (const string &s, const LocationBearer &location_bearer)
+{
+ error (s, source_location (location_bearer));
+}
+
+template <class LocationBearer>
+inline void programming_error (const string &s,
+ const LocationBearer &location_bearer)
+{
+ programming_error (s, source_location (location_bearer));
+}
+
+template <class LocationBearer>
+inline void non_fatal_error (const string &s,
+ const LocationBearer &location_bearer)
+{
+ non_fatal_error (s, source_location (location_bearer));
+}
+
+template <class LocationBearer>
+inline void warning (const string &s,
+ const LocationBearer &location_bearer)
+{
+ warning (s, source_location (location_bearer));
+}
+
+template <class LocationBearer>
+inline void basic_progress (const string &s,
+ const LocationBearer &location_bearer)
+{
+ basic_progress (s, source_location (location_bearer));
+}
+
+template <class LocationBearer>
+inline void progress_indication (const string &s, bool newline,
+ const LocationBearer &location_bearer)
+{
+ progress_indication (s, newline, source_location (location_bearer));
+}
+
+template <class LocationBearer>
+inline void message (const string &s, bool newline,
+ const LocationBearer &location_bearer)
+{
+ message (s, newline, source_location (location_bearer));
+}
+
+template <class LocationBearer>
+inline void debug_output (const string &s, bool newline,
+ const LocationBearer &location_bearer)
+{
+ debug_output (s, newline, source_location (location_bearer));
+}
+
#endif /* WARN_HH */
« no previous file with comments | « no previous file | lily/context.cc » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b