mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
dependency which required logger.cc to have access to the entire rest of the system. Although we still need to forward declare all the log messages.
64 lines
1.4 KiB
C++
64 lines
1.4 KiB
C++
#include "lib/core/globals.h"
|
|
#include "lib/core/bytes.h"
|
|
#include "lib/fluxmap.h"
|
|
#include "lib/sector.h"
|
|
#include "lib/flux.h"
|
|
#include "lib/logger.h"
|
|
|
|
namespace
|
|
{
|
|
class LogRendererImpl : public LogRenderer
|
|
{
|
|
public:
|
|
LogRenderer& add(std::string m) override
|
|
{
|
|
if (_atNewline && _indented)
|
|
{
|
|
_stream << " ";
|
|
_lineLen = 4;
|
|
_indented = true;
|
|
}
|
|
|
|
if ((m.size() + _lineLen) > 80)
|
|
{
|
|
_stream << "\n ";
|
|
_lineLen = 4;
|
|
_indented = true;
|
|
}
|
|
|
|
_stream << m;
|
|
return *this;
|
|
}
|
|
|
|
LogRenderer& newsection() override
|
|
{
|
|
newline();
|
|
_indented = false;
|
|
return *this;
|
|
}
|
|
|
|
LogRenderer& newline() override
|
|
{
|
|
if (!_atNewline)
|
|
{
|
|
_stream << '\n';
|
|
_atNewline = true;
|
|
}
|
|
_lineLen = 0;
|
|
return *this;
|
|
}
|
|
|
|
void renderTo(std::ostream& stream) override {}
|
|
|
|
private:
|
|
bool _atNewline = false;
|
|
bool _indented = false;
|
|
int _lineLen = 0;
|
|
std::stringstream _stream;
|
|
};
|
|
}
|
|
|
|
std::unique_ptr<LogRenderer> LogRenderer::create()
|
|
{
|
|
return std::make_unique<LogRendererImpl>();
|
|
} |