Improve dtd for ADML services
[anna.git] / example / core / selectiveTracing / main.cpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 // Standard
10 #include <iostream>
11
12 // STL
13 #include <string>
14
15 #include <anna/core/functions.hpp>
16 #include <anna/core/core.hpp>
17 #include <anna/core/RuntimeException.hpp>
18 #include <anna/core/tracing/TraceLevelChecker.hpp>
19 #include <anna/core/tracing/Configuration.hpp>
20
21
22
23 using namespace anna;
24 using namespace anna::tracing;
25
26 void _exit(const std::string & msg) {
27    std::cout << std::endl << msg << std::endl;
28    exit(-1);
29 }
30
31 void test(const std::string & value) throw() {
32    LOGINFORMATION(
33       std::string msg = "Starting test for ";
34       msg += value;
35       Logger::information(msg , ANNA_FILE_LOCATION);
36    );
37    anna::tracing::TraceLevelChecker tlc(value.c_str());
38    LOGDEBUG(Logger::debug("Enabled tracing ?", ANNA_FILE_LOCATION));
39    LOGINFORMATION(
40       std::string msg = "Finishing test for ";
41       msg += value;
42       Logger::information(msg , ANNA_FILE_LOCATION);
43    );
44 }
45
46 int main(int argc, char** argv) {
47    Logger::setLevel(Logger::Information);
48 //   Logger::setLevel(Logger::Debug);
49    Logger::initialize("selectiveTracing", new TraceWriter("file.trace", 2048000));
50    anna::tracing::Configuration & conf = anna::tracing::Configuration::instantiate();
51    LOGINFORMATION(Logger::information("Blue Trigger", ANNA_FILE_LOCATION));
52    conf.activateTraceTrigger("blue");
53    test("red");
54    test("blue");
55    test("darkblue");
56    conf.useRegexpForTraceTriggers();
57    test("darkblue");
58    test("green");
59 }
60