spdlog/include/c11log/sinks/stdout_sinks.h

38 lines
587 B
C
Raw Normal View History

2014-01-25 08:52:10 -05:00
#pragma once
2014-01-25 04:09:04 -05:00
#include <iostream>
#include "base_sink.h"
namespace c11log
{
2014-01-25 08:52:10 -05:00
namespace sinks
{
class ostream_sink: public base_sink
{
public:
ostream_sink(std::ostream& os):_ostream(os) {}
virtual ~ostream_sink() = default;
2014-01-25 04:09:04 -05:00
2014-01-25 08:52:10 -05:00
protected:
virtual void sink_it_(const std::string& msg) override
{
_ostream << msg;
}
2014-01-25 04:09:04 -05:00
2014-01-25 08:52:10 -05:00
std::ostream& _ostream;
};
2014-01-25 04:09:04 -05:00
2014-01-25 08:52:10 -05:00
class stdout_sink:public ostream_sink
{
public:
stdout_sink():ostream_sink(std::cout) {}
};
2014-01-25 04:09:04 -05:00
2014-01-25 08:52:10 -05:00
class stderr_sink:public ostream_sink
{
public:
stderr_sink():ostream_sink(std::cerr) {}
};
}
2014-01-25 04:09:04 -05:00
}