From 0a9e5494c2843dcc069eabe9c8a0959e6b769b0a Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Thu, 29 Jan 2015 03:23:51 +0100 Subject: Supporting templace version for suppling locations in log exception method and GuardedLogger --- src/core/common/Logger.hpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'src/core/common/Logger.hpp') diff --git a/src/core/common/Logger.hpp b/src/core/common/Logger.hpp index ae06d08..8eac82e 100644 --- a/src/core/common/Logger.hpp +++ b/src/core/common/Logger.hpp @@ -271,6 +271,21 @@ public: log(Severity::ERROR, ex.msg, loc.isValid() ? loc : ex.getLocation()); } + /** + * Logs the given loggable exception. + * + * @param ex is the exception that should be logged. + * @param loc is a location which (if valid overrides the location given in + * the exception. + * @param mode specifies how the message should be displayed. + */ + template + void log(const LoggableException &ex, LocationType loc, + MessageMode mode = MessageMode::DEFAULT) + { + log(ex, SourceLocation::location(loc), mode); + } + /** * Logs the given message. The file name is set to the topmost file name on * the file name stack. @@ -648,6 +663,21 @@ public: */ GuardedLogger(Logger &parent, SourceLocation loc = SourceLocation{}); + /** + * Constructor of the GuardedLogger class, pushes a first file instance onto + * the file stack. + * + * @tparam LocationType is the type of the object pointing at the location. + * @param parent is the parent logger instance to which all calls should + * be relayed. + * @param loc specifies the first source location. + */ + template + GuardedLogger(Logger &parent, LocationType loc) + : GuardedLogger(parent, SourceLocation::location(loc)) + { + } + /** * Destructor of the GuardedLogger class, automatically unwinds the file * stack. @@ -788,7 +818,6 @@ public: */ bool hasFatalError(); }; - } #endif /* _OUSIA_LOGGER_HPP_ */ -- cgit v1.2.3