Last change
on this file since 501 was
501,
checked in by ymipsl, 10 years ago
|
Add licence copyright to all file ond directory src using the command :
svn propset -R copyright -F header_licence src
XIOS is now officialy under CeCILL licence
YM
|
-
Property copyright set to
Software name : XIOS (Xml I/O Server) http://forge.ipsl.jussieu.fr/ioserver Creation date : January 2009 Licence : CeCCIL version2 see license file in root directory : Licence_CeCILL_V2-en.txt or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement) CNRS/IPSL (Institut Pierre Simon Laplace) Project Manager : Yann Meurdesoif yann.meurdesoif@cea.fr
|
File size:
1.3 KB
|
Rev | Line | |
---|
[380] | 1 | #ifndef __XIOS_LOG_HPP__ |
---|
| 2 | #define __XIOS_LOG_HPP__ |
---|
[300] | 3 | |
---|
[364] | 4 | #include <string> |
---|
[300] | 5 | #include <iostream> |
---|
[369] | 6 | #include <string> |
---|
[300] | 7 | |
---|
[335] | 8 | namespace xios |
---|
[300] | 9 | { |
---|
| 10 | using namespace std ; |
---|
| 11 | |
---|
| 12 | class CLog : public ostream |
---|
| 13 | { |
---|
| 14 | public : |
---|
[490] | 15 | CLog(const string& name_) : ostream(cout.rdbuf()),level(0),name(name_), strBuf_(cout.rdbuf()) {} |
---|
| 16 | CLog& operator()(int l) |
---|
| 17 | { |
---|
| 18 | if (l<=level) |
---|
[300] | 19 | { |
---|
[490] | 20 | rdbuf(strBuf_); |
---|
[347] | 21 | *this<<"-> "<<name<<" : " ; |
---|
[300] | 22 | } |
---|
| 23 | else rdbuf(NULL) ; |
---|
| 24 | return *this; |
---|
| 25 | } |
---|
[490] | 26 | void setLevel(int l) {level=l; } |
---|
[300] | 27 | int getLevel() {return level ;} |
---|
| 28 | bool isActive(void) { if (rdbuf()==NULL) return true ; else return false ;} |
---|
| 29 | bool isActive(int l) {if (l<=level) return true ; else return false ; } |
---|
| 30 | |
---|
[490] | 31 | public: |
---|
| 32 | //! Write info into a file with its streambuf |
---|
| 33 | void write2File(std::streambuf* sBuff) { changeStreamBuff(sBuff); } |
---|
| 34 | |
---|
| 35 | //! Write info into standard output |
---|
| 36 | void write2StdOut() { changeStreamBuff(cout.rdbuf()); } |
---|
| 37 | private: |
---|
| 38 | /*! |
---|
| 39 | * \brief Change current streambuf (by default std::cout) to new one |
---|
| 40 | * This function associates a new streambuf to the current log object |
---|
| 41 | * \param [in] pointer to new streambuf |
---|
| 42 | */ |
---|
| 43 | void changeStreamBuff(std::streambuf* sBuff) { strBuf_ = sBuff; rdbuf(sBuff); } |
---|
| 44 | |
---|
[300] | 45 | private : |
---|
| 46 | int level ; |
---|
[347] | 47 | string name ; |
---|
[490] | 48 | std::streambuf* strBuf_; |
---|
[300] | 49 | }; |
---|
| 50 | |
---|
| 51 | extern CLog info; |
---|
[347] | 52 | extern CLog report; |
---|
[300] | 53 | } |
---|
| 54 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.