summaryrefslogtreecommitdiff
path: root/lib/common/Logging.h
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2015-05-04 18:56:43 +0000
committerChris Wilson <chris+github@qwirx.com>2015-05-04 18:56:43 +0000
commite266b546a960ce6c7400ec546f7edce8f8fdd8a1 (patch)
tree35fb3a8771da2c38d0f56bc9b7ec7436c99ba370 /lib/common/Logging.h
parentffbdc492d317ea305c0462d0a0afbacc8c4a0a6c (diff)
Add command-line option to limit log messages to certain file(s).
E.g. you can run with -L NamedLock.cpp to only show messages logged in that file. You can also repeat it to only show messages from certain files.
Diffstat (limited to 'lib/common/Logging.h')
-rw-r--r--lib/common/Logging.h43
1 files changed, 41 insertions, 2 deletions
diff --git a/lib/common/Logging.h b/lib/common/Logging.h
index 856c0499..f61bf1dc 100644
--- a/lib/common/Logging.h
+++ b/lib/common/Logging.h
@@ -385,6 +385,9 @@ class Capture : public Logger
}
};
+// Forward declaration
+class HideFileGuard;
+
// --------------------------------------------------------------------------
//
// Class
@@ -406,7 +409,8 @@ class Logging
static Syslog* spSyslog;
static Logging sGlobalLogging;
static std::string sProgramName;
-
+ static std::auto_ptr<HideFileGuard> sapHideFileGuard;
+
public:
Logging ();
~Logging();
@@ -501,11 +505,16 @@ class Logging
}
};
+ // Process global options
+ static std::string GetOptionString();
+ static int ProcessOption(signed int option);
+ static std::string GetUsageString();
+
// --------------------------------------------------------------------------
//
// Class
// Name: Logging::OptionParser
- // Purpose: Process command-line options
+ // Purpose: Process command-line options, some global, some local
// Created: 2014/04/09
//
// --------------------------------------------------------------------------
@@ -629,6 +638,36 @@ class HideCategoryGuard : public Logger
virtual void SetProgramName(const std::string& rProgramName) { }
};
+class HideFileGuard : public Logger
+{
+ private:
+ std::list<std::string> mFileNames;
+ HideFileGuard(const HideFileGuard& other); // no copying
+ HideFileGuard& operator=(const HideFileGuard& other); // no assignment
+ bool mHideAllButSelected;
+
+ public:
+ HideFileGuard(const std::string& rFileName, bool HideAllButSelected = false)
+ : mHideAllButSelected(HideAllButSelected)
+ {
+ mFileNames.push_back(rFileName);
+ Logging::Add(this);
+ }
+ ~HideFileGuard()
+ {
+ Logging::Remove(this);
+ }
+ void Add(const std::string& rFileName)
+ {
+ mFileNames.push_back(rFileName);
+ }
+ virtual bool Log(Log::Level level, const std::string& file, int line,
+ const std::string& function, const Log::Category& category,
+ const std::string& message);
+ virtual const char* GetType() { return "HideFileGuard"; }
+ virtual void SetProgramName(const std::string& rProgramName) { }
+};
+
std::string PrintEscapedBinaryData(const std::string& rInput);
#endif // LOGGING__H