1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-25 14:07:46 +00:00
sapphire/src/common/Logging/Logger.h

78 lines
1.6 KiB
C
Raw Normal View History

2017-08-08 13:53:47 +02:00
#ifndef _LOGGER_H
2018-10-26 19:57:39 +11:00
#define _LOGGER_H
2017-08-08 13:53:47 +02:00
2018-10-26 20:06:12 +11:00
#include <string>
2017-08-08 13:53:47 +02:00
2019-01-04 21:46:37 +11:00
#include <spdlog/fmt/fmt.h>
namespace Sapphire
{
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
class Logger
{
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
private:
std::string m_logFile;
Logger();
~Logger();
2017-08-08 13:53:47 +02:00
2018-12-23 03:53:08 +01:00
public:
2017-08-08 13:53:47 +02:00
2018-12-23 03:53:08 +01:00
static void init( const std::string& logPath );
2017-08-08 13:53:47 +02:00
2019-01-04 21:46:37 +11:00
// todo: this is a minor increase in build time because of fmtlib, but much less than including spdlog directly
2018-12-23 03:53:08 +01:00
static void error( const std::string& text );
2019-01-04 21:46:37 +11:00
template< typename... Args >
static void error( const std::string& fmt, const Args&... args )
{
error( fmt::format( fmt, args... ) );
}
2017-08-08 13:53:47 +02:00
static void warn( const std::string& text );
2019-01-04 21:46:37 +11:00
template< typename... Args >
static void warn( const std::string& fmt, const Args&... args )
{
warn( fmt::format( fmt, args... ) );
}
2018-12-23 03:53:08 +01:00
static void info( const std::string& text );
2019-01-04 21:46:37 +11:00
template< typename... Args >
static void info( const std::string& fmt, const Args&... args )
{
info( fmt::format( fmt, args... ) );
}
2017-08-08 13:53:47 +02:00
2018-12-23 03:53:08 +01:00
static void debug( const std::string& text );
2019-01-04 21:46:37 +11:00
template< typename... Args >
static void debug( const std::string& fmt, const Args&... args )
{
debug( fmt::format( fmt, args... ) );
}
2018-12-23 03:53:08 +01:00
static void fatal( const std::string& text );
2019-01-04 21:46:37 +11:00
template< typename... Args >
static void fatal( const std::string& fmt, const Args&... args )
{
fatal( fmt::format( fmt, args... ) );
}
2017-08-08 13:53:47 +02:00
static void trace( const std::string& text );
2019-01-04 21:46:37 +11:00
template< typename... Args >
static void trace( const std::string& fmt, const Args&... args )
{
trace( fmt::format( fmt, args... ) );
}
2018-10-28 21:53:21 +01:00
};
2017-08-08 13:53:47 +02:00
}
2017-08-08 13:53:47 +02:00
2018-09-26 08:47:22 -04:00
#endif