spdlog/include/c11log/sinks/stdout_sinks.h

32 lines
597 B
C
Raw Normal View History

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