nestlog: choose function-printing style
This commit is contained in:
parent
7c964ab93c
commit
2871874dd8
7 changed files with 81 additions and 24 deletions
36
example/ex3/ex3.cpp
Normal file
36
example/ex3/ex3.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* examples ex3/ex3.cpp */
|
||||
|
||||
#include "nestlog/scope.hpp"
|
||||
|
||||
using namespace xo;
|
||||
|
||||
int
|
||||
fib(int n) {
|
||||
scope log(XO_SSETUP0(), ":n ", n);
|
||||
|
||||
int retval = 1;
|
||||
|
||||
if (n >= 2) {
|
||||
retval = fib(n - 1) + fib(n - 2);
|
||||
log(":n ", n);
|
||||
}
|
||||
|
||||
log.end_scope("<- :retval ", retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char ** argv) {
|
||||
log_config::style = FS_Pretty;
|
||||
log_config::indent_width = 4;
|
||||
|
||||
int n = 4;
|
||||
|
||||
scope log(XO_SSETUP0(), ":n ", 4);
|
||||
|
||||
int fn = fib(n);
|
||||
|
||||
log(":n ", n);
|
||||
log("<- :fib(n) ", fn);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue