Simplify by replacing is_convertible_to_sv with string_view_t param

This commit is contained in:
gabime 2023-09-15 22:25:50 +03:00
parent b19ceb6d0a
commit 3eea04bcd3
2 changed files with 25 additions and 40 deletions

View File

@ -103,16 +103,15 @@ public:
}
// log with no format string, just string message
template<typename S, typename = is_convertible_to_sv<S>>
void log(source_loc loc, level::level_enum lvl, S msg)
void log(source_loc loc, level::level_enum lvl, string_view_t msg)
{
if (should_log(lvl))
{
sink_it_(details::log_msg(loc, name_, lvl, msg));
}
}
template<typename S, typename = is_convertible_to_sv<S>>
void log(level::level_enum lvl, S msg)
void log(level::level_enum lvl, string_view_t msg)
{
if (should_log(lvl))
{
@ -169,38 +168,36 @@ public:
}
// log functions with no format string, just string
template<typename S, typename = is_convertible_to_sv<S>>
void trace(const S msg, source_loc loc = source_loc::current())
void trace(string_view_t msg, source_loc loc = source_loc::current())
{
log(loc, level::trace, msg);
}
template<typename S, typename = is_convertible_to_sv<S>>
void debug(const S msg, source_loc loc = source_loc::current())
void debug(string_view_t msg, source_loc loc = source_loc::current())
{
log(loc, level::debug, msg);
}
template<typename S, typename = is_convertible_to_sv<S>>
void info(const S msg, source_loc loc = source_loc::current())
void info(string_view_t msg, source_loc loc = source_loc::current())
{
log(loc, level::info, msg);
}
template<typename S, typename = is_convertible_to_sv<S>>
void warn(const S msg, source_loc loc = source_loc::current())
void warn(string_view_t msg, source_loc loc = source_loc::current())
{
log(loc, level::warn, msg);
}
template<typename S, typename = is_convertible_to_sv<S>>
void error(const S msg, source_loc loc = source_loc::current())
void error(string_view_t msg, source_loc loc = source_loc::current())
{
log(loc, level::err, msg);
}
template<typename S, typename = is_convertible_to_sv<S>>
void critical(const S msg, source_loc loc = source_loc::current())
void critical(string_view_t msg, source_loc loc = source_loc::current())
{
log(loc, level::critical, msg);
}
@ -242,38 +239,32 @@ public:
}
// log functions with no format string, just string
template<typename S, typename = is_convertible_to_sv<S>>
void trace(const S msg)
void trace(string_view_t msg)
{
log(level::trace, msg);
}
template<typename S, typename = is_convertible_to_sv<S>>
void debug(const S msg)
void debug(string_view_t msg)
{
log(level::debug, msg);
}
template<typename S, typename = is_convertible_to_sv<S>>
void info(const S msg)
void info(string_view_t msg)
{
log(level::info, msg);
}
template<typename S, typename = is_convertible_to_sv<S>>
void warn(const S msg)
inline void warn(string_view_t msg)
{
log(level::warn, msg);
}
template<typename S, typename = is_convertible_to_sv<S>>
void error(const S msg)
void error(string_view_t msg)
{
log(level::err, msg);
}
template<typename S, typename = is_convertible_to_sv<S>>
void critical(const S msg)
void critical(string_view_t msg)
{
log(level::critical, msg);
}

View File

@ -266,38 +266,32 @@ void critical(format_string_t<Args...> fmt, Args &&...args)
}
// log functions with no format string, just string
template<typename S, typename = is_convertible_to_sv<S>>
void trace(const S msg)
inline void trace(string_view_t msg)
{
log(level::trace, msg);
}
template<typename S, typename = is_convertible_to_sv<S>>
void debug(const S msg)
inline void debug(string_view_t msg)
{
log(level::debug, msg);
}
template<typename S, typename = is_convertible_to_sv<S>>
void info(const S msg)
inline void info(string_view_t msg)
{
log(level::info, msg);
}
template<typename S, typename = is_convertible_to_sv<S>>
void warn(const S msg)
inline void warn(string_view_t msg)
{
log(level::warn, msg);
}
template<typename S, typename = is_convertible_to_sv<S>>
void error(const S msg)
inline void error(string_view_t msg)
{
log(level::err, msg);
}
template<typename S, typename = is_convertible_to_sv<S>>
void critical(const S msg)
inline void critical(string_view_t msg)
{
log(level::critical, msg);
}