Fix crashing on windows when registering a file logger after a console logger, windows runtime bugs annoy the hell out of me >:(

This commit is contained in:
2020-12-31 13:53:26 -08:00
parent 81fb4e4c2d
commit 8913e55e34
2 changed files with 20 additions and 7 deletions

View File

@@ -17,6 +17,7 @@
#endif
extern "C" void logvisorBp();
#define log_typeid(type) std::hash<std::string>()(#type)
namespace logvisor {
@@ -43,6 +44,10 @@ enum Level {
* @brief Backend interface for receiving app-wide log events
*/
struct ILogger {
private:
uint64_t m_typeHash;
public:
ILogger(uint64_t typeHash) : m_typeHash(typeHash) {}
virtual ~ILogger() = default;
virtual void report(const char* modName, Level severity, fmt::string_view format, fmt::format_args args) = 0;
virtual void report(const char* modName, Level severity, fmt::wstring_view format, fmt::wformat_args args) = 0;
@@ -50,6 +55,8 @@ struct ILogger {
fmt::string_view format, fmt::format_args args) = 0;
virtual void reportSource(const char* modName, Level severity, const char* file, unsigned linenum,
fmt::wstring_view format, fmt::wformat_args args) = 0;
[[nodiscard]] uint64_t getTypeId() const { return m_typeHash; }
};
/**