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 //
9 #ifndef anna_core_tracing_Configuration_hpp
10 #define anna_core_tracing_Configuration_hpp
14 #include <anna/core/Singleton.hpp>
15 #include <anna/core/tracing/Logger.hpp>
17 #include <anna/core/util/RegularExpression.hpp>
31 * Class used for selective tracing configuration
33 class Configuration : public anna::Singleton <Configuration> {
38 typedef std::map<anna::RegularExpression, anna::Logger::Level> trace_trigger_map_t;
42 trace_trigger_map_t a_traceTriggers; // configured triggers map, for selective tracing
43 bool a_readTraceTriggersAsRegexp; // boolean to configure the way in which trace triggers are interpreted
46 Configuration() { a_readTraceTriggersAsRegexp = false; } // private constructor
48 friend class anna::Singleton <Configuration>;
49 friend class TraceLevelChecker;
52 const trace_trigger_map_t & getTraceTriggers() const throw() { return a_traceTriggers; }
58 * Deletes all added triggers for selective tracing.
60 void resetTraceTriggers() throw() { a_traceTriggers.clear(); }
64 * Activates a trigger for selective tracing. The normal way is to activate only one
65 * (usually applications register MSISDN, but we prefer the name 'trigger' because
66 * selective tracing capabilities are generalized for any context data we want to detect).
67 * Anyway, it is possible to add several string references for multiple context log activation.
69 * @param trigger String reference for contexts comparison
70 * @param accumulate Boolean for trigger filter accumulation over internal set. I.e., application
71 * could test any MSISDN within a configured set. False by default, means activation for only one
73 * @param level Desired trace level when context fulfill this trigger reference. Debug by default
75 void activateTraceTrigger(const std::string & trigger, bool accumulate = false, anna::Logger::Level level = anna::Logger::Debug) throw();
79 * Deletes a trigger for selective tracing.
81 * @param trigger String reference to be erased from internal trigger set
83 void deactivateTraceTrigger(const std::string & trigger) throw();
87 * Interpret all trace triggers as regular expressions.
88 * Is used from TraceLevelChecker to provide strict or regexp-based checkings.
89 * If not configured, regexp is disabled.
91 * @return Boolean about if regular expressions interpretation are activated.
93 bool readRegexpForTraceTriggers() const throw() { return (a_readTraceTriggersAsRegexp); }
97 * Configure all trace triggers to be interpreted as regular expressions.
98 * Application can set this depending on trace filtering needs.
99 * If not configured, regexp is disabled for TraceLevelChecker.
101 * @param readRegexp Boolean for activation/deactivation of regexp funtionality
103 void useRegexpForTraceTriggers(bool readRegexp = true) throw() { a_readTraceTriggersAsRegexp = readRegexp; }
107 * Class string representation
109 * @return String with class content
111 std::string asString(void) const throw();