mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-07 01:06:45 +08:00
upd: [imp] output interface of the log should be const
This commit is contained in:
parent
f2ae0f5a3a
commit
af96a09e36
@ -114,8 +114,15 @@ class grip {
|
|||||||
char const *func_;
|
char const *func_;
|
||||||
level level_limit_;
|
level level_limit_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
template <typename O>
|
||||||
|
grip(char const *func, O &&out, level level_limit) noexcept
|
||||||
|
: out_ (std::forward<O>(out))
|
||||||
|
, func_ (func)
|
||||||
|
, level_limit_(level_limit) {}
|
||||||
|
|
||||||
template <typename... A>
|
template <typename... A>
|
||||||
grip &output(log::level l, A &&... args) noexcept {
|
grip const &operator()(log::level l, A &&... args) const noexcept {
|
||||||
if (underlyof(l) < underlyof(level_limit_)) {
|
if (underlyof(l) < underlyof(level_limit_)) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -128,19 +135,12 @@ class grip {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
template <typename... A> grip const &trace (A &&...args) const noexcept { return (*this)(log::level::trace , std::forward<A>(args)...); }
|
||||||
template <typename O>
|
template <typename... A> grip const &debug (A &&...args) const noexcept { return (*this)(log::level::debug , std::forward<A>(args)...); }
|
||||||
grip(char const *func, O &&out, level level_limit) noexcept
|
template <typename... A> grip const &info (A &&...args) const noexcept { return (*this)(log::level::info , std::forward<A>(args)...); }
|
||||||
: out_ (std::forward<O>(out))
|
template <typename... A> grip const &warning(A &&...args) const noexcept { return (*this)(log::level::warning, std::forward<A>(args)...); }
|
||||||
, func_ (func)
|
template <typename... A> grip const &error (A &&...args) const noexcept { return (*this)(log::level::error , std::forward<A>(args)...); }
|
||||||
, level_limit_(level_limit) {}
|
template <typename... A> grip const &failed (A &&...args) const noexcept { return (*this)(log::level::failed , std::forward<A>(args)...); }
|
||||||
|
|
||||||
template <typename... A> grip &trace (A &&...args) noexcept { return output(log::level::trace , std::forward<A>(args)...); }
|
|
||||||
template <typename... A> grip &debug (A &&...args) noexcept { return output(log::level::debug , std::forward<A>(args)...); }
|
|
||||||
template <typename... A> grip &info (A &&...args) noexcept { return output(log::level::info , std::forward<A>(args)...); }
|
|
||||||
template <typename... A> grip &warning(A &&...args) noexcept { return output(log::level::warning, std::forward<A>(args)...); }
|
|
||||||
template <typename... A> grip &error (A &&...args) noexcept { return output(log::level::error , std::forward<A>(args)...); }
|
|
||||||
template <typename... A> grip &failed (A &&...args) noexcept { return output(log::level::failed , std::forward<A>(args)...); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename O>
|
template <typename O>
|
||||||
|
|||||||
@ -23,7 +23,7 @@ TEST(log, custom) {
|
|||||||
std::string i;
|
std::string i;
|
||||||
std::string e;
|
std::string e;
|
||||||
} ll_data;
|
} ll_data;
|
||||||
auto ll = [&ll_data](auto &&ctx) mutable {
|
auto ll = [&ll_data](auto &&ctx) {
|
||||||
auto s = imp::fmt(ctx.params);
|
auto s = imp::fmt(ctx.params);
|
||||||
if (ctx.level == imp::log::level::error) ll_data.e += s + " ";
|
if (ctx.level == imp::log::level::error) ll_data.e += s + " ";
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user