]>
Dogcows Code - chaz/yoink/blob - src/Moof/Log.hh
c7736301fc679f6ede496933d0eccbc866d530e1
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
10 **************************************************************************/
17 * Functions related to logging the process.
18 * The logging functions are logError(), logWarning(), and logInfo(),
19 * listed from most critical to least critical.
22 #include <cstdlib> // exit
27 * Macro which tests an assertion and issues an logError() and exits if
29 * @param X test to perform
37 #define ASSERT(X) if (!(X)) Mf::logError \
38 << "false assertion at " << __FILE__ << ":" << __LINE__ << ", " \
52 NONE
= 0, ///< Disable all logging.
53 ERRORR
= 1, ///< Log only errors.
54 WARNING
= 2, ///< Log warnings and errors.
55 INFO
= 3, ///< Log everything.
58 static void setLevel(Level level
);
59 static Level
getLevel();
62 Log(Level level
, const char* type
) :
64 mType(type
) /* only pass literal strings */ {}
68 void operator () (const T
& item
)
70 *this << item
<< std::endl
;
75 template <typename T
> friend std::ostream
& operator << (Log
&, const T
&);
84 extern std::ostream
& log
;
85 extern std::ostream
& nullLog
;
88 extern Log logWarning
;
93 inline std::ostream
& operator << (Log
& logObj
, const T
& item
)
95 if (Log::gLevel
< logObj
.mLevel
) return nullLog
;
96 return log
<< logObj
.mType
<< item
;
101 void importLogFunctions(Script
& script
);
106 #endif // _MOOF_LOG_H_
This page took 0.041581 seconds and 4 git commands to generate.