| 19 | namespace util::log { |
| 20 | |
| 21 | std::string ProgramDataPath() { |
| 22 | std::string app_data_path; |
| 23 | #ifdef WIN32 |
| 24 | WCHAR *path = nullptr; |
| 25 | const auto ret = |
| 26 | ::SHGetKnownFolderPath(FOLDERID_ProgramData, 0, nullptr, &path); |
| 27 | if (ret == S_OK) { |
| 28 | const std::wstring temp(path); |
| 29 | std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> conv; |
| 30 | app_data_path = conv.to_bytes(temp); |
| 31 | } |
| 32 | if (path != nullptr) { |
| 33 | CoTaskMemFree(path); |
| 34 | } |
| 35 | #endif |
| 36 | |
| 37 | return app_data_path; |
| 38 | } |
| 39 | LogConfig &LogConfig::Instance() { |
| 40 | static LogConfig log_config; |
| 41 | return log_config; |