00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef OFLOGFIL_H
00035 #define OFLOGFIL_H
00036
00037 #include "dcmtk/config/osconfig.h"
00038 #include "dcmtk/ofstd/ofthread.h"
00039 #include "dcmtk/ofstd/ofstream.h"
00040
00041 #define INCLUDE_CSTDLIB
00042 #include "dcmtk/ofstd/ofstdinc.h"
00043
00044
00049 class OFLogFile
00050 {
00051 public:
00052
00055 enum LF_Level
00056 {
00058 LL_none = 0,
00060 LL_error = 1,
00062 LL_warning = 2,
00064 LL_informational = 3,
00066 LL_debug = 4
00067 };
00068
00074 OFLogFile(const char *filename, int flags = ios::app);
00075
00078 virtual ~OFLogFile() {}
00079
00088 ofstream &lockFile(LF_Level level = LL_none, const char *module = NULL);
00089
00092 void unlockFile()
00093 {
00094 File.flush();
00095 #ifdef _REENTRANT
00096 Mutex.unlock();
00097 #endif
00098 }
00099
00103 OFBool good()
00104 {
00105 #ifdef _REENTRANT
00106 Mutex.lock();
00107 #endif
00108 OFBool status = File.good() ? OFTrue : OFFalse;
00109 #ifdef _REENTRANT
00110 Mutex.unlock();
00111 #endif
00112 return status;
00113 }
00114
00120 ostream& getFile()
00121 {
00122 return File;
00123 }
00124
00132 void writeMessage(const char *message, int indent = 3);
00133
00142 void setFilter(LF_Level level)
00143 {
00144 #ifdef _REENTRANT
00145 Mutex.lock();
00146 #endif
00147 Filter = level;
00148 #ifdef _REENTRANT
00149 Mutex.unlock();
00150 #endif
00151 }
00152
00156 LF_Level getFilter()
00157 {
00158 return Filter;
00159 }
00160
00165 OFBool checkFilter(LF_Level level)
00166 {
00167 return (level != LL_none) && (level <= Filter);
00168 }
00169
00170
00171 private:
00172
00174 OFLogFile(const OFLogFile &arg);
00175
00177 OFLogFile& operator=(const OFLogFile &arg);
00178
00180 ofstream File;
00181
00183 LF_Level Filter;
00184
00185 #ifdef _REENTRANT
00186
00187 OFMutex Mutex;
00188 #endif
00189 };
00190
00191
00192 #endif
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241