Replace the final use of boost::posix_time with std::chrono.
This commit is contained in:
parent
d757ee280b
commit
055fbf7b8c
6 changed files with 16 additions and 13 deletions
|
@ -18,6 +18,7 @@
|
|||
#include "log.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
static lg::log_domain log_filesystem("filesystem");
|
||||
#define ERR_FS LOG_STREAM(err, log_filesystem)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "gui/widgets/widget.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
namespace dialogs
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "wml_exception.hpp"
|
||||
|
||||
#include <numeric>
|
||||
#include <cmath>
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
|
|
18
src/log.cpp
18
src/log.cpp
|
@ -47,7 +47,6 @@ static bool timestamp = true;
|
|||
static bool precise_timestamp = false;
|
||||
static std::mutex log_mutex;
|
||||
|
||||
static boost::posix_time::time_facet facet("%Y%m%d %H:%M:%S%F ");
|
||||
static std::ostream *output_stream = nullptr;
|
||||
|
||||
static std::ostream& output()
|
||||
|
@ -198,14 +197,15 @@ std::string get_timespan(const std::time_t& t) {
|
|||
return sout.str();
|
||||
}
|
||||
|
||||
static void print_precise_timestamp(std::ostream & out) noexcept
|
||||
static void print_precise_timestamp(std::ostream& out) noexcept
|
||||
{
|
||||
try {
|
||||
facet.put(
|
||||
std::ostreambuf_iterator<char>(out),
|
||||
out,
|
||||
' ',
|
||||
boost::posix_time::microsec_clock::local_time());
|
||||
int64_t micros = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
|
||||
std::time_t seconds = micros/1'000'000;
|
||||
int fractional = micros-(seconds*1'000'000);
|
||||
char c = out.fill('0');
|
||||
out << std::put_time(std::localtime(&seconds), "%Y%m%d %H:%M:%S") << "." << std::setw(6) << fractional;
|
||||
out.fill(c);
|
||||
} catch(...) {}
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ void scope_logger::do_log_entry(const std::string& str) noexcept
|
|||
{
|
||||
str_ = str;
|
||||
try {
|
||||
ticks_ = boost::posix_time::microsec_clock::local_time();
|
||||
ticks_ = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
|
||||
} catch(...) {}
|
||||
debug()(domain_, false, true) | formatter() << "{ BEGIN: " << str_ << "\n";
|
||||
++indent;
|
||||
|
@ -279,7 +279,7 @@ void scope_logger::do_log_exit() noexcept
|
|||
{
|
||||
long ticks = 0;
|
||||
try {
|
||||
ticks = (boost::posix_time::microsec_clock::local_time() - ticks_).total_milliseconds();
|
||||
ticks = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count() - ticks_;
|
||||
} catch(...) {}
|
||||
--indent;
|
||||
auto output = debug()(domain_, false, true);
|
||||
|
|
|
@ -56,12 +56,10 @@
|
|||
#include <sstream> // as above. iostream (actually, iosfwd) declares stringstream as an incomplete type, but does not define it
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <ctime>
|
||||
|
||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||
#include "formatter.hpp"
|
||||
|
||||
using boost::posix_time::ptime;
|
||||
|
||||
namespace lg {
|
||||
|
||||
/**
|
||||
|
@ -167,7 +165,7 @@ log_domain& general();
|
|||
|
||||
class scope_logger
|
||||
{
|
||||
ptime ticks_;
|
||||
int64_t ticks_;
|
||||
const log_domain& domain_;
|
||||
std::string str_;
|
||||
public:
|
||||
|
|
Loading…
Add table
Reference in a new issue