qt_sink 可以向 QTextBrowser、QTextEdit 等控件输出日志消息: #include 'spdlog/sinks/qt_sinks.h'auto logger = spdlog::qt_logger_mt('QLogger',ui->textBrowser);logger->info('hello QTextBrowser');logger->warn('this msg from spdlog');
auto logger = spdlog::qt_logger_mt("QLogger",ui->textBrowser); logger->info("hello QTextBrowser"); logger->warn("this msg from spdlog"); 运行结果如下: msvc sink msvc_sink 使用 OutputDebugStringA 向 Windows调试接收器发生日志记录: #include "spdlog/sinks/stdout_color_sinks.h" #include "...
在Widget.cpp中添加下列代码; #include"widget.h"#include"ui_widget.h"#include"spdlog/spdlog.h"#include"spdlog/sinks/qt_sinks.h"#include"spdlog/sinks/basic_file_sink.h"Widget::Widget(QWidget*parent):QWidget(parent),ui(newUi::Widget){ui->setupUi(this);autolog_edit=std::make_shared<spdlog:...
qt_sink qt_sink could output log messages from QTextBrowser,QTextEdit... Example: #include"spdlog/sinks/qt_sinks.h"autologger = spdlog::qt_logger_mt("QLogger",ui->textBrowser); logger->info("hello QTextBrowser"); logger->warn("this msg from spdlog"); Implementing your own sink To implem...
#include"spdlog/spdlog.h"#include"spdlog/sinks/rotating_file_sink.h" 创建日志 basic log 不带滚动,日志文件会一直被写入,不断变大。 // Create basic file logger (not rotated)automy_logger = spd::basic_logger_mt("basic_logger","logs/basic-log.txt"); ...
#ifndef _SIMLOG_H_ #define _SIMLOG_H_ #include <QtWidgets/QWidget> #include <spdlog/spdlog.h> #include "simlog_export.h" #ifdef _WIN32 //strrchr:查找字符在指定字符串从右面开始的第一次出现的位置,若是成功,返回该字符以及后面的字符,若是失败,返回NULL ...
Qt Sink: Allow for darker colors for light backgrounds (#2817). Thanks to @krawq. Set CMAKE_BUILD_TYPE only for single-config generators (#2839). Thanks to @moritz-h. Provide spdlog_header_only in build directory export (#2846). Thanks to @robertmaynard. Add SPDLOG_TO_VERSION to comp...
创建Loggers 每个Logger都包含一个数组,数组里是std::shared_ptr,每次调用log时,logger会在每个sink上调用sink(log_msg)。sink分为多线程和单线程版本,单线程版本的sink不允许在多线程里调用 使用factory创建logger //Create ... 线程池 #include sed
#include "spdlog/sinks/qt_sinks.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setMinimumSize(640, 480); auto log_widget = new QTextEdit(this); setCentralWidget(log_widget); int max_lines = 500; // keep the text widget to max 500 lines. remove old lines if needed...
// 一个日志器使用多个SINK std::vector<spdlog::sink_ptr> sinks; sinks.push_back( std::make_shared<spdlog::sinks::stdout_sink_st>()); sinks.push_back( std::make_shared<spdlog::sinks::daily_file_sink_st>("logfile",23,59));