]> Dogcows Code - chaz/yoink/blobdiff - src/moof/log.hh
the massive refactoring effort
[chaz/yoink] / src / moof / log.hh
similarity index 66%
rename from src/Moof/Log.hh
rename to src/moof/log.hh
index c09ac017690600fb302cb79a382a5ef55b24750e..2679b37306694763e1b0886a904a660f549f5fff 100644 (file)
@@ -9,13 +9,13 @@
 *
 **************************************************************************/
 
-#ifndef _MOOF_LOG_H_
-#define _MOOF_LOG_H_
+#ifndef _MOOF_LOG_HH_
+#define _MOOF_LOG_HH_
 
 /**
- * \file Log.h
+ * \file log.hh
  * Functions related to logging the process.
- * The logging functions are logError(), logWarning(), and logInfo(),
+ * The logging functions are log_error(), log_warning(), and log_info(),
  * listed from most critical to least critical.
  */
 
 #include <iostream>
 
 
-/**
- * Macro which tests an assertion and issues a logError() and exits if the
- * assertion is false.
- * \param X test to perform
- */
-
 #undef ASSERT
-
 #if NDEBUG
 #define ASSERT(X)
 #else
-#define ASSERT(X) if (!(X)) Mf::logError \
+/**
+ * Macro which tests an assertion and issues a log_error() and exits if the
+ * assertion is false.
+ * \param X test to perform
+ */
+#define ASSERT(X) if (!(X)) moof::log_error \
        << "false assertion at " << __FILE__ << ":" << __LINE__ << ", " \
        << #X, exit(1)
 #endif
 
 
-namespace Mf {
+namespace moof {
+
+
+class script;
 
 
 /**
@@ -50,19 +51,19 @@ namespace Mf {
  * stream.  Either way, any object can be printed to the log as long as
  * there is an override for the ostream insertion operator.
  */
-class Log
+class log
 {
 public:
 
        /**
         * A type for the level or priority of a log message.
         */
-       enum Level
+       enum level
        {
-               NONE            = 0,            ///< Disable all logging.
-               ERRORR          = 1,            ///< Log only errors.
-               WARNING         = 2,            ///< Log warnings and errors.
-               INFO            = 3,            ///< Log everything.
+               none            = 0,            ///< Disable all logging.
+               error           = 1,            ///< Log only errors.
+               warning         = 2,            ///< Log warnings and errors.
+               info            = 3,            ///< Log everything.
        };
 
 
@@ -71,14 +72,21 @@ public:
         * log.  Any logging with a lower priority will be ignored.
         * \param level The log level.
         */
-       static void setLevel(Level level);
+       static void level(level level);
 
        /**
         * Get the current lowest-priority log level.  If unchanged, the
-        * default level is INFO.
+        * default level is info.
         * \return The log level.
         */
-       static Level level();
+       static enum level level();
+
+
+       /**
+        * Import log functions to a script.
+        * \param The script.
+        */
+       static void import(script& script);
 
 
        /**
@@ -86,9 +94,9 @@ public:
         * \param level The log level.
         * \param prefix The string printed before each log message.
         */
-       Log(Level level, const char* prefix) :
-               mLevel(level),
-               mPrefix(prefix) /* only pass literal strings */ {}
+       log(enum level level, const char* prefix) :
+               level_(level),
+               prefix_(prefix) /* only pass literal strings */ {}
 
 
        template <class A>
@@ -132,36 +140,32 @@ public:
 
 private:
 
-       template <class T> friend std::ostream& operator << (Log&, const T&);
+       template <class T> friend std::ostream& operator << (log&, const T&);
 
-       static Level    gLevel;
+       static enum level       gLevel;
 
-       Level                   mLevel;
-       const char*             mPrefix;
+       enum level                      level_;
+       const char*                     prefix_;
 };
 
 
 extern std::ostream&   log;
-extern std::ostream&   nullLog;
+extern std::ostream&   null_log;
 
-extern Log logError;
-extern Log logWarning;
-extern Log logInfo;
+extern class log log_error;
+extern class log log_warning;
+extern class log log_info;
 
 
 template <class T>
-inline std::ostream& operator << (Log& logObj, const T& item)
+inline std::ostream& operator << (class log& log, const T& item)
 {
-       if (Log::gLevel < logObj.mLevel) return nullLog;
-       return log << logObj.mPrefix << item;
+       if (log::gLevel < log.level_) return null_log;
+       return moof::log << log.prefix_ << item;
 }
 
 
-class Script;
-void importLogFunctions(Script& script);
-
-
-} // namespace Mf
+} // namespace moof
 
-#endif // _MOOF_LOG_H_
+#endif // _MOOF_LOG_HH_
 
This page took 0.024714 seconds and 4 git commands to generate.