From e6fe203cf40a3542cb6949187387f2ab018bc762 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 9 Apr 2014 22:15:49 +0000 Subject: Refactor logging option processing out of Daemon class. Allows command-line tools to reuse the same option processing. --- lib/common/Logging.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'lib/common/Logging.h') diff --git a/lib/common/Logging.h b/lib/common/Logging.h index d74ded61..7cf9d46c 100644 --- a/lib/common/Logging.h +++ b/lib/common/Logging.h @@ -446,6 +446,37 @@ class Logging Logging::Remove(mpLogger); } }; + + // -------------------------------------------------------------------------- + // + // Class + // Name: Logging::OptionParser + // Purpose: Process command-line options + // Created: 2014/04/09 + // + // -------------------------------------------------------------------------- + class OptionParser + { + public: + OptionParser(Log::Level InitialLevel = + #ifdef BOX_RELEASE_BUILD + Log::NOTICE + #else + Log::INFO + #endif + ) + : mCurrentLevel(InitialLevel) + { } + + static std::string GetOptionString(); + int ProcessOption(signed int option); + static std::string GetUsageString(); + int mCurrentLevel; // need an int to do math with + Log::Level GetCurrentLevel() + { + return (Log::Level) mCurrentLevel; + } + }; }; class FileLogger : public Logger -- cgit v1.2.3