TableLogSink.h
Go to the documentation of this file.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 #ifndef TABLES_TABLELOGSINK_H
00030 #define TABLES_TABLELOGSINK_H
00031
00032
00033 #include <casacore/casa/aips.h>
00034 #include <casacore/casa/Logging/LogSink.h>
00035 #include <casacore/casa/Logging/LogFilter.h>
00036 #include <casacore/tables/Tables/Table.h>
00037 #include <casacore/tables/Tables/ScalarColumn.h>
00038 #include <casacore/tables/Tables/ArrayColumn.h>
00039 #include <casacore/casa/Utilities/Assert.h>
00040 #include <casacore/casa/Exceptions/Error.h>
00041
00042 namespace casacore {
00043
00044
00045 class TableDesc;
00046 class SetupNewTable;
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 class TableLogSink : public LogSinkInterface
00093 {
00094 public:
00095
00096
00097
00098
00099 TableLogSink (LogMessage::Priority filter, const String& fileName);
00100 TableLogSink (const LogFilterInterface& filter, const String& fileName);
00101
00102
00103
00104
00105
00106 explicit TableLogSink (const String& fileName);
00107
00108
00109
00110 TableLogSink (const TableLogSink& other);
00111 TableLogSink& operator= (const TableLogSink& other);
00112
00113
00114 ~TableLogSink();
00115
00116
00117
00118 void reopenRW (const LogFilterInterface& filter);
00119
00120
00121 virtual Bool postLocally (const LogMessage& message);
00122
00123
00124 virtual uInt nelements() const;
00125
00126
00127
00128 virtual Double getTime (uInt i) const;
00129 virtual String getPriority (uInt i) const;
00130 virtual String getMessage (uInt i) const;
00131 virtual String getLocation (uInt i) const;
00132 virtual String getObjectID (uInt i) const;
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 const Table& table() const;
00145 Table& table();
00146 const ScalarColumn<Double>& roTime() const;
00147 ScalarColumn<Double>& time();
00148 const ScalarColumn<String>& roPriority() const;
00149 ScalarColumn<String>& priority();
00150 const ScalarColumn<String>& roMessage() const;
00151 ScalarColumn<String>& message();
00152 const ScalarColumn<String>& roLocation() const;
00153 ScalarColumn<String>& location();
00154 const ScalarColumn<String>& roObjectID() const;
00155 ScalarColumn<String>& objectID();
00156
00157
00158
00159
00160 enum Columns {
00161
00162 TIME,
00163
00164 PRIORITY,
00165
00166 MESSAGE,
00167
00168
00169
00170 LOCATION,
00171
00172
00173 OBJECT_ID
00174 };
00175
00176
00177
00178 static String columnName(Columns which);
00179
00180
00181
00182
00183 static TableDesc logTableDescription();
00184
00185
00186 virtual void flush (Bool global=True);
00187
00188
00189 virtual void writeLocally (Double time, const String& message,
00190 const String& priority, const String& location,
00191 const String& objectID);
00192
00193
00194 virtual void clearLocally();
00195
00196
00197 static String localId( );
00198
00199 String id( ) const;
00200
00201
00202
00203
00204 static LogSink makeSink (const String& fileName);
00205 static LogSink makeSink (LogMessage::Priority filter,
00206 const String& fileName);
00207 static LogSink makeSink (const LogFilterInterface& filter,
00208 const String& fileName);
00209
00210
00211 private:
00212
00213 TableLogSink();
00214
00215 void copy_other(const TableLogSink& other);
00216
00217 void makeTable (SetupNewTable&);
00218
00219 void attachCols();
00220
00221 void init (const String& fileName);
00222
00223
00224 Table log_table_p;
00225 ScalarColumn<Double> time_p;
00226 ScalarColumn<String> priority_p;
00227 ScalarColumn<String> message_p;
00228
00229 ScalarColumn<String> location_p;
00230
00231 ScalarColumn<String> id_p;
00232 };
00233
00234
00235 inline const Table& TableLogSink::table() const {return log_table_p;}
00236 inline Table& TableLogSink::table() {return log_table_p;}
00237
00238 inline const ScalarColumn<Double>& TableLogSink::roTime() const
00239 {return time_p;}
00240 inline ScalarColumn<Double>& TableLogSink::time()
00241 {return time_p;}
00242 inline const ScalarColumn<String>& TableLogSink::roPriority() const
00243 {return priority_p;}
00244 inline ScalarColumn<String>& TableLogSink::priority()
00245 {return priority_p;}
00246 inline const ScalarColumn<String>& TableLogSink::roLocation() const
00247 {return location_p;}
00248 inline ScalarColumn<String>& TableLogSink::location()
00249 {return location_p;}
00250 inline const ScalarColumn<String>& TableLogSink::roObjectID() const
00251 {return id_p;}
00252 inline ScalarColumn<String>& TableLogSink::objectID()
00253 {return id_p;}
00254 inline const ScalarColumn<String>& TableLogSink::roMessage() const
00255 {return message_p;}
00256 inline ScalarColumn<String>& TableLogSink::message()
00257 {return message_p;}
00258
00259 inline LogSink TableLogSink::makeSink (const String& fileName)
00260 { return makeSink (LogFilter(), fileName); }
00261 inline LogSink TableLogSink::makeSink (LogMessage::Priority filter,
00262 const String& fileName)
00263 { return makeSink (LogFilter(filter), fileName); }
00264
00265
00266
00267 }
00268
00269 #endif