Skip to content

Commit 39a8180

Browse files
authored
Use tt-logger in assert.hpp (#23722)
### Ticket NA ### Problem description The assertion macros were logging critical errors ahead of abort / exception throwing using spdlog directly (default logger). This means that they were always printing to stdout no matter what, and we had no option to log to a file. ### What's changed - Use `tt-logger` logging macros instead. An earlier version of `tt-logger` was struggling to handle this section of code, so I side stepped it by directly using spdlog. However, the latest version of `tt-logger` seems to handle this usage without an issue. ### Checklist - [x] [All post commit](https://github.com/tenstorrent/tt-metal/actions/runs/15736013791) CI passes - [x] New/Existing tests provide coverage for changes
1 parent fb497a8 commit 39a8180

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

tt_metal/api/tt-metalium/assert.hpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,6 @@ static std::string demangle(const char* str) {
4848
return str;
4949
}
5050

51-
// Logging functions for assert usage
52-
template <typename... Args>
53-
inline void metal_log_fatal(fmt::format_string<const Args&...> fmt_str, const Args&... args) {
54-
spdlog::critical("[Always] {}", fmt::format(fmt_str, args...));
55-
}
56-
57-
template <typename... Args>
58-
inline void metal_log_debug(fmt::format_string<const Args&...> fmt_str, const Args&... args) {
59-
spdlog::debug("[Always] {}", fmt::format(fmt_str, args...));
60-
}
61-
6251
// https://www.fatalerrors.org/a/backtrace-function-and-assert-assertion-macro-encapsulation.html
6352

6453
/**
@@ -105,8 +94,7 @@ template <typename... Args>
10594
char const* file, int line, char const* assert_type, char const* condition_str, Args const&... args) {
10695
if (std::getenv("TT_ASSERT_ABORT")) {
10796
if constexpr (sizeof...(args) > 0) {
108-
tt::assert::metal_log_fatal(args...);
109-
spdlog::default_logger()->flush();
97+
log_critical(tt::LogAlways, args...);
11098
}
11199
abort();
112100
}
@@ -116,8 +104,7 @@ template <typename... Args>
116104
if constexpr (sizeof...(args) > 0) {
117105
trace_message_ss << "info:" << std::endl;
118106
trace_message_ss << fmt::format(args...) << std::endl;
119-
tt::assert::metal_log_debug(args...);
120-
spdlog::default_logger()->flush();
107+
log_critical(tt::LogAlways, args...);
121108
}
122109
trace_message_ss << "backtrace:\n";
123110
trace_message_ss << tt::assert::backtrace_to_string(100, 3, " --- ");

0 commit comments

Comments
 (0)