mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 16:35:45 +08:00
null sink
This commit is contained in:
parent
ed6532b9f0
commit
8e8c39375a
@ -99,6 +99,7 @@
|
||||
<ClInclude Include="..\..\include\c11log\sinks\base_sink.h" />
|
||||
<ClInclude Include="..\..\include\c11log\sinks\console_sinks.h" />
|
||||
<ClInclude Include="..\..\include\c11log\sinks\file_sinks.h" />
|
||||
<ClInclude Include="..\..\include\c11log\sinks\null_sink.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
</ItemGroup>
|
||||
|
@ -78,6 +78,9 @@
|
||||
<ClInclude Include="..\..\include\c11log\sinks\file_sinks.h">
|
||||
<Filter>Header Files\c11log\sinks</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\c11log\sinks\null_sink.h">
|
||||
<Filter>Header Files\c11log\details</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "c11log/sinks/async_sink.h"
|
||||
#include "c11log/sinks/file_sinks.h"
|
||||
#include "c11log/sinks/console_sinks.h"
|
||||
|
||||
#include "c11log/sinks/null_sink.h"
|
||||
#include "utils.h"
|
||||
|
||||
using std::cout;
|
||||
@ -16,12 +16,12 @@ using namespace utils;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const unsigned int howmany = argc <= 1 ? 5000000:atoi(argv[1]);
|
||||
const unsigned int howmany = argc <= 1 ? 10000:atoi(argv[1]);
|
||||
|
||||
logger cout_logger ("example", sinks::stdout_sink());
|
||||
cout_logger.info() << "Hello logger";
|
||||
|
||||
auto nullsink = sinks::null_sink::get();
|
||||
auto nullsink = std::make_shared<sinks::null_sink>();
|
||||
//auto fsink = std::make_shared<sinks::rotating_file_sink>("log", "txt", 1024*1024*50 , 5, 0);
|
||||
//auto as = std::make_shared<sinks::async_sink>(1000);
|
||||
//as->add_sink(fsink);
|
||||
@ -32,6 +32,7 @@ int main(int argc, char* argv[])
|
||||
auto start = system_clock::now();
|
||||
for (unsigned int i = 1; i <= howmany; ++i)
|
||||
my_logger.info() << "Hello logger: msg #" << i;
|
||||
my_logger.info("FFF");
|
||||
|
||||
//as->shutdown(std::chrono::milliseconds(15000));
|
||||
auto delta = system_clock::now() - start;
|
||||
|
@ -43,18 +43,6 @@ protected:
|
||||
std::atomic<bool> _enabled;
|
||||
};
|
||||
|
||||
class null_sink:public base_sink
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<null_sink>& get()
|
||||
{
|
||||
static auto inst = std::make_shared<null_sink>();
|
||||
return inst;
|
||||
}
|
||||
protected:
|
||||
void _sink_it(const details::log_msg&) override
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
@ -43,5 +43,7 @@ inline std::shared_ptr<console_sink>& stderr_sink ()
|
||||
return inst;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
18
include/c11log/sinks/null_sink.h
Normal file
18
include/c11log/sinks/null_sink.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
#include "base_sink.h"
|
||||
|
||||
namespace c11log {
|
||||
namespace sinks {
|
||||
class null_sink : public base_sink
|
||||
{
|
||||
protected:
|
||||
void _sink_it(const details::log_msg&) override
|
||||
{}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user