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