Commit bdc568b8 authored by Kenton Varda's avatar Kenton Varda

Tweak previous change.

parent 93e030e3
...@@ -60,6 +60,12 @@ public: ...@@ -60,6 +60,12 @@ public:
Exception(const Exception& other) noexcept; Exception(const Exception& other) noexcept;
~Exception() noexcept; ~Exception() noexcept;
const char* getFile() const { return file; }
int getLine() const { return line; }
Nature getNature() const { return nature; }
Durability getDurability() const { return durability; }
ArrayPtr<const char> getDescription() const { return description; }
const char* what() const noexcept override; const char* what() const noexcept override;
private: private:
......
...@@ -126,7 +126,7 @@ static Array<char> makeDescription(const char* condition, const char* macroArgs, ...@@ -126,7 +126,7 @@ static Array<char> makeDescription(const char* condition, const char* macroArgs,
} }
} }
void Log::logInternal(const char* file, uint line, Severity severity, const char* macroArgs, void Log::logInternal(const char* file, int line, Severity severity, const char* macroArgs,
ArrayPtr<Array<char>> argValues) { ArrayPtr<Array<char>> argValues) {
getExceptionCallback()->logMessage( getExceptionCallback()->logMessage(
str(severity, ": ", file, ":", line, ": ", str(severity, ": ", file, ":", line, ": ",
...@@ -134,7 +134,7 @@ void Log::logInternal(const char* file, uint line, Severity severity, const char ...@@ -134,7 +134,7 @@ void Log::logInternal(const char* file, uint line, Severity severity, const char
} }
void Log::recoverableFaultInternal( void Log::recoverableFaultInternal(
const char* file, uint line, Exception::Nature nature, const char* file, int line, Exception::Nature nature,
const char* condition, const char* macroArgs, ArrayPtr<Array<char>> argValues) { const char* condition, const char* macroArgs, ArrayPtr<Array<char>> argValues) {
getExceptionCallback()->onRecoverableException( getExceptionCallback()->onRecoverableException(
Exception(nature, Exception::Durability::PERMANENT, file, line, Exception(nature, Exception::Durability::PERMANENT, file, line,
...@@ -142,7 +142,7 @@ void Log::recoverableFaultInternal( ...@@ -142,7 +142,7 @@ void Log::recoverableFaultInternal(
} }
void Log::fatalFaultInternal( void Log::fatalFaultInternal(
const char* file, uint line, Exception::Nature nature, const char* file, int line, Exception::Nature nature,
const char* condition, const char* macroArgs, ArrayPtr<Array<char>> argValues) { const char* condition, const char* macroArgs, ArrayPtr<Array<char>> argValues) {
getExceptionCallback()->onFatalException( getExceptionCallback()->onFatalException(
Exception(nature, Exception::Durability::PERMANENT, file, line, Exception(nature, Exception::Durability::PERMANENT, file, line,
......
...@@ -48,28 +48,28 @@ public: ...@@ -48,28 +48,28 @@ public:
static inline void setLogLevel(Severity severity) { minSeverity = severity; } static inline void setLogLevel(Severity severity) { minSeverity = severity; }
template <typename... Params> template <typename... Params>
static void log(const char* file, uint line, Severity severity, const char* macroArgs, static void log(const char* file, int line, Severity severity, const char* macroArgs,
Params&&... params); Params&&... params);
template <typename... Params> template <typename... Params>
static void recoverableFault(const char* file, uint line, Exception::Nature nature, static void recoverableFault(const char* file, int line, Exception::Nature nature,
const char* condition, const char* macroArgs, Params&&... params); const char* condition, const char* macroArgs, Params&&... params);
template <typename... Params> template <typename... Params>
static void fatalFault(const char* file, uint line, Exception::Nature nature, static void fatalFault(const char* file, int line, Exception::Nature nature,
const char* condition, const char* macroArgs, Params&&... params) const char* condition, const char* macroArgs, Params&&... params)
CAPNPROTO_NORETURN; CAPNPROTO_NORETURN;
private: private:
static Severity minSeverity; static Severity minSeverity;
static void logInternal(const char* file, uint line, Severity severity, const char* macroArgs, static void logInternal(const char* file, int line, Severity severity, const char* macroArgs,
ArrayPtr<Array<char>> argValues); ArrayPtr<Array<char>> argValues);
static void recoverableFaultInternal( static void recoverableFaultInternal(
const char* file, uint line, Exception::Nature nature, const char* file, int line, Exception::Nature nature,
const char* condition, const char* macroArgs, ArrayPtr<Array<char>> argValues); const char* condition, const char* macroArgs, ArrayPtr<Array<char>> argValues);
static void fatalFaultInternal( static void fatalFaultInternal(
const char* file, uint line, Exception::Nature nature, const char* file, int line, Exception::Nature nature,
const char* condition, const char* macroArgs, ArrayPtr<Array<char>> argValues) const char* condition, const char* macroArgs, ArrayPtr<Array<char>> argValues)
CAPNPROTO_NORETURN; CAPNPROTO_NORETURN;
}; };
...@@ -113,14 +113,14 @@ ArrayPtr<const char> operator*(const Stringifier&, Log::Severity severity); ...@@ -113,14 +113,14 @@ ArrayPtr<const char> operator*(const Stringifier&, Log::Severity severity);
#endif #endif
template <typename... Params> template <typename... Params>
void Log::log(const char* file, uint line, Severity severity, const char* macroArgs, void Log::log(const char* file, int line, Severity severity, const char* macroArgs,
Params&&... params) { Params&&... params) {
Array<char> argValues[sizeof...(Params)] = {str(params)...}; Array<char> argValues[sizeof...(Params)] = {str(params)...};
logInternal(file, line, severity, macroArgs, arrayPtr(argValues, sizeof...(Params))); logInternal(file, line, severity, macroArgs, arrayPtr(argValues, sizeof...(Params)));
} }
template <typename... Params> template <typename... Params>
void Log::recoverableFault(const char* file, uint line, Exception::Nature nature, void Log::recoverableFault(const char* file, int line, Exception::Nature nature,
const char* condition, const char* macroArgs, Params&&... params) { const char* condition, const char* macroArgs, Params&&... params) {
Array<char> argValues[sizeof...(Params)] = {str(params)...}; Array<char> argValues[sizeof...(Params)] = {str(params)...};
recoverableFaultInternal(file, line, nature, condition, macroArgs, recoverableFaultInternal(file, line, nature, condition, macroArgs,
...@@ -128,7 +128,7 @@ void Log::recoverableFault(const char* file, uint line, Exception::Nature nature ...@@ -128,7 +128,7 @@ void Log::recoverableFault(const char* file, uint line, Exception::Nature nature
} }
template <typename... Params> template <typename... Params>
void Log::fatalFault(const char* file, uint line, Exception::Nature nature, void Log::fatalFault(const char* file, int line, Exception::Nature nature,
const char* condition, const char* macroArgs, Params&&... params) { const char* condition, const char* macroArgs, Params&&... params) {
Array<char> argValues[sizeof...(Params)] = {str(params)...}; Array<char> argValues[sizeof...(Params)] = {str(params)...};
fatalFaultInternal(file, line, nature, condition, macroArgs, fatalFaultInternal(file, line, nature, condition, macroArgs,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment