OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
BESLog.h
Go to the documentation of this file.
1 // BESLog.h
2 
3 // This file is part of bes, A C++ back-end server implementation framework
4 // for the OPeNDAP Data Access Protocol.
5 
6 // Copyright (c) 2004-2009 University Corporation for Atmospheric Research
7 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 //
23 // You can contact University Corporation for Atmospheric Research at
24 // 3080 Center Green Drive, Boulder, CO 80301
25 
26 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
27 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
28 //
29 // Authors:
30 // pwest Patrick West <pwest@ucar.edu>
31 // jgarcia Jose Garcia <jgarcia@ucar.edu>
32 
33 #ifndef BESLog_h_
34 #define BESLog_h_ 1
35 
36 #include <fstream>
37 #include <string>
38 
39 using std::ofstream ;
40 using std::ios ;
41 using std::ostream ;
42 using std::string ;
43 
44 #include "BESObj.h"
45 
87 class BESLog : public BESObj
88 {
89 private:
90  static BESLog * _instance ;
91  int _flushed ;
92  ofstream * _file_buffer ;
93  string _file_name ;
94  // Flag to indicate the object is not routing data to its associated stream
95  int _suspended ;
96  // Flag to indicate whether to log verbose messages
97  bool _verbose ;
98 protected:
99  BESLog();
100 
101  // Dumps the current system time.
102  void dump_time() ;
103 public:
104  ~BESLog();
105 
111  void suspend()
112  {
113  _suspended = 1 ;
114  }
115 
121  void resume()
122  {
123  _suspended = 0 ;
124  }
125 
132  void verbose_on()
133  {
134  _verbose = true ;
135  }
136 
142  void verbose_off()
143  {
144  _verbose = false ;
145  }
146 
162  bool is_verbose()
163  {
164  return _verbose ;
165  }
166 
168  typedef ios& (*p_ios_manipulator) (ios&);
170  typedef ostream& (*p_ostream_manipulator) (ostream&);
171 
172  BESLog& operator << (string&);
173  BESLog& operator << (const string&);
174  BESLog& operator << (char*);
175  BESLog& operator << (const char*);
176  BESLog& operator << (int);
177  BESLog& operator << (char);
178  BESLog& operator << (long);
179  BESLog& operator << (unsigned long);
180  BESLog& operator << (double);
181 
184 
185  virtual void dump( ostream &strm ) const ;
186 
187  static BESLog *TheLog() ;
188 };
189 
190 #endif // BESLog_h_
191