Make log_path a variable again.

We don't need log_dir() twice afterall.
This commit is contained in:
tastytea 2021-06-01 11:07:34 +02:00
parent a8f2b7dfb6
commit 12a1c47259
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 20 additions and 22 deletions

View File

@ -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);

View File

@ -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();