Skip to content

Commit

Permalink
fix logger
Browse files Browse the repository at this point in the history
  • Loading branch information
markaren committed Oct 18, 2024
1 parent 35d53f7 commit 897f3f5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
27 changes: 26 additions & 1 deletion include/ecos/logger/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ enum class level : int

void set_logging_level(level lvl);

void log(level lvl, const std::string& msg);
void log(level lvl, std::string_view msg);

template<typename... Args>
void trace(fmt::format_string<Args...> fmt, Args&&... args)
Expand Down Expand Up @@ -51,6 +51,31 @@ void err(fmt::format_string<Args...> fmt, Args&&... args)
log(level::err, fmt::format(fmt, std::forward<Args>(args)...));
}

inline void trace(std::string_view msg)
{
log(level::trace, msg);
}

inline void debug(std::string_view msg)
{
log(level::debug, msg);
}

inline void info(std::string_view msg)
{
log(level::info, msg);
}

inline void warn(std::string_view msg)
{
log(level::warn, msg);
}

inline void err(std::string_view msg)
{
log(level::err, msg);
}

} // namespace ecos::log


Expand Down
4 changes: 2 additions & 2 deletions src/ecos/logger/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct ecos_logger
logger_->set_level(convert(lvl));
}

void log(log::level lvl, const std::string& msg)
void log(log::level lvl, std::string_view msg)
{
logger_->log(convert(lvl), msg);
}
Expand All @@ -65,7 +65,7 @@ void log::set_logging_level(level lvl)
ecos_logger::get_instance().set_level(lvl);
}

void log::log(log::level lvl, const std::string& msg)
void log::log(log::level lvl, std::string_view msg)
{
ecos_logger::get_instance().log(lvl, msg);
}

0 comments on commit 897f3f5

Please sign in to comment.