Skip to content

Commit

Permalink
Improve error log handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernthedev committed Oct 30, 2023
1 parent 978fce9 commit 5089e23
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,11 @@ constexpr auto globalFileName = "PaperLog.log";
static bool inited = false;

template <typename... TArgs>
inline void WriteStdOut(int level, std::string_view ctx, std::string_view s,
TArgs &&...args) {
inline void WriteStdOut(int level, std::string_view ctx, std::string_view s) {
#ifdef PAPERLOG_ANDROID_LOG
__android_log_write(
level, ctx.data(),
fmt::format(fmt::runtime(s), std::forward<TArgs>(args)...).data());
s.data());
#endif

#ifdef PAPERLOG_FMT_C_STDOUT
Expand All @@ -93,8 +92,7 @@ namespace Paper::Logger {
}

WriteStdOut(ANDROID_LOG_INFO, "PAPERLOG",
"Logging paper to folder %s and file %s", logPath.data(),
globalFileName);
"Logging paper to folder " + std::string(logPath) + "and file " + globalFileName);

globalLoggerConfig = {config};
globalLogPath = logPath;
Expand Down Expand Up @@ -142,7 +140,7 @@ Paper::LoggerConfig& GlobalConfig() {
}

inline void logError(std::string_view error) {
WriteStdOut((int)Paper::LogLevel::ERR, "PAPERLOG", "%s", error.data());
WriteStdOut((int)Paper::LogLevel::ERR, "PAPERLOG", error);
if (globalFile.is_open()) {
globalFile << error << std::endl;
}
Expand Down

0 comments on commit 5089e23

Please sign in to comment.