Code refactoring.

master
Vectozavr 2021-10-17 14:27:19 +07:00
parent 813f23d655
commit f36d94183a
2 changed files with 10 additions and 6 deletions

View File

@ -12,6 +12,7 @@ namespace Consts {
const int STANDARD_SCREEN_HEIGHT = 1920; const int STANDARD_SCREEN_HEIGHT = 1920;
const sf::Color BACKGROUND_COLOR = sf::Color(255, 255, 255); const sf::Color BACKGROUND_COLOR = sf::Color(255, 255, 255);
const std::string PROJECT_NAME = "engine"; const std::string PROJECT_NAME = "engine";
const bool USE_LOG_FILE = true;
const double PI = 3.14159265358979323846264338327950288; const double PI = 3.14159265358979323846264338327950288;
const double EPS = 0.000001; const double EPS = 0.000001;

View File

@ -10,16 +10,19 @@
#include <iomanip> #include <iomanip>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include "../Consts.h"
namespace Log namespace Log
{ {
void log(const std::string& message) { void log(const std::string& message) {
std::time_t const now_c = std::time(nullptr); if(Consts::USE_LOG_FILE) {
auto dt = std::put_time(std::localtime(&now_c), "%F %T"); std::time_t const now_c = std::time(nullptr);
auto dt = std::put_time(std::localtime(&now_c), "%F %T");
std::fstream file("engine_log.txt", std::ios::out | std::ios::app); std::fstream file("engine_log.txt", std::ios::out | std::ios::app);
file << dt << "\t" << message << " (" << Time::fps() << " fps)" << std::endl; file << dt << "\t" << message << " (" << Time::fps() << " fps)" << std::endl;
std::cout << dt << "\t" << message << " (" << Time::fps() << " fps)" << std::endl; std::cout << dt << "\t" << message << " (" << Time::fps() << " fps)" << std::endl;
file.close(); file.close();
}
} }
} }