Make log_path a variable again.
We don't need log_dir() twice afterall.
This commit is contained in:
parent
a8f2b7dfb6
commit
12a1c47259
40
src/log.cpp
40
src/log.cpp
|
@ -39,29 +39,29 @@ using sev = boost::log::trivial::severity_level;
|
|||
|
||||
inline static global_variables global;
|
||||
|
||||
fs::path log_dir()
|
||||
{
|
||||
fs::path path{helpers::get_env("XDG_STATE_HOME")};
|
||||
if (path.empty())
|
||||
{
|
||||
path = helpers::get_env("HOME");
|
||||
if (!path.empty())
|
||||
{
|
||||
path /= ".local";
|
||||
path /= "state";
|
||||
}
|
||||
}
|
||||
if (!path.empty())
|
||||
{
|
||||
return path /= "epubgrep";
|
||||
}
|
||||
return fs::path{};
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
const auto log_path{[]
|
||||
{
|
||||
fs::path path{helpers::get_env("XDG_STATE_HOME")};
|
||||
if (path.empty())
|
||||
{
|
||||
path = helpers::get_env("HOME");
|
||||
if (!path.empty())
|
||||
{
|
||||
path /= ".local";
|
||||
path /= "state";
|
||||
}
|
||||
}
|
||||
if (!path.empty())
|
||||
{
|
||||
path /= "epubgrep";
|
||||
}
|
||||
return path / "epubgrep.log";
|
||||
}()};
|
||||
|
||||
global.textlog = blog::add_file_log(
|
||||
keywords::file_name = (log_dir() / "epubgrep.log").c_str(),
|
||||
keywords::file_name = log_path.c_str(),
|
||||
keywords::format = "%LineID% [%TimeStamp%] "
|
||||
"[%ThreadID%]: [%Severity%] %Message%");
|
||||
global.textlog->set_filter(blog::trivial::severity >= sev::info);
|
||||
|
|
|
@ -45,8 +45,6 @@ struct global_variables
|
|||
BOOST_LOG_INLINE_GLOBAL_LOGGER_DEFAULT(
|
||||
logger, boost::log::sources::severity_logger_mt<sev>)
|
||||
|
||||
fs::path log_dir();
|
||||
|
||||
void init();
|
||||
|
||||
void init_debug();
|
||||
|
|
Loading…
Reference in New Issue
Block a user