Update README.md

This commit is contained in:
Gabi Melman 2014-12-07 05:05:01 +02:00
parent f6adbeaf82
commit 741bf8cde1

View File

@ -18,7 +18,7 @@ Just copy the files to your build tree and use a C++11 compiler
* Headers only. * Headers only.
* No dependencies. * No dependencies.
* Cross platform - Linux / Windows on 32/64 bits. * 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"; * stream call style: ```logger.info("Hello") << " logger";
* mixed calls style ```logger.info("Hello {}", name) << 1 << 2 << 3; * mixed calls style ```logger.info("Hello {}", name) << 1 << 2 << 3;
* [Custom](https://github.com/gabime/spdlog/wiki/Custom-formatting) formatting. * [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. * Console logging.
* Linux syslog. * Linux syslog.
* Easily extendable with custom log targets (just implement a single function in the [sink](include/spdlog/sinks/sink.h) interface). * 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. * Log levels.
@ -61,17 +61,28 @@ int main(int, char* [])
std::string filename = "spdlog_example"; std::string filename = "spdlog_example";
auto console = spd::stdout_logger_mt("console"); auto console = spd::stdout_logger_mt("console");
console->info("Welcome to spdlog!") ; 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); auto file_logger = spd::rotating_logger_mt("file_logger", filename, 1024 * 1024 * 5, 3);
file_logger->info("Log file message number", 1); file_logger->info("Log file message number", 1);
for (int i = 0; i < 100; ++i) for (int i = 0; i < 100; ++i)
{ {
auto square = i*i; file_logger->info("{} * {} = {}, i, i, i*i );
file_logger->info() << i << '*' << i << '=' << square << " (" << "0x" << std::hex << square << ")";
} }
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 // Change log level to all loggers to warning and above
spd::set_level(spd::level::WARN); spd::set_level(spd::level::WARN);
console->info("This should not be displayed"); console->info("This should not be displayed");