2017-08-08 13:53:47 +02:00
|
|
|
#include "Logger.h"
|
|
|
|
|
2018-10-25 12:21:22 +11:00
|
|
|
#include <spdlog/spdlog.h>
|
|
|
|
#include <spdlog/sinks/stdout_color_sinks.h>
|
|
|
|
#include <spdlog/sinks/daily_file_sink.h>
|
|
|
|
|
|
|
|
// #include <iostream>
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
|
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
Logger::Logger()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Logger::~Logger()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Logger::setLogPath( const std::string& logPath )
|
|
|
|
{
|
|
|
|
m_logFile = logPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Logger::init()
|
|
|
|
{
|
|
|
|
|
2018-10-25 12:21:22 +11:00
|
|
|
std::vector< spdlog::sink_ptr > sinks;
|
|
|
|
|
|
|
|
sinks.push_back( std::make_shared< spdlog::sinks::stdout_color_sink_mt >() );
|
|
|
|
sinks.push_back( std::make_shared< spdlog::sinks::daily_file_sink_mt >( m_logFile, 0, 0 ) );
|
|
|
|
|
|
|
|
m_logger = std::make_shared< spdlog::logger >( "logger", std::begin( sinks ), std::end( sinks ) );
|
|
|
|
|
|
|
|
//spdlog::set_pattern( "[%H:%M:%S] [%l] %v" );
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Logger::Log( LoggingSeverity logSev, const std::string& text )
|
|
|
|
{
|
2018-10-25 12:21:22 +11:00
|
|
|
// BOOST_LOG_SEV( m_lg, ( boost::log::trivial::severity_level ) logSev ) << text;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Logger::error( const std::string& text )
|
|
|
|
{
|
2018-10-25 12:21:22 +11:00
|
|
|
m_logger->error( text );
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Logger::info( const std::string& text )
|
|
|
|
{
|
2018-10-25 12:21:22 +11:00
|
|
|
m_logger->info( text );
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Logger::debug( const std::string& text )
|
|
|
|
{
|
2018-10-25 12:21:22 +11:00
|
|
|
m_logger->debug( text );
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Logger::fatal( const std::string& text )
|
|
|
|
{
|
2018-10-25 12:21:22 +11:00
|
|
|
m_logger->critical( text );
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
}
|