blob: 3df4335b19f40cb7616476b1e62417a2cfc33fc7 [file] [log] [blame]
#pragma once
#include "boottime_api/boottime_api.h"
#include <fmt/printf.h>
namespace boot_time_monitor
{
namespace log
{
/**
* @brief Logs an error message to stderr if the given status is not OK.
*
* This is a utility function that checks an `absl::Status` object. If the
* status represents an error condition (`!status.ok()`), the function
* prints the detailed error string to the standard error stream.
*
* @param status The `absl::Status` to check.
*/
inline void LogIfError(const absl::Status& status)
{
if (!status.ok())
{
fmt::print(stderr, "{}\n", status.ToString());
}
}
} // namespace log
} // namespace boot_time_monitor