pre-release
This commit is contained in:
@@ -10,7 +10,7 @@ Logger::Logger( int LOG_LEVEL, std::string mask )
|
||||
this->mask = mask;
|
||||
|
||||
setlogmask( LOG_UPTO( this->LOG_LEVEL ) );
|
||||
openlog( this->mask.c_str(), LOG_CONS | LOG_PID | LOG_NDELAY, LOG_PERROR | LOG_LOCAL1 );
|
||||
openlog( "rex", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_PERROR | LOG_LOCAL1 );
|
||||
|
||||
}
|
||||
|
||||
@@ -33,19 +33,10 @@ void Logger::log( int LOG_LEVEL, std::string msg )
|
||||
|
||||
if ( LOG_LEVEL == E_FATAL | LOG_LEVEL == E_WARN )
|
||||
{
|
||||
std::cerr << "[" << this->get_8601() << "] [" << ERR << "] " << "[" << this->mask << "] " << msg.c_str() << std::endl;
|
||||
std::cerr << "[" << get_8601() << "] [" << ERR << "] " << "[" << this->mask << "] " << msg.c_str() << std::endl;
|
||||
} else {
|
||||
std::cout << "[" << this->get_8601() << "] [" << ERR << "] " << "[" << this->mask << "] " << msg.c_str() << std::endl;
|
||||
std::cout << "[" << get_8601() << "] [" << ERR << "] " << "[" << this->mask << "] " << msg.c_str() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string Logger::get_8601()
|
||||
{
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto itt = std::chrono::system_clock::to_time_t(now);
|
||||
std::ostringstream ss;
|
||||
// ss << std::put_time(gmtime(&itt), "%FT%TZ");
|
||||
ss << std::put_time(localtime(&itt), "%Y-%m-%d_%H:%M:%S");
|
||||
return ss.str();
|
||||
}
|
||||
@@ -2,15 +2,15 @@
|
||||
// Created by bagira on 6/13/20.
|
||||
//
|
||||
|
||||
#ifndef EXAMPLAR_LOGGER_H
|
||||
#define EXAMPLAR_LOGGER_H
|
||||
#ifndef REX_LOGGER_H
|
||||
#define REX_LOGGER_H
|
||||
|
||||
#include <syslog.h>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include "../loaders/misc/helpers.h"
|
||||
|
||||
enum L_LVL {
|
||||
E_FATAL,
|
||||
@@ -27,9 +27,8 @@ public:
|
||||
private:
|
||||
int LOG_LEVEL;
|
||||
std::string mask;
|
||||
std::string get_8601();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //EXAMPLAR_LOGGER_H
|
||||
#endif //REX_LOGGER_H
|
||||
|
||||
Reference in New Issue
Block a user