diff --git a/README.md b/README.md index 8145c91..1c2df2a 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ output: - indentation reflects call structure. We don't see anything for `main()`, since we didn't put any logging there -### 2 +### 2 slightly more elaborate ``` /* examples ex2/ex2.cpp */ @@ -89,6 +89,9 @@ main(int argc, char ** argv) { log && log("<- :fib(n) ", fn); } ``` +- global configuration settings live in the `xo::log_config` class. see [log_config.hpp](include/nestlog/log_config.hpp) +- the recommended form `log && log(...)` tests whether logging at this site is enabled /before/ evaluating/formatting the log message; + when logging is disabled, this saves the cost of computing and formatting that message. output: ![ex2 output](img/ex2.png) diff --git a/example/ex1/ex1.cpp b/example/ex1/ex1.cpp index db0ce39..1258e2a 100644 --- a/example/ex1/ex1.cpp +++ b/example/ex1/ex1.cpp @@ -2,13 +2,17 @@ using namespace xo; -void A(int x) { - XO_SCOPE(log, info); +void inner(int x) { + scope log(XO_ENTER0(always), ":x ", x); +} - log("x:", x); +void outer(int y) { + scope log(XO_ENTER0(always), ":y ", y); + + inner(2*y); } int main(int argc, char ** argv) { - A(66); + outer(123); }