Place FmtLogMessage's definition in backend.cpp
I decided to overload LogMessage because I don't see a reason to come up with a new function name just for this, but if you guys want me to overload FmtLogMessage instead I'm fine with that.
This commit is contained in:
parent
ceeb2810fe
commit
c892cea029
3 changed files with 34 additions and 34 deletions
|
@ -153,9 +153,12 @@ void LogMessage(Class log_class, Level log_level, const char* filename, unsigned
|
||||||
PrintColoredMessage(entry);
|
PrintColoredMessage(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogEntry(Entry& entry) {
|
void LogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num,
|
||||||
if (filter && !filter->CheckMessage(entry.log_class, entry.log_level))
|
const char* function, const char* format, const fmt::format_args& args) {
|
||||||
|
if (filter && !filter->CheckMessage(log_class, log_level))
|
||||||
return;
|
return;
|
||||||
|
Entry entry =
|
||||||
|
CreateEntry(log_class, log_level, filename, line_num, function, fmt::vformat(format, args));
|
||||||
|
|
||||||
PrintColoredMessage(entry);
|
PrintColoredMessage(entry);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,26 @@ namespace Log {
|
||||||
|
|
||||||
class Filter;
|
class Filter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A log entry. Log entries are store in a structured format to permit more varied output
|
||||||
|
* formatting on different frontends, as well as facilitating filtering and aggregation.
|
||||||
|
*/
|
||||||
|
struct Entry {
|
||||||
|
std::chrono::microseconds timestamp;
|
||||||
|
Class log_class;
|
||||||
|
Level log_level;
|
||||||
|
std::string filename;
|
||||||
|
unsigned int line_num;
|
||||||
|
std::string function;
|
||||||
|
std::string message;
|
||||||
|
|
||||||
|
Entry() = default;
|
||||||
|
Entry(Entry&& o) = default;
|
||||||
|
|
||||||
|
Entry& operator=(Entry&& o) = default;
|
||||||
|
Entry& operator=(const Entry& o) = default;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the passed log class as a C-string. Subclasses are separated by periods
|
* Returns the name of the passed log class as a C-string. Subclasses are separated by periods
|
||||||
* instead of underscores as in the enumeration.
|
* instead of underscores as in the enumeration.
|
||||||
|
@ -25,5 +45,9 @@ const char* GetLogClassName(Class log_class);
|
||||||
*/
|
*/
|
||||||
const char* GetLevelName(Level log_level);
|
const char* GetLevelName(Level log_level);
|
||||||
|
|
||||||
|
/// Creates a log entry by formatting the given source location, and message.
|
||||||
|
Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr,
|
||||||
|
const char* function, std::string message);
|
||||||
|
|
||||||
void SetFilter(Filter* filter);
|
void SetFilter(Filter* filter);
|
||||||
} // namespace Log
|
} // namespace Log
|
||||||
|
|
|
@ -99,33 +99,6 @@ enum class Class : ClassType {
|
||||||
Count ///< Total number of logging classes
|
Count ///< Total number of logging classes
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* A log entry. Log entries are store in a structured format to permit more varied output
|
|
||||||
* formatting on different frontends, as well as facilitating filtering and aggregation.
|
|
||||||
*/
|
|
||||||
struct Entry {
|
|
||||||
std::chrono::microseconds timestamp;
|
|
||||||
Class log_class;
|
|
||||||
Level log_level;
|
|
||||||
std::string filename;
|
|
||||||
unsigned int line_num;
|
|
||||||
std::string function;
|
|
||||||
std::string message;
|
|
||||||
|
|
||||||
Entry() = default;
|
|
||||||
Entry(Entry&& o) = default;
|
|
||||||
|
|
||||||
Entry& operator=(Entry&& o) = default;
|
|
||||||
Entry& operator=(const Entry& o) = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Creates a log entry by formatting the given source location, and message.
|
|
||||||
Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr,
|
|
||||||
const char* function, std::string message);
|
|
||||||
|
|
||||||
// Logs an Entry
|
|
||||||
void LogEntry(Entry& entry);
|
|
||||||
|
|
||||||
/// Logs a message to the global logger.
|
/// Logs a message to the global logger.
|
||||||
void LogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num,
|
void LogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num,
|
||||||
const char* function,
|
const char* function,
|
||||||
|
@ -139,14 +112,14 @@ void LogMessage(Class log_class, Level log_level, const char* filename, unsigned
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
/// Logs a message to the global logger, this time with 100% moar fmtlib
|
/// Logs a message to the global logger, using fmt
|
||||||
|
void LogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num,
|
||||||
|
const char* function, const char* format, const fmt::format_args& args);
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num,
|
void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num,
|
||||||
const char* function, const char* format, const Args&... args) {
|
const char* function, const char* format, const Args&... args) {
|
||||||
Entry entry = CreateEntry(log_class, log_level, filename, line_num, function,
|
LogMessage(log_class, log_level, filename, line_num, function, format, fmt::make_args(args...));
|
||||||
fmt::format(format, args...));
|
|
||||||
|
|
||||||
LogEntry(entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Log
|
} // namespace Log
|
||||||
|
|
Loading…
Reference in a new issue