|
@@ -11,62 +11,53 @@ using namespace Framework::Logging;
|
|
|
|
|
|
FlushingOStream Framework::Logging::trace(std::source_location location)
|
|
|
{
|
|
|
- DynamicBuffer* buff = 0;
|
|
|
- return FlushingOStream(
|
|
|
- buff = new DynamicBuffer([&location, &buff](std::stringbuf& buffer) {
|
|
|
- zLoggingHandler()->log(
|
|
|
- LogLevel::Trace, location, buffer.str().c_str());
|
|
|
- delete buff;
|
|
|
- return 0;
|
|
|
- }));
|
|
|
+ DynamicBuffer* buff = new DynamicBuffer([&location](
|
|
|
+ std::stringbuf& buffer) {
|
|
|
+ zLoggingHandler()->log(LogLevel::Trace, location, buffer.str().c_str());
|
|
|
+ return 0;
|
|
|
+ });
|
|
|
+ return FlushingOStream(buff, [buff]() { delete buff; });
|
|
|
}
|
|
|
|
|
|
FlushingOStream Framework::Logging::debug(std::source_location location)
|
|
|
{
|
|
|
- DynamicBuffer* buff = 0;
|
|
|
- return FlushingOStream(
|
|
|
- buff = new DynamicBuffer([&location, &buff](std::stringbuf& buffer) {
|
|
|
- zLoggingHandler()->log(
|
|
|
- LogLevel::Debug, location, buffer.str().c_str());
|
|
|
- delete buff;
|
|
|
- return 0;
|
|
|
- }));
|
|
|
+ DynamicBuffer* buff = new DynamicBuffer([&location](
|
|
|
+ std::stringbuf& buffer) {
|
|
|
+ zLoggingHandler()->log(LogLevel::Debug, location, buffer.str().c_str());
|
|
|
+ return 0;
|
|
|
+ });
|
|
|
+ return FlushingOStream(buff, [buff]() { delete buff; });
|
|
|
}
|
|
|
|
|
|
FlushingOStream Framework::Logging::info(std::source_location location)
|
|
|
{
|
|
|
- DynamicBuffer* buff = 0;
|
|
|
- return FlushingOStream(
|
|
|
- buff = new DynamicBuffer([&location, &buff](std::stringbuf& buffer) {
|
|
|
- zLoggingHandler()->log(
|
|
|
- LogLevel::Info, location, buffer.str().c_str());
|
|
|
- delete buff;
|
|
|
- return 0;
|
|
|
- }));
|
|
|
+ DynamicBuffer* buff = new DynamicBuffer([&location](
|
|
|
+ std::stringbuf& buffer) {
|
|
|
+ zLoggingHandler()->log(LogLevel::Info, location, buffer.str().c_str());
|
|
|
+ return 0;
|
|
|
+ });
|
|
|
+ return FlushingOStream(buff, [buff]() { delete buff; });
|
|
|
}
|
|
|
|
|
|
FlushingOStream Framework::Logging::warning(std::source_location location)
|
|
|
{
|
|
|
- DynamicBuffer* buff = 0;
|
|
|
- return FlushingOStream(
|
|
|
- buff = new DynamicBuffer([&location, &buff](std::stringbuf& buffer) {
|
|
|
- zLoggingHandler()->log(
|
|
|
- LogLevel::Warning, location, buffer.str().c_str());
|
|
|
- delete buff;
|
|
|
- return 0;
|
|
|
- }));
|
|
|
+ DynamicBuffer* buff
|
|
|
+ = new DynamicBuffer([&location](std::stringbuf& buffer) {
|
|
|
+ zLoggingHandler()->log(
|
|
|
+ LogLevel::Warning, location, buffer.str().c_str());
|
|
|
+ return 0;
|
|
|
+ });
|
|
|
+ return FlushingOStream(buff, [buff]() { delete buff; });
|
|
|
}
|
|
|
|
|
|
FlushingOStream Framework::Logging::error(std::source_location location)
|
|
|
{
|
|
|
- DynamicBuffer* buff = 0;
|
|
|
- return FlushingOStream(
|
|
|
- buff = new DynamicBuffer([&location, &buff](std::stringbuf& buffer) {
|
|
|
- zLoggingHandler()->log(
|
|
|
- LogLevel::Error, location, buffer.str().c_str());
|
|
|
- delete buff;
|
|
|
- return 0;
|
|
|
- }));
|
|
|
+ DynamicBuffer* buff = new DynamicBuffer([&location](
|
|
|
+ std::stringbuf& buffer) {
|
|
|
+ zLoggingHandler()->log(LogLevel::Error, location, buffer.str().c_str());
|
|
|
+ return 0;
|
|
|
+ });
|
|
|
+ return FlushingOStream(buff, [buff]() { delete buff; });
|
|
|
}
|
|
|
|
|
|
LoggingHandler* Framework::Logging::zLoggingHandler()
|
|
@@ -385,7 +376,7 @@ public:
|
|
|
bool active = enabled(level);
|
|
|
if (active)
|
|
|
{
|
|
|
- if (color < Color::LIGHT_Black)
|
|
|
+ if (color < Color::LIGHT_BLACK)
|
|
|
{
|
|
|
return Text("\033[1;") + Text(30 + (int)color) + "m"
|
|
|
+ after->formatMessage(msg, level, location) + "\033[0m";
|
|
@@ -451,7 +442,7 @@ public:
|
|
|
bool active = enabled(level);
|
|
|
if (active)
|
|
|
{
|
|
|
- if (color < Color::LIGHT_Black)
|
|
|
+ if (color < Color::LIGHT_BLACK)
|
|
|
{
|
|
|
return Text("\033[1;") + Text(40 + (int)color) + "m"
|
|
|
+ after->formatMessage(msg, level, location) + "\033[0m";
|
|
@@ -571,7 +562,7 @@ Framework::Logging::CoutLoggingChannel::CoutLoggingChannel()
|
|
|
|
|
|
void Framework::Logging::CoutLoggingChannel::writeMessage(const Text& msg) const
|
|
|
{
|
|
|
- std::cout << msg.getText() << std::endl;
|
|
|
+ std::cout << msg.getText();
|
|
|
}
|
|
|
|
|
|
Framework::Logging::ConsoleHandlerLoggingChannel::ConsoleHandlerLoggingChannel(
|
|
@@ -593,20 +584,30 @@ void Framework::Logging::ConsoleHandlerLoggingChannel::writeMessage(
|
|
|
}
|
|
|
|
|
|
Framework::Logging::FileLoggingChannel::FileLoggingChannel(Text filePath)
|
|
|
+ : FileLoggingChannel(new Datei(filePath))
|
|
|
+{}
|
|
|
+
|
|
|
+Framework::Logging::FileLoggingChannel::FileLoggingChannel(Datei* file)
|
|
|
: LoggingChannel(),
|
|
|
- file(new Datei(filePath))
|
|
|
+ file(file)
|
|
|
{
|
|
|
if (!file->existiert())
|
|
|
{
|
|
|
file->erstellen();
|
|
|
}
|
|
|
- file->open(
|
|
|
- Datei::Style::schreiben | Datei::Style::ende | Datei::Style::lesen);
|
|
|
+ if (!file->istOffen())
|
|
|
+ {
|
|
|
+ file->open(
|
|
|
+ Datei::Style::schreiben | Datei::Style::ende | Datei::Style::lesen);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
Framework::Logging::FileLoggingChannel::~FileLoggingChannel()
|
|
|
{
|
|
|
- file->close();
|
|
|
+ if (file->istOffen())
|
|
|
+ {
|
|
|
+ file->close();
|
|
|
+ }
|
|
|
file->release();
|
|
|
}
|
|
|
|