review fixes + T70
This commit is contained in:
parent
9bb0b8983d
commit
e22cb3aee4
@ -322,6 +322,13 @@ if (LOG_NO_ERROR)
|
||||
add_definitions(-DLOG_NO_ERROR)
|
||||
endif()
|
||||
# -- logging ------------------------------------------------------------------
|
||||
# -- logger -------------------------------------------------------------------
|
||||
option(SYNC_LOGGER "" OFF)
|
||||
message(STATUS "SYNC LOGGER: ${SYNC_LOGGER}")
|
||||
if (SYNC_LOGGER)
|
||||
add_definitions(-DSYNC_LOGGER)
|
||||
endif()
|
||||
# -- logger -------------------------------------------------------------------
|
||||
# -- assert -------------------------------------------------------------------
|
||||
option(RUNTIME_ASSERT "Enable runtime assertions" ON)
|
||||
message(STATUS "RUNTIME_ASSERT: ${RUNTIME_ASSERT}")
|
||||
|
@ -23,7 +23,6 @@ public:
|
||||
ChunkedEncoder(Stream &stream)
|
||||
: logger(logging::log->logger("Chunked Encoder")), stream(stream)
|
||||
{
|
||||
// logger = logging::log->logger("Chunked Encoder");
|
||||
}
|
||||
|
||||
static constexpr size_t chunk_size = N - 2;
|
||||
@ -71,9 +70,6 @@ private:
|
||||
|
||||
void end_chunk()
|
||||
{
|
||||
// TODO: this call is unnecessary bacause the same method is called
|
||||
// inside the flush method
|
||||
// write_chunk_header();
|
||||
flush();
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,8 @@ public:
|
||||
streams.emplace_back(std::forward<Stream::uptr>(stream));
|
||||
}
|
||||
|
||||
virtual std::string type() = 0;
|
||||
|
||||
protected:
|
||||
friend class Logger;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include <fmt/format.h>
|
||||
|
||||
|
@ -12,6 +12,7 @@ public:
|
||||
|
||||
protected:
|
||||
void emit(Record::uptr) override;
|
||||
std::string type() override;
|
||||
|
||||
private:
|
||||
lockfree::MpscQueue<Record> records;
|
||||
|
@ -8,4 +8,5 @@ class SyncLog : public Log, Lockable<Futex>
|
||||
{
|
||||
protected:
|
||||
void emit(Record::uptr) override;
|
||||
std::string type() override;
|
||||
};
|
||||
|
@ -11,6 +11,11 @@ void AsyncLog::emit(Record::uptr record)
|
||||
records.push(std::move(record));
|
||||
}
|
||||
|
||||
std::string AsyncLog::type()
|
||||
{
|
||||
return "AsyncLog";
|
||||
}
|
||||
|
||||
void AsyncLog::work()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
|
@ -5,3 +5,8 @@ void SyncLog::emit(Record::uptr record)
|
||||
auto guard = this->acquire_unique();
|
||||
dispatch(*record);
|
||||
}
|
||||
|
||||
std::string SyncLog::type()
|
||||
{
|
||||
return "SyncLog";
|
||||
}
|
||||
|
@ -34,10 +34,17 @@ int main(void)
|
||||
// that are configured below
|
||||
std::set_terminate(&terminate_handler);
|
||||
|
||||
// logger init
|
||||
#ifdef SYNC_LOGGER
|
||||
logging::init_sync();
|
||||
// logging::init_async();
|
||||
#else
|
||||
logging::init_async();
|
||||
#endif
|
||||
logging::log->pipe(std::make_unique<Stdout>());
|
||||
|
||||
// get Main logger
|
||||
logger = logging::log->logger("Main");
|
||||
logger.info("{}", logging::log->type());
|
||||
|
||||
signal(SIGINT, sigint_handler);
|
||||
signal(SIGABRT, sigint_handler);
|
||||
@ -64,7 +71,7 @@ int main(void)
|
||||
bolt::Server<bolt::Worker> server(std::move(socket));
|
||||
serverptr = &server;
|
||||
|
||||
constexpr size_t N = 1;
|
||||
auto N = std::thread::hardware_concurrency();
|
||||
|
||||
logger.info("Starting {} workers", N);
|
||||
server.start(N);
|
||||
|
Loading…
Reference in New Issue
Block a user