shooter/engine/utils/Log.cpp

29 lines
757 B
C++
Raw Normal View History

2021-09-13 15:53:43 +03:00
//
// Created by Иван Ильин on 13.01.2021.
//
2021-10-09 13:41:12 +03:00
#define _CRT_SECURE_NO_WARNINGS
2021-09-13 15:53:43 +03:00
#include <ctime>
2021-10-09 13:41:12 +03:00
#include <iomanip>
2021-09-13 15:53:43 +03:00
#include <fstream>
#include <iostream>
2021-10-31 11:39:08 +03:00
#include "Log.h"
#include "Time.h"
2021-10-17 10:27:19 +03:00
#include "../Consts.h"
2021-09-13 15:53:43 +03:00
2021-10-31 11:39:08 +03:00
namespace Log {
void log(const std::string &message) {
if (Consts::USE_LOG_FILE) {
2021-10-17 10:27:19 +03:00
std::time_t const now_c = std::time(nullptr);
auto dt = std::put_time(std::localtime(&now_c), "%F %T");
2021-09-13 15:53:43 +03:00
2021-10-17 10:27:19 +03:00
std::fstream file("engine_log.txt", std::ios::out | std::ios::app);
file << dt << "\t" << message << " (" << Time::fps() << " fps)" << std::endl;
std::cout << dt << "\t" << message << " (" << Time::fps() << " fps)" << std::endl;
file.close();
}
2021-09-13 15:53:43 +03:00
}
}