summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-02-28 01:37:19 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-02-28 01:37:19 -0600
commitd3d13329d98b2b26378813a91ad0d4e49045a426 (patch)
tree2edbf8eb068d6e037b46a0074f556d6d685413be /src
parentfc62402c60cd3faac37f3cd60ee417d119869929 (diff)
downloadfork-ledger-d3d13329d98b2b26378813a91ad0d4e49045a426.tar.gz
fork-ledger-d3d13329d98b2b26378813a91ad0d4e49045a426.tar.bz2
fork-ledger-d3d13329d98b2b26378813a91ad0d4e49045a426.zip
Made the --debug option's argument a regex
Diffstat (limited to 'src')
-rw-r--r--src/utils.cc7
-rw-r--r--src/utils.h26
2 files changed, 30 insertions, 3 deletions
diff --git a/src/utils.cc b/src/utils.cc
index 2f64bb0a..5260fd42 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -603,7 +603,12 @@ void logger_func(log_level_t level)
namespace ledger {
-optional<std::string> _log_category;
+optional<std::string> _log_category;
+#if defined(HAVE_BOOST_REGEX_UNICODE)
+optional<boost::u32regex> _log_category_re;
+#else
+optional<boost::regex> _log_category_re;
+#endif
struct __maybe_enable_debugging {
__maybe_enable_debugging() {
diff --git a/src/utils.h b/src/utils.h
index e1a03d79..c7aaac52 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -338,10 +338,32 @@ extern uint8_t _trace_level;
#if defined(DEBUG_ON)
-extern optional<std::string> _log_category;
+extern optional<std::string> _log_category;
+#if defined(HAVE_BOOST_REGEX_UNICODE)
+ extern optional<boost::u32regex> _log_category_re;
+#else
+ extern optional<boost::regex> _log_category_re;
+#endif
inline bool category_matches(const char * cat) {
- return _log_category && starts_with(cat, *_log_category);
+ if (_log_category) {
+ if (! _log_category_re) {
+ _log_category_re =
+#if defined(HAVE_BOOST_REGEX_UNICODE)
+ boost::make_u32regex(_log_category->c_str(),
+ boost::regex::perl | boost::regex::icase);
+#else
+ boost::make_regex(_log_category->c_str(),
+ boost::regex::perl | boost::regex::icase);
+#endif
+ }
+#if defined(HAVE_BOOST_REGEX_UNICODE)
+ return boost::u32regex_search(cat, *_log_category_re);
+#else
+ return boost::regex_search(cat, *_log_category_re);
+#endif
+ }
+ return false;
}
#define SHOW_DEBUG(cat) \