├── .travis.yml
├── LICENSE
├── README.md
├── demo.cc
├── drecho.cpp
└── drecho.hpp
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: cpp
2 | sudo: required
3 |
4 | compiler:
5 | - clang
6 | - gcc
7 |
8 | install:
9 | - wget --quiet -O - https://raw.githubusercontent.com/r-lyeh/depot/master/travis.pre.sh | bash -x
10 |
11 | script:
12 | - wget --quiet -O - https://raw.githubusercontent.com/r-lyeh/depot/master/travis.build.sh | bash -x
13 | - wget --quiet -O - https://raw.githubusercontent.com/r-lyeh/depot/master/travis.run.sh | bash -x
14 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015 r-lyeh (https://github.com/r-lyeh)
2 |
3 | This software is provided 'as-is', without any express or implied
4 | warranty. In no event will the authors be held liable for any damages
5 | arising from the use of this software.
6 |
7 | Permission is granted to anyone to use this software for any purpose,
8 | including commercial applications, and to alter it and redistribute it
9 | freely, subject to the following restrictions:
10 |
11 | 1. The origin of this software must not be misrepresented; you must not
12 | claim that you wrote the original software. If you use this software
13 | in a product, an acknowledgment in the product documentation would be
14 | appreciated but is not required.
15 | 2. Altered source versions must be plainly marked as such, and must not be
16 | misrepresented as being the original software.
17 | 3. This notice may not be removed or altered from any source distribution.
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | DrEcho :pill:
2 | ======
3 |
4 | - Dr Echo to spice your terminal up. Written in C++11.
5 | - Dr Echo is cross-platform.
6 | - Dr Echo is zlib/libpng licensed.
7 |
8 | ### API
9 |
10 | ```c++
11 | #include
12 | #include "drecho.hpp"
13 |
14 | // default settings
15 | const bool dr::log_timestamp = true;
16 | const bool dr::log_branch = true;
17 | const bool dr::log_branch_scope = true;
18 | const bool dr::log_text = true;
19 | const bool dr::log_errno = true;
20 | const bool dr::log_location = true;
21 |
22 | int main(void) {
23 | // hello world, classic
24 | std::cout << "classic hello world" << std::endl;
25 |
26 | // DrEcho spices up this
27 | dr::echo << "new hello world. notice the extra timestamp on the left" << std::endl;
28 |
29 | // DrEcho can also detect posix, OpenGL and win32 errors automatically
30 | errno = EAGAIN;
31 | dr::echo << "an error will be catched on this line" << std::endl;
32 |
33 | // Set up a few custom keywords to highlight
34 | dr::highlight( DR_YELLOW, { "warn", "warning" } );
35 | dr::highlight( DR_GREEN, { "info", "debug" } );
36 | dr::highlight( DR_CYAN, { "another", "branch" } );
37 | dr::echo << "this is another warning with a few debug keywords" << std::endl;
38 |
39 | // Spice up cout from now
40 | dr::capture( std::cout );
41 | std::cout << "this cout will be highlighted" << std::endl;
42 |
43 | // Showcase tree usage
44 | {
45 | dr::tab scope;
46 | std::cout << "this is branch #1" << std::endl;
47 | {
48 | dr::tab scope;
49 | std::cout << "this is branch #1.1" << std::endl;
50 | std::cout << "this is branch #1.2" << std::endl;
51 | {
52 | dr::tab scope;
53 | std::cout << "this is branch #1.2.1" << std::endl;
54 | std::cout << "this is branch #1.2.2" << std::endl;
55 | }
56 | std::cout << "this is branch #1.3" << std::endl;
57 | }
58 | std::cout << "this is branch #2" << std::endl;
59 | }
60 |
61 | // Release our spiced up cout
62 | dr::release( std::cout );
63 | std::cout << ">> back to ordinary world" << std::endl;
64 | }
65 | ```
66 |
67 | ### Possible output
68 |
69 | 
70 |
71 | ### Changelog
72 | - v1.0.0 (2016/04/11): Initial semantic versioning adherence
73 |
--------------------------------------------------------------------------------
/demo.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include "drecho.hpp"
3 |
4 | // default settings
5 | const bool dr::log_timestamp = true;
6 | const bool dr::log_branch = true;
7 | const bool dr::log_branch_scope = true;
8 | const bool dr::log_text = true;
9 | const bool dr::log_errno = true;
10 | const bool dr::log_location = true;
11 |
12 | int main(void) {
13 | // hello world, classic
14 | std::cout << "classic hello world" << std::endl;
15 |
16 | // DrEcho spices up this
17 | dr::echo << "new hello world. notice the extra timestamp on the left" << std::endl;
18 |
19 | // DrEcho can also detect posix, OpenGL and win32 errors automatically
20 | errno = EAGAIN;
21 | dr::echo << "an error will be catched on this line" << std::endl;
22 |
23 | // Set up a few custom keywords to highlight
24 | dr::highlight( DR_YELLOW, { "warn", "warning" } );
25 | dr::highlight( DR_GREEN, { "info", "debug" } );
26 | dr::highlight( DR_CYAN, { "another", "branch" } );
27 | dr::echo << "this is another warning with a few debug keywords" << std::endl;
28 |
29 | // Spice up cout from now
30 | dr::capture( std::cout );
31 | std::cout << "this cout will be highlighted" << std::endl;
32 |
33 | // Showcase tree usage
34 | {
35 | dr::tab scope;
36 | std::cout << "this is branch #1" << std::endl;
37 | {
38 | dr::tab scope;
39 | std::cout << "this is branch #1.1" << std::endl;
40 | std::cout << "this is branch #1.2" << std::endl;
41 | {
42 | dr::tab scope;
43 | std::cout << "this is branch #1.2.1" << std::endl;
44 | std::cout << "this is branch #1.2.2" << std::endl;
45 | }
46 | std::cout << "this is branch #1.3" << std::endl;
47 | }
48 | std::cout << "this is branch #2" << std::endl;
49 | }
50 |
51 | // Release our spiced up cout
52 | dr::release( std::cout );
53 | std::cout << ">> back to ordinary world" << std::endl;
54 | }
55 |
--------------------------------------------------------------------------------
/drecho.cpp:
--------------------------------------------------------------------------------
1 | // DrEcho spices your terminal up
2 | // - rlyeh, zlib/libpng licensed.
3 |
4 | // @todo optional DR_ASSERT on detected errors
5 |
6 | // @todo .html logs, unconditionally
7 | // @todo .flat logs on linux, with no ansi codes
8 | // @todo .ansi logs on windows, and then provide tint.exe viewer in tools/
9 |
10 | // @todo hotkeys filtering in runtime (ie, strike 'd'e'b'u'g' keys to filter lines with 'debug' keywords only)
11 | // @todo clipboard filtering in runtime (ie, copy this 'debug' text to filter lines with 'debug' keywords only)
12 | // @todo also negative logic ('error -debug' : lines with 'error' keyword that have no 'debug' keywords in it)
13 |
14 | // -- 8< -- 8< -- 8< -- 8< -- 8< -- 8< -- 8< -- 8< -- 8< -- 8< -- 8< -- 8< -- 8< -- 8< -- 8< -- 8< -- 8<
15 |
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include