mirror of https://github.com/djcb/mu.git
logger: create logdir if non-existent
This commit is contained in:
parent
d90692e27b
commit
9b8a0146e0
|
@ -49,6 +49,13 @@ maybe_open_logfile()
|
||||||
if (MuStream.is_open())
|
if (MuStream.is_open())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
const auto logdir{to_string_gchar(g_path_get_dirname(MuLogPath.c_str()))};
|
||||||
|
if (g_mkdir_with_parents(logdir.c_str(), 0700) != 0) {
|
||||||
|
std::cerr << "creating " << logdir << " failed:" << g_strerror(errno)
|
||||||
|
<< std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
MuStream.open(MuLogPath, std::ios::out | std::ios::app);
|
MuStream.open(MuLogPath, std::ios::out | std::ios::app);
|
||||||
if (!MuStream.is_open()) {
|
if (!MuStream.is_open()) {
|
||||||
std::cerr << "opening " << MuLogPath << " failed:" << g_strerror(errno)
|
std::cerr << "opening " << MuLogPath << " failed:" << g_strerror(errno)
|
||||||
|
|
Loading…
Reference in New Issue