Skip to content

Commit 36eb173

Browse files
committed
Updated README.md with qt color example
1 parent ca44ce5 commit 36eb173

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

README.md

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Very fast, header-only/compiled, C++ logging library. [![ci](https://github.com/gabime/spdlog/actions/workflows/ci.yml/badge.svg)](https://github.com/gabime/spdlog/actions/workflows/ci.yml)  [![Build status](https://ci.appveyor.com/api/projects/status/d2jnxclg20vd0o50?svg=true&branch=v1.x)](https://ci.appveyor.com/project/gabime/spdlog) [![Release](https://img.shields.io/github/release/gabime/spdlog.svg)](https://github.com/gabime/spdlog/releases/latest)
44

5-
## Install
5+
## Install
66
#### Header-only version
77
Copy the include [folder](https://github.com/gabime/spdlog/tree/v1.x/include/spdlog) to your build tree and use a C++11 compiler.
88

@@ -12,14 +12,14 @@ $ git clone https://github.com/gabime/spdlog.git
1212
$ cd spdlog && mkdir build && cd build
1313
$ cmake .. && make -j
1414
```
15-
16-
see example [CMakeLists.txt](https://github.com/gabime/spdlog/blob/v1.x/example/CMakeLists.txt) on how to use.
15+
16+
see example [CMakeLists.txt](https://github.com/gabime/spdlog/blob/v1.x/example/CMakeLists.txt) on how to use.
1717

1818
## Platforms
19-
* Linux, FreeBSD, OpenBSD, Solaris, AIX
20-
* Windows (msvc 2013+, cygwin)
21-
* macOS (clang 3.5+)
22-
* Android
19+
* Linux, FreeBSD, OpenBSD, Solaris, AIX
20+
* Windows (msvc 2013+, cygwin)
21+
* macOS (clang 3.5+)
22+
* Android
2323

2424
## Package managers:
2525
* Debian: `sudo apt install libspdlog-dev`
@@ -44,18 +44,18 @@ $ cmake .. && make -j
4444
* [Custom](https://github.com/gabime/spdlog/wiki/3.-Custom-formatting) formatting.
4545
* Multi/Single threaded loggers.
4646
* Various log targets:
47-
* Rotating log files.
48-
* Daily log files.
49-
* Console logging (colors supported).
50-
* syslog.
51-
* Windows event log.
52-
* Windows debugger (```OutputDebugString(..)```).
53-
* Log to Qt widgets
54-
* Easily [extendable](https://github.com/gabime/spdlog/wiki/4.-Sinks#implementing-your-own-sink) with custom log targets.
47+
* Rotating log files.
48+
* Daily log files.
49+
* Console logging (colors supported).
50+
* syslog.
51+
* Windows event log.
52+
* Windows debugger (```OutputDebugString(..)```).
53+
* Log to Qt widgets ([example](#log-to-qt-with-nice-colors)).
54+
* Easily [extendable](https://github.com/gabime/spdlog/wiki/4.-Sinks#implementing-your-own-sink) with custom log targets.
5555
* Log filtering - log levels can be modified at runtime as well as compile time.
5656
* Support for loading log levels from argv or environment var.
5757
* [Backtrace](#backtrace-support) support - store debug messages in a ring buffer and display them later on demand.
58-
58+
5959
## Usage samples
6060

6161
#### Basic usage
@@ -271,7 +271,7 @@ void async_example()
271271
```
272272

273273
---
274-
#### Asynchronous logger with multi sinks
274+
#### Asynchronous logger with multi sinks
275275
```c++
276276
#include "spdlog/sinks/stdout_color_sinks.h"
277277
#include "spdlog/sinks/rotating_file_sink.h"
@@ -349,7 +349,7 @@ void err_handler_example()
349349
```
350350

351351
---
352-
#### syslog
352+
#### syslog
353353
```c++
354354
#include "spdlog/sinks/syslog_sink.h"
355355
void syslog_example()
@@ -360,7 +360,7 @@ void syslog_example()
360360
}
361361
```
362362
---
363-
#### Android example
363+
#### Android example
364364
```c++
365365
#include "spdlog/sinks/android_sink.h"
366366
void android_example()
@@ -422,8 +422,21 @@ void replace_default_logger_example()
422422
```
423423

424424
---
425+
#### Log to Qt with nice colors
426+
```c++
427+
#include "spdlog/spdlog.h"
428+
#include "spdlog/sinks/qt_sinks.h"
429+
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
430+
{
431+
setMinimumSize(640, 480);
432+
auto log_widget = new QTextEdit(this);
433+
setCentralWidget(log_widget);
434+
auto logger = spdlog::qt_color_logger_mt("qt_logger", log_widget);
435+
logger->info("Some info message");
436+
}
437+
```
425438
426-
439+
---
427440
## Benchmarks
428441
429442
Below are some [benchmarks](https://github.com/gabime/spdlog/blob/v1.x/bench/bench.cpp) done in Ubuntu 64 bit, Intel i7-4770 CPU @ 3.40GHz

0 commit comments

Comments
 (0)