1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
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 //
10 #include <anna/core/tracing/Configuration.hpp>
17 //using namespace anna::tracing;
20 //******************************************************************************
21 //---------------------------------------------------------------- Configuration
22 //******************************************************************************
25 //------------------------------------------------------------------------------
26 //---------------------------------------- Configuration::activateTraceTrigger()
27 //------------------------------------------------------------------------------
28 void anna::tracing::Configuration::activateTraceTrigger(const std::string & trigger, bool accumulate, anna::Logger::Level level) throw() {
29 if(!accumulate) resetTraceTriggers();
31 RegularExpression regEx(trigger); // not yet compiled (perhaps no regular expressions used)
32 a_traceTriggers[regEx] = level;
36 //------------------------------------------------------------------------------
37 //-------------------------------------- Configuration::deactivateTraceTrigger()
38 //------------------------------------------------------------------------------
39 void anna::tracing::Configuration::deactivateTraceTrigger(const std::string & trigger) throw() {
40 RegularExpression regEx(trigger); // not yet compiled (perhaps no regular expressions used)
41 trace_trigger_map_t::iterator it = a_traceTriggers.find(regEx);
43 if(it != a_traceTriggers.end()) a_traceTriggers.erase(it);
47 //------------------------------------------------------------------------------
48 //---------------------------------------------------- Configuration::asString()
49 //------------------------------------------------------------------------------
50 std::string anna::tracing::Configuration::asString(void) const throw() {
51 std::string result = "";
52 // Gets selective tracing trigger map representation with this format:
53 // 'trigger1(desiredLevel1)|trigger2(desiredLevel2)| ... |triggerN(desiredLevelN)'
55 if(a_traceTriggers.size() != 0) {
56 trace_trigger_map_t::const_iterator it;
58 for(it = a_traceTriggers.begin(); it != a_traceTriggers.end(); ++it) {
59 result += (*it).first.getPattern();
61 result += Logger::asString((*it).second);
65 // Delete the last pipe: starts at 'size()-1', take 1 character:
66 result.erase(result.size() - 1, 1);
68 result = "Currently, no trigger strings have been added for selective tracing";
71 result += "; Interpreted as Regular Expression: ";
72 result += (a_readTraceTriggersAsRegexp) ? "yes" : "no";