mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-16 01:37:58 +00:00
Compare commits
8 Commits
42c466296a
...
d977dd4395
Author | SHA1 | Date | |
---|---|---|---|
|
d977dd4395 | ||
|
ca402379a9 | ||
|
903bf2135d | ||
|
1f732585b2 | ||
|
224de0601e | ||
|
9b84337830 | ||
|
a4665c27df | ||
|
3337015346 |
44
README.md
44
README.md
@ -35,9 +35,8 @@ $ cmake .. && make -j
|
||||
|
||||
## Features
|
||||
* Very fast (see [benchmarks](#benchmarks) below).
|
||||
* Headers only or compiled version
|
||||
* Headers only or compiled
|
||||
* Feature rich formatting, using the excellent [fmt](https://github.com/fmtlib/fmt) library.
|
||||
* **New!** [Backtrace](#backtrace-support) support - store debug messages in a ring buffer and display later on demand.
|
||||
* Asynchronous mode (optional)
|
||||
* [Custom](https://github.com/gabime/spdlog/wiki/3.-Custom-formatting) formatting.
|
||||
* Multi/Single threaded loggers.
|
||||
@ -50,7 +49,7 @@ $ cmake .. && make -j
|
||||
* Easily extendable with custom log targets (just implement a single function in the [sink](include/spdlog/sinks/sink.h) interface).
|
||||
* Log filtering - log levels can be modified in runtime as well as in compile time.
|
||||
* Support for loading log levels from argv or from environment var.
|
||||
|
||||
* [Backtrace](#backtrace-support) support - store debug messages in a ring buffer and display later on demand.
|
||||
|
||||
## Usage samples
|
||||
|
||||
@ -87,20 +86,7 @@ int main()
|
||||
}
|
||||
|
||||
```
|
||||
#### Load log levels from env variable or from argv
|
||||
```c++
|
||||
#include "spdlog/cfg/env.h"
|
||||
void load_levels_example()
|
||||
{
|
||||
// Set the log level to "info" and mylogger to to "trace":
|
||||
// SPDLOG_LEVEL=info,mylogger=trace && ./example
|
||||
spdlog::cfg::load_env_levels();
|
||||
// or from command line:
|
||||
// ./example SPDLOG_LEVEL=info,mylogger=trace
|
||||
// #include "spdlog/cfg/argv.h" // for loading levels from argv
|
||||
// spdlog::cfg::load_argv_levels(args, argv);
|
||||
}
|
||||
```
|
||||
---
|
||||
#### Create stdout/stderr logger object
|
||||
```c++
|
||||
#include "spdlog/spdlog.h"
|
||||
@ -113,6 +99,7 @@ void stdout_example()
|
||||
spdlog::get("console")->info("loggers can be retrieved from a global registry using the spdlog::get(logger_name)");
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
#### Basic file logger
|
||||
```c++
|
||||
@ -327,7 +314,6 @@ void err_handler_example()
|
||||
|
||||
```
|
||||
|
||||
|
||||
---
|
||||
#### syslog
|
||||
```c++
|
||||
@ -351,6 +337,28 @@ void android_example()
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
#### Load log levels from env variable or from argv
|
||||
|
||||
```c++
|
||||
#include "spdlog/cfg/env.h"
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
spdlog::cfg::load_env_levels();
|
||||
// or from command line:
|
||||
// ./example SPDLOG_LEVEL=info,mylogger=trace
|
||||
// #include "spdlog/cfg/argv.h" // for loading levels from argv
|
||||
// spdlog::cfg::load_argv_levels(args, argv);
|
||||
}
|
||||
```
|
||||
So then you can:
|
||||
|
||||
```console
|
||||
$ export SPDLOG_LEVEL=info,mylogger=trace
|
||||
$ ./example
|
||||
```
|
||||
|
||||
---
|
||||
## Benchmarks
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user