mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 18:11:33 +08:00
Update README.md
This commit is contained in:
parent
f6adbeaf82
commit
741bf8cde1
21
README.md
21
README.md
@ -18,7 +18,7 @@ Just copy the files to your build tree and use a C++11 compiler
|
||||
* Headers only.
|
||||
* No dependencies.
|
||||
* Cross platform - Linux / Windows on 32/64 bits.
|
||||
* *new* [cppformat](http://cppformat.github.io/) for formatting and extra performance: ```logger.info("The number {} in hex is {:X}", 255, 255)
|
||||
* **new**! Now using the excellent [cppformat](http://cppformat.github.io/) for feature rich formatting and extra performance: ```logger.info("The number {} in hex is {:X}", 255, 255)
|
||||
* stream call style: ```logger.info("Hello") << " logger";
|
||||
* mixed calls style ```logger.info("Hello {}", name) << 1 << 2 << 3;
|
||||
* [Custom](https://github.com/gabime/spdlog/wiki/Custom-formatting) formatting.
|
||||
@ -29,7 +29,7 @@ Just copy the files to your build tree and use a C++11 compiler
|
||||
* Console logging.
|
||||
* Linux syslog.
|
||||
* Easily extendable with custom log targets (just implement a single function in the [sink](include/spdlog/sinks/sink.h) interface).
|
||||
* Optional async logging .
|
||||
* Optional, even faster, async logging .
|
||||
* Log levels.
|
||||
|
||||
|
||||
@ -61,17 +61,28 @@ int main(int, char* [])
|
||||
std::string filename = "spdlog_example";
|
||||
auto console = spd::stdout_logger_mt("console");
|
||||
console->info("Welcome to spdlog!") ;
|
||||
console->info() << "Creating file " << filename << "..";
|
||||
console->info("Creating file {}..", filename);
|
||||
|
||||
auto file_logger = spd::rotating_logger_mt("file_logger", filename, 1024 * 1024 * 5, 3);
|
||||
file_logger->info("Log file message number", 1);
|
||||
|
||||
for (int i = 0; i < 100; ++i)
|
||||
{
|
||||
auto square = i*i;
|
||||
file_logger->info() << i << '*' << i << '=' << square << " (" << "0x" << std::hex << square << ")";
|
||||
file_logger->info("{} * {} = {}, i, i, i*i );
|
||||
}
|
||||
|
||||
|
||||
console->info("Easy padding in numbers like {:08d}", 12);
|
||||
console->info("int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
|
||||
console->info("Positional args are {1} {0}..", "too", "supported):
|
||||
|
||||
console->info("{:<30}", "left aligned");
|
||||
console->info("{:>30}", "right aligned");
|
||||
console->info("{:^30}", "centered");
|
||||
|
||||
//see cppformat's full docs here:
|
||||
//http://cppformat.readthedocs.org/en/stable/syntax.html
|
||||
|
||||
// Change log level to all loggers to warning and above
|
||||
spd::set_level(spd::level::WARN);
|
||||
console->info("This should not be displayed");
|
||||
|
Loading…
Reference in New Issue
Block a user