spdlog/include/c11log/sinks/stdout_sinks.h

32 lines
597 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"
2014-02-21 15:51:54 -05:00
namespace c11log {
namespace sinks {
class ostream_sink: public base_sink {
2014-01-25 08:52:10 -05:00
public:
2014-02-21 15:51:54 -05:00
ostream_sink(std::ostream& os):_ostream(os) {}
2014-01-25 08:52:10 -05:00
virtual ~ostream_sink() = default;
2014-01-25 04:09:04 -05:00
2014-01-25 08:52:10 -05:00
protected:
2014-02-22 03:34:42 -05:00
virtual void _sink_it(const std::string& msg) override {
2014-02-21 15:51:54 -05:00
_ostream << msg;
}
2014-01-25 04:09:04 -05:00
2014-02-21 15:51:54 -05:00
std::ostream& _ostream;
2014-01-25 08:52:10 -05:00
};
2014-01-25 04:09:04 -05:00
2014-02-21 15:51:54 -05:00
class stdout_sink:public ostream_sink {
2014-01-25 08:52:10 -05:00
public:
stdout_sink():ostream_sink(std::cout) {}
};
2014-01-25 04:09:04 -05:00
2014-02-21 15:51:54 -05:00
class stderr_sink:public ostream_sink {
2014-01-25 08:52:10 -05:00
public:
stderr_sink():ostream_sink(std::cerr) {}
2014-02-21 15:51:54 -05:00
2014-01-25 08:52:10 -05:00
};
}
2014-01-25 04:09:04 -05:00
}