OPeNDAP Hyrax Back End Server (BES)
Updated for version 3.8.3
|
00001 // BESLog.h 00002 00003 // This file is part of bes, A C++ back-end server implementation framework 00004 // for the OPeNDAP Data Access Protocol. 00005 00006 // Copyright (c) 2004-2009 University Corporation for Atmospheric Research 00007 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu> 00008 // 00009 // This library is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU Lesser General Public 00011 // License as published by the Free Software Foundation; either 00012 // version 2.1 of the License, or (at your option) any later version. 00013 // 00014 // This library is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 // Lesser General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU Lesser General Public 00020 // License along with this library; if not, write to the Free Software 00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 // 00023 // You can contact University Corporation for Atmospheric Research at 00024 // 3080 Center Green Drive, Boulder, CO 80301 00025 00026 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005 00027 // Please read the full copyright statement in the file COPYRIGHT_UCAR. 00028 // 00029 // Authors: 00030 // pwest Patrick West <pwest@ucar.edu> 00031 // jgarcia Jose Garcia <jgarcia@ucar.edu> 00032 00033 #ifndef BESLog_h_ 00034 #define BESLog_h_ 1 00035 00036 #include <fstream> 00037 #include <string> 00038 00039 using std::ofstream ; 00040 using std::ios ; 00041 using std::ostream ; 00042 using std::string ; 00043 00044 #include "BESObj.h" 00045 00087 class BESLog : public BESObj 00088 { 00089 private: 00090 static BESLog * _instance ; 00091 int _flushed ; 00092 ofstream * _file_buffer ; 00093 string _file_name ; 00094 // Flag to indicate the object is not routing data to its associated stream 00095 int _suspended ; 00096 // Flag to indicate whether to log verbose messages 00097 bool _verbose ; 00098 protected: 00099 BESLog(); 00100 00101 // Dumps the current system time. 00102 void dump_time() ; 00103 public: 00104 ~BESLog(); 00105 00111 void suspend() 00112 { 00113 _suspended = 1 ; 00114 } 00115 00121 void resume() 00122 { 00123 _suspended = 0 ; 00124 } 00125 00132 void verbose_on() 00133 { 00134 _verbose = true ; 00135 } 00136 00142 void verbose_off() 00143 { 00144 _verbose = false ; 00145 } 00146 00162 bool is_verbose() 00163 { 00164 return _verbose ; 00165 } 00166 00168 typedef ios& (*p_ios_manipulator) (ios&); 00170 typedef ostream& (*p_ostream_manipulator) (ostream&); 00171 00172 BESLog& operator << (string&); 00173 BESLog& operator << (const string&); 00174 BESLog& operator << (char*); 00175 BESLog& operator << (const char*); 00176 BESLog& operator << (int); 00177 BESLog& operator << (char); 00178 BESLog& operator << (long); 00179 BESLog& operator << (unsigned long); 00180 BESLog& operator << (double); 00181 00182 BESLog& operator<<(p_ostream_manipulator); 00183 BESLog& operator<<(p_ios_manipulator); 00184 00185 virtual void dump( ostream &strm ) const ; 00186 00187 static BESLog *TheLog() ; 00188 }; 00189 00190 #endif // BESLog_h_ 00191