shooter/engine/utils/Log.cpp

26 lines
663 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 "Log.h"
#include "Time.h"
#include <ctime>
2021-10-09 13:41:12 +03:00
#include <iomanip>
2021-09-13 15:53:43 +03:00
#include <fstream>
#include <iostream>
namespace Log
{
void log(const std::string& message) {
2021-10-09 13:41:12 +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-09 13:41:12 +03:00
std::fstream file("engine_log.txt", std::ios::out | std::ios::app);
2021-09-13 15:53:43 +03:00
file << dt << "\t" << message << " (" << Time::fps() << " fps)" << std::endl;
std::cout << dt << "\t" << message << " (" << Time::fps() << " fps)" << std::endl;
file.close();
}
}