diff --git a/.gitignore b/.gitignore index f6e33f8..08c22c7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ test/index +test/demo deps diff --git a/README.md b/README.md index 3695571..f175b82 100644 --- a/README.md +++ b/README.md @@ -27,19 +27,33 @@ DEBUG=bands ./musicprogram ```c++ #include "./deps/heapwolf/debug/index.hxx" -Debug d("bands"); - -// -// The instance can then be called with any number of arbitrary types. -// -d("danzig", 100, 'x'); +Debug debug("demo"); +Debug debug3("demo:beep"); + +int f3 () { + Debug debug2("demo:boop"); + debug2("running function f3"); + debug3("running function f3"); + return 0; +} + + +int f2 () { + debug("running function f2"); + return f3(); +} + +int main () { + debug("starting program"); + f2(); + debug("ending program"); + return 0; +} ``` #### OUTPUT +![example](/docs/screenshot.png) -``` -bands danzig 100 x -``` # TEST diff --git a/docs/screenshot.png b/docs/screenshot.png new file mode 100644 index 0000000..caae9f8 Binary files /dev/null and b/docs/screenshot.png differ diff --git a/index.hxx b/index.hxx index 6dc9436..48e8abf 100644 --- a/index.hxx +++ b/index.hxx @@ -74,6 +74,8 @@ class Debug { if (!std::regex_match(this->name, std::regex(res))) { return; // the env var does not contain the name } + } else { + return; } // diff --git a/package.json b/package.json index fc2fe21..673bad7 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,10 @@ "clang++ -std=c++2a -stdlib=libc++", "test/index.cxx -o test/index && ./test/index" ], - "install": "" + "demo": [ + "clang++ -std=c++2a -stdlib=libc++", + "test/demo.cxx -o test/demo && ./test/demo" + ] }, "flags": [ "-std=c++2a", diff --git a/test/demo.cxx b/test/demo.cxx new file mode 100644 index 0000000..aba04b1 --- /dev/null +++ b/test/demo.cxx @@ -0,0 +1,24 @@ +#include "../index.hxx" + +Debug debug("demo"); +Debug debug3("demo:beep"); + +int f3 () { + Debug debug2("demo:boop"); + debug2("running function f3"); + debug3("running function f3"); + return 0; +} + + +int f2 () { + debug("running function f2"); + return f3(); +} + +int main () { + debug("starting program"); + f2(); + debug("ending program"); + return 0; +}