From 3025031e10fc32a0eef0f269e617f68bab2017da Mon Sep 17 00:00:00 2001 From: Paul Merrill Date: Sun, 14 Aug 2011 14:44:29 -0700 Subject: [PATCH] polish Log --- src/common.h | 2 +- src/log.cpp | 16 ++++------------ src/log.h | 34 +++++++++++++++++++--------------- 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/common.h b/src/common.h index ece4358..3527870 100644 --- a/src/common.h +++ b/src/common.h @@ -10,7 +10,7 @@ #include #include -#include "log.h" +#include "log.h" // for message_mode_t //! Game Movement Mode enum movement_mode_t { diff --git a/src/log.cpp b/src/log.cpp index 72efc95..70bc027 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -7,16 +7,10 @@ #include "config.h" #include "log.h" -/** - * Singleton enforcement. - */ +//! Singleton enforcement. Log* Log::instance() { - static Log* inst = NULL; - if (!inst) { - inst = new Log; - } - + static Log* inst = new Log; return inst; } @@ -25,16 +19,14 @@ Log::Log() mode = MESSAGE_MODE; } -/** - * Specify mode setting. - */ +//! Specify mode setting. void Log::setMode(message_mode_t mode) { Log* l = instance(); l->mode = mode; } -/** +/* * Give output to the "write" function if it is allowed to be sent in * the current mode. */ diff --git a/src/log.h b/src/log.h index 32f5daf..c45f1cd 100644 --- a/src/log.h +++ b/src/log.h @@ -11,20 +11,18 @@ #include //! Logging Mode Enum -/*! - This enum defines the logging modes. -*/ + +//! This enum defines the logging modes. enum message_mode_t { - MM_SILENT = 1, // Only error messages are sent to the console. - MM_DEVELOPER, // Error messages and development messages are sent to the - // console. - MM_DEBUG // All messages are sent to the console. + //! Only error messages are sent to the console. + MM_SILENT = 1, + //! Error and development messages are sent to the console. + MM_DEVELOPER, + //! All messages are sent to the console. + MM_DEBUG }; -//! Log Class -/*! - This is a singleton that handles error messages. -*/ +//! This is a singleton that handles error messages. class Log { public: @@ -45,13 +43,19 @@ public: static void blank(); private: - static Log* instance(); // Access to our singleton instance. + //! Access to our singleton instance. + static Log* instance(); static std::string& rtrim(std::string& str); - Log(); // Hide our constructor. + //! Hide our constructor. + Log(); + + + //! Our class instance. + static Log* pInstance; - static Log* pInstance; // Our class instance. - message_mode_t mode; // Message mode that has been set. + //! Controls verbosity. + message_mode_t mode; }; #endif -- 2.11.4.GIT