253 :
public std::ostream {
257 Console(ConsoleLevel level, std::string tag,
258 std::string file,
int line, std::string function)
259 : std::ostream(&buffer),
260 buffer(getBuffer(level, tag, file, line, function)) {}
262 Console(ConsoleLevel level, std::string tag)
263 : std::ostream(&buffer),
264 buffer(getBuffer(level, tag)) {}
266 static void addSink(std::shared_ptr<MessageSink> ms) {
267 std::lock_guard<std::mutex> guard(lock);
268 message_sinks.push_back(ms);
271 static void removeSink(std::shared_ptr<MessageSink> ms) {
272 std::lock_guard<std::mutex> guard(lock);
273 message_sinks.erase(std::remove(message_sinks.begin(), message_sinks.end(), ms),
274 message_sinks.end());
277 static void removeAllSinks() {
278 std::lock_guard<std::mutex> guard(lock);
279 message_sinks.clear();
287 :
public std::stringbuf {
288 std::vector<std::shared_ptr<MessageSink>> sinks;
291 ConsoleBuffer(std::vector<std::shared_ptr<MessageSink>> sinks,
294 message_template(msg) {}
298 static ConsoleBuffer getBuffer(ConsoleLevel level, std::string tag);
300 static ConsoleBuffer getBuffer(ConsoleLevel level, std::string tag,
301 std::string file,
int line, std::string function);
303 static gmCore_API std::vector<std::shared_ptr<MessageSink>> message_sinks;
305 ConsoleBuffer buffer;
306 static gmCore_API std::mutex lock;