log/level: move level_width
query into level unit
This commit is contained in:
parent
b8d0d50c6a
commit
78608c2a61
@ -136,3 +136,34 @@ cruft::log::log_level (void)
|
||||
|
||||
return s_log_level_value;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
std::size_t
|
||||
cruft::log::level_width (void)
|
||||
{
|
||||
static constexpr
|
||||
cruft::log::level_t
|
||||
ALL_LEVELS[] = {
|
||||
cruft::log::EMERGENCY,
|
||||
cruft::log::ALERT,
|
||||
cruft::log::CRITICAL,
|
||||
cruft::log::ERROR,
|
||||
cruft::log::WARN,
|
||||
cruft::log::NOTICE,
|
||||
cruft::log::INFO,
|
||||
cruft::log::DEBUG,
|
||||
};
|
||||
|
||||
|
||||
static std::size_t width = [] {
|
||||
size_t hi = 0;
|
||||
|
||||
for (auto i: ALL_LEVELS)
|
||||
hi = cruft::max (to_string (i).size (), hi);
|
||||
|
||||
return hi;
|
||||
} ();
|
||||
|
||||
return width;
|
||||
}
|
||||
|
@ -77,4 +77,7 @@ namespace cruft::log {
|
||||
|
||||
bool needs_break (level_t);
|
||||
|
||||
|
||||
/// Calculate the maximum width, in characters, of all level names.
|
||||
std::size_t level_width (void);
|
||||
}
|
||||
|
@ -24,37 +24,6 @@
|
||||
using cruft::log::sink::console;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
static std::size_t
|
||||
level_width (void)
|
||||
{
|
||||
static constexpr
|
||||
cruft::log::level_t
|
||||
ALL_LEVELS[] = {
|
||||
cruft::log::EMERGENCY,
|
||||
cruft::log::ALERT,
|
||||
cruft::log::CRITICAL,
|
||||
cruft::log::ERROR,
|
||||
cruft::log::WARN,
|
||||
cruft::log::NOTICE,
|
||||
cruft::log::INFO,
|
||||
cruft::log::DEBUG,
|
||||
};
|
||||
|
||||
|
||||
static size_t width = [] {
|
||||
size_t hi = 0;
|
||||
|
||||
for (auto i: ALL_LEVELS)
|
||||
hi = cruft::max (to_string (i).size (), hi);
|
||||
|
||||
return hi;
|
||||
} ();
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
static
|
||||
cruft::term::csi::graphics
|
||||
|
Loading…
Reference in New Issue
Block a user