Skip to content

Commit

Permalink
Use strftime instead of put_time
Browse files Browse the repository at this point in the history
  • Loading branch information
elnormous committed Jul 3, 2018
1 parent 1a48b84 commit 3209b0e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// rtmp_relay
//

#include <ctime>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <string>
#ifdef _WIN32
Expand Down Expand Up @@ -37,13 +35,15 @@ namespace relay
{
auto n = std::chrono::system_clock::now();
auto t = std::chrono::system_clock::to_time_t(n);
tm* buffer = localtime(&t);
tm* time = localtime(&t);
char buffer[32];
strftime(buffer, sizeof(buffer), "%Y.%m.%d %H:%M:%S", time);

if (level == Level::ERR ||
level == Level::WARN)
std::cerr << std::put_time(buffer, "%Y.%m.%d %H:%M:%S") << ": " << s << std::endl;
std::cerr << buffer << ": " << s << std::endl;
else
std::cout << std::put_time(buffer, "%Y.%m.%d %H:%M:%S") << ": " << s << std::endl;
std::cout << buffer << ": " << s << std::endl;

#ifdef _WIN32
wchar_t szBuffer[MAX_PATH];
Expand Down

0 comments on commit 3209b0e

Please sign in to comment.