Get rid of a logging helper

This commit is contained in:
blankie 2023-01-16 11:08:35 +07:00
parent 381b34f731
commit d2006d5a4e
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
5 changed files with 3 additions and 13 deletions

View File

@ -25,7 +25,7 @@ static void fclose_and_log(FILE* file) {
return; return;
} }
std::system_error e = std::system_error(errno, std::generic_category(), "fclose()"); std::system_error e = std::system_error(errno, std::generic_category(), "fclose()");
log("Failed to close a file", std::move(e)); log(std::string("Failed to close a file: ") + e.what());
} }
static bool write(const std::string& ptr, FILE* file) { static bool write(const std::string& ptr, FILE* file) {

View File

@ -8,7 +8,7 @@ static inline void write_config_and_update_structures(const Config& config) {
try { try {
write_config(config); write_config(config);
} catch (const std::exception& e) { } catch (const std::exception& e) {
log("Failed to write config", e); log(std::string("Failed to write config: ") + e.what());
return; return;
} }
} }

View File

@ -29,11 +29,3 @@ void log(std::string entry, time_t time) {
void log(std::string entry) { void log(std::string entry) {
log(std::move(entry), time(nullptr)); log(std::move(entry), time(nullptr));
} }
void log(std::string action, const std::exception& e, time_t time) {
log(action + ": " + e.what(), time);
}
void log(std::string action, const std::exception& e) {
log(std::move(action), e, time(nullptr));
}

2
log.h
View File

@ -8,5 +8,3 @@ extern std::string log_entries;
void log(std::string entry, time_t time); void log(std::string entry, time_t time);
void log(std::string entry); void log(std::string entry);
void log(std::string action, const std::exception& e, time_t time);
void log(std::string action, const std::exception& e);

View File

@ -117,7 +117,7 @@ int main(int, char**) {
io.Fonts->AddFontFromFileTTF(fonts.first.c_str(), config.normal_font_size); io.Fonts->AddFontFromFileTTF(fonts.first.c_str(), config.normal_font_size);
monospace_font = io.Fonts->AddFontFromFileTTF(fonts.second.c_str(), config.monospace_font_size); monospace_font = io.Fonts->AddFontFromFileTTF(fonts.second.c_str(), config.monospace_font_size);
} catch (const std::exception& e) { } catch (const std::exception& e) {
log("Failed to get fonts", e); log(std::string("Failed to get fonts: ") + e.what());
} }
#endif #endif
if (!monospace_font) { if (!monospace_font) {