add exception property to logger item
This commit is contained in:
parent
2f72422afe
commit
4ed1e4cd55
@ -26,8 +26,12 @@ class Logger : public Interface {
|
|||||||
Item() = delete;
|
Item() = delete;
|
||||||
Item(Level level,
|
Item(Level level,
|
||||||
std::string_view contents,
|
std::string_view contents,
|
||||||
std::source_location srcloc = std::source_location::current()) noexcept
|
std::source_location srcloc = std::source_location::current(),
|
||||||
: level_(level), contents_(contents), srcloc_(srcloc) { }
|
std::exception_ptr ex = std::current_exception()) noexcept
|
||||||
|
: level_(level),
|
||||||
|
contents_(contents),
|
||||||
|
srcloc_(srcloc),
|
||||||
|
exception_(ex) { }
|
||||||
|
|
||||||
Item(const Item&) = default;
|
Item(const Item&) = default;
|
||||||
Item(Item&&) = default;
|
Item(Item&&) = default;
|
||||||
@ -37,11 +41,13 @@ class Logger : public Interface {
|
|||||||
Level level() const noexcept { return level_; }
|
Level level() const noexcept { return level_; }
|
||||||
const std::string& contents() const noexcept { return contents_; }
|
const std::string& contents() const noexcept { return contents_; }
|
||||||
const std::source_location& srcloc() const noexcept { return srcloc_; }
|
const std::source_location& srcloc() const noexcept { return srcloc_; }
|
||||||
|
const std::exception_ptr& exception() const noexcept { return exception_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Level level_;
|
Level level_;
|
||||||
std::string contents_;
|
std::string contents_;
|
||||||
std::source_location srcloc_;
|
std::source_location srcloc_;
|
||||||
|
std::exception_ptr exception_;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -53,28 +59,31 @@ class Logger : public Interface {
|
|||||||
|
|
||||||
// THREAD-SAFE
|
// THREAD-SAFE
|
||||||
void Trace(std::string_view contents,
|
void Trace(std::string_view contents,
|
||||||
SrcLoc srcloc = SrcLoc::current()) noexcept {
|
SrcLoc srcloc = SrcLoc::current(),
|
||||||
Push(Item {kTrace, contents, srcloc});
|
std::exception_ptr ex = std::current_exception()) noexcept {
|
||||||
|
Push(Item {kTrace, contents, srcloc, ex});
|
||||||
}
|
}
|
||||||
|
|
||||||
// THREAD-SAFE
|
// THREAD-SAFE
|
||||||
void Info(std::string_view contents,
|
void Info(std::string_view contents,
|
||||||
SrcLoc srcloc = SrcLoc::current()) noexcept {
|
SrcLoc srcloc = SrcLoc::current(),
|
||||||
Push(Item {kInfo, contents, srcloc});
|
std::exception_ptr ex = std::current_exception()) noexcept {
|
||||||
|
Push(Item {kInfo, contents, srcloc, ex});
|
||||||
}
|
}
|
||||||
|
|
||||||
// THREAD-SAFE
|
// THREAD-SAFE
|
||||||
void Warn(std::string_view contents,
|
void Warn(std::string_view contents,
|
||||||
SrcLoc srcloc = SrcLoc::current()) noexcept {
|
SrcLoc srcloc = SrcLoc::current(),
|
||||||
Push(Item {kWarn, contents, srcloc});
|
std::exception_ptr ex = std::current_exception()) noexcept {
|
||||||
|
Push(Item {kWarn, contents, srcloc, ex});
|
||||||
}
|
}
|
||||||
|
|
||||||
// THREAD-SAFE
|
// THREAD-SAFE
|
||||||
void Error(std::string_view contents,
|
void Error(std::string_view contents,
|
||||||
SrcLoc srcloc = SrcLoc::current()) noexcept {
|
SrcLoc srcloc = SrcLoc::current(),
|
||||||
Push(Item {kError, contents, srcloc});
|
std::exception_ptr ex = std::current_exception()) noexcept {
|
||||||
|
Push(Item {kError, contents, srcloc, ex});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace nf7::subsys
|
} // namespace nf7::subsys
|
||||||
|
Loading…
x
Reference in New Issue
Block a user