17
17
#define EFP_LOG_TIME_STAMP true
18
18
#define EFP_LOG_BUFFER_SIZE 256
19
19
// todo Maybe compile time log-level
20
- // todo Processing period configuration
21
20
22
21
namespace efp {
23
22
enum class LogLevel : char {
@@ -388,10 +387,12 @@ namespace efp {
388
387
}
389
388
390
389
static inline void set_log_period (std::chrono::milliseconds period) {
391
- _period = period;
390
+ instance (). _period = period;
392
391
}
393
392
394
- static inline std::chrono::milliseconds get_log_period () { return _period; }
393
+ static inline std::chrono::milliseconds get_log_period () {
394
+ return instance ()._period ;
395
+ }
395
396
396
397
static void
397
398
set_output (FILE* output_file) {
@@ -451,9 +452,9 @@ namespace efp {
451
452
protected:
452
453
private:
453
454
Logger ()
454
- : // with_time_stamp(true) ,
455
- _run ( true ) ,
456
- _thread ( [&]() {
455
+ : _period{ 200 } ,
456
+ _run{ true } ,
457
+ _thread{ [&]() {
457
458
while (_run.load ()) {
458
459
const auto start_time_point = std::chrono::steady_clock::now ();
459
460
#if EFP_LOG_TIME_STAMP == true
@@ -470,22 +471,16 @@ namespace efp {
470
471
std::this_thread::sleep_for (_period - elapsed_time);
471
472
}
472
473
}
473
- }) {
474
+ }} {
474
475
}
475
476
476
- static std::chrono::milliseconds _period;
477
-
478
- LogLevel _log_level;
477
+ std::chrono::milliseconds _period;
479
478
480
479
detail::LogBuffer _log_buffer;
481
480
std::atomic<bool > _run;
482
481
std::thread _thread;
483
482
};
484
483
485
- std::chrono::milliseconds Logger::_period = std::chrono::milliseconds(200 );
486
-
487
- // LogLevel Logger::instance().log_level = LogLevel::Debug;
488
-
489
484
namespace detail {
490
485
491
486
template <typename ... Args>
0 commit comments