diff options
author | Ed Tanous <edtanous@google.com> | 2021-12-01 23:50:35 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2021-12-10 21:40:56 +0300 |
commit | df5415fc03b458eedfcb07a6be262d1067a50aec (patch) | |
tree | 5f2d7a93599d7268b1d8daa70da70346b5aba7c1 /redfish-core/src/error_messages.cpp | |
parent | f523c3246920e8be6320f9c761f6c975c61c9e0d (diff) | |
download | bmcweb-df5415fc03b458eedfcb07a6be262d1067a50aec.tar.xz |
Add logging to internal error
Internal error call sites are propagated through the code, and might be
triggered multiple times in the course of a request, which makes them
difficult to track the source of.
This commit changes the internalError() method to include a print of
which invocation within bmcweb triggered the error, using c++20s
std::source_location mechanism.
Note:
clang-13 still doesn't implement std::source_location, so this commit
pulls source_location.hpp from lg2 to be able to support all compilers.
Tested:
Loaded in qemu, and added an internalError() call into systems.hpp for
the /redfish/v1/Systems handler. Observed that
[CRITICAL "error_messages.cpp":234] Internal Error
../../../../../../workspace/sources/bmcweb/redfish-core/include/../lib/systems.hpp(2820:40)
`redfish::requestRoutesSystemsCollection(App&)::<lambda(const
crow::Request&, const std::shared_ptr<bmcweb::AsyncResp>&)>`:
Got printed to the bmcweb logs.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ic1b4240422445357bc87404de814ad14f86b9edf
Diffstat (limited to 'redfish-core/src/error_messages.cpp')
-rw-r--r-- | redfish-core/src/error_messages.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp index 9c28e8f804..cb4d69c226 100644 --- a/redfish-core/src/error_messages.cpp +++ b/redfish-core/src/error_messages.cpp @@ -229,8 +229,11 @@ nlohmann::json internalError(void) "consider resetting the service."}}; } -void internalError(crow::Response& res) +void internalError(crow::Response& res, const bmcweb::source_location location) { + BMCWEB_LOG_CRITICAL << "Internal Error " << location.file_name() << "(" + << location.line() << ":" << location.column() << ") `" + << location.function_name() << "`: "; res.result(boost::beast::http::status::internal_server_error); addMessageToErrorJson(res.jsonValue, internalError()); } |