Branch data Line data Source code
1 : :
2 : : #include <fstream>
3 : : #include <iomanip>
4 : :
5 : : #include "CubitMessage.hpp"
6 : : #include "CubitDefines.h"
7 : : #include "CubitString.hpp"
8 : : #include "CubitUtil.hpp"
9 : : #include <cassert>
10 : : #include <cstring>
11 : : #include <vector>
12 : : #include <iostream>
13 : :
14 : : #include "SettingHandler.hpp"
15 : :
16 : : #ifdef _WIN32
17 : : #define vsnprintf _vsnprintf
18 : : //#define strdup _strdup
19 : : #endif
20 : :
21 : : int CubitMessage::errorCount = 0;
22 : : int CubitMessage::warningCount = 0;
23 : : //
24 : : // Message type usage:
25 : : // PRINT_ERROR: Message to tell user why the task did not complete.
26 : : // PRINT_WARNING: Message to tell user why completed task may not be what
27 : : // was requested.
28 : : // PRINT_INFO: Message to tell user about status and progress.
29 : : // PRINT_DEBUG: Message to developer tied to a global debug flag.
30 : : // DIAGNOSTIC: Message to developer.
31 : :
32 : :
33 [ - + ]: 6540 : struct DefaultCubitMessageHandler : public CubitMessageHandler
34 : : {
35 : 7681 : void print_message(const char* message)
36 : : {
37 : 7681 : std::cout << message;
38 : 7681 : std::cout.flush();
39 : 7681 : }
40 : 561 : void print_error(const char* message)
41 : : {
42 : : #ifdef XTERM
43 : : char esc = 0x1B;
44 : : // Turn on reverse video on VT102 (xterm also)
45 : : // (0=normal, 1-bold, 4-underscore, 5-blink, 7-inverse)
46 : : std::cout << esc << '[' << '7' << 'm';
47 : : #endif
48 : :
49 : 561 : std::cout << message;
50 : 561 : std::cout.flush();
51 : :
52 : : #ifdef XTERM
53 : : std::cout << esc << '[' << '0' << 'm';
54 : : std::cout.flush();
55 : : #endif
56 : :
57 : 561 : }
58 : : };
59 : :
60 : 1635 : static DefaultCubitMessageHandler mDefaultHandler;
61 : :
62 : :
63 : : CubitMessage* CubitMessage::instance_ = NULL;
64 : : CubitMessageHandler* CubitMessage::mHandler = &mDefaultHandler;
65 : : CubitMessageErrorHandler* CubitMessage::mErrorHandler = NULL;
66 : : int CubitMessage::infoFlag = CUBIT_TRUE;
67 : : int CubitMessage::diagnosticFlag = CUBIT_FALSE;
68 : : int CubitMessage::warningFlag = CUBIT_TRUE;
69 : : int CubitMessage::errorFlag = CUBIT_TRUE;
70 : : std::ofstream* CubitMessage::loggingStream = NULL;
71 : : CubitString* CubitMessage::loggingFile = NULL;
72 : : std::ofstream* CubitMessage::loggingErrorStream = NULL;
73 : : CubitString* CubitMessage::loggingErrorFile = NULL;
74 : : int CubitMessage::expectedStartErrorCount = -1;
75 : : int CubitMessage::expectedEndErrorCount = -1;
76 : : bool CubitMessage::expectedLessErrorCountAccepted = false;
77 : :
78 : 1616692 : CubitMessage* CubitMessage::instance()
79 : : {
80 [ + + ]: 1616692 : if (!instance_)
81 : : {
82 [ + - ]: 705 : instance_ = new CubitMessage;
83 [ - + ]: 705 : if (!instance_)
84 : : {
85 : 0 : std::cerr << " *** Unable to instantiate message object ***" << std::endl;
86 : 0 : exit(1);
87 : : }
88 : : }
89 : 1616692 : return instance_;
90 : : }
91 : :
92 : 0 : void CubitMessage::free_instance()
93 : : {
94 [ # # ]: 0 : if (instance_)
95 [ # # ]: 0 : delete instance_;
96 : 0 : instance_ = NULL;
97 : 0 : }
98 : :
99 : 705 : CubitMessage::CubitMessage()
100 : : {
101 : 705 : infoFlag = CUBIT_TRUE;
102 : 705 : warningFlag = CUBIT_TRUE;
103 : 705 : errorFlag = CUBIT_TRUE;
104 : 705 : diagnosticFlag= CUBIT_FALSE;
105 : 705 : loggingStream = NULL;
106 : 705 : loggingFile = NULL;
107 : 705 : loggingErrorStream = NULL;
108 : 705 : loggingErrorFile = NULL;
109 : 705 : currentDebugFlag = CUBIT_DEBUG_1;
110 : :
111 : : // Initialize the debugFlag array
112 : : static MessageFlag staticDebugFlag[] =
113 : : {
114 : : MessageFlag( 0, "UNUSED"),
115 : : MessageFlag( 1, "Previously used; available for reuse."),
116 : : MessageFlag( 2, "Whisker weaving information"),
117 : : MessageFlag( 3, "Timing information for 3D Meshing routines."),
118 : : MessageFlag( 4, "Graphics Debugging (DrawingTool)"),
119 : : MessageFlag( 5, "FastQ debugging"),
120 : : MessageFlag( 6, "Submapping graphics debugging"),
121 : : MessageFlag( 7, "Knife progress whisker weaving information"),
122 : : MessageFlag( 8, "Mapping Face debug / Linear Programing debug "),
123 : : MessageFlag( 9, "Paver Debugging"),
124 : : MessageFlag( 10, "WW: removed hex seam flag"),
125 : : MessageFlag( 11, "Nodeset Associativity debugging"),
126 : : MessageFlag( 12, "Fastq activity"),
127 : : MessageFlag( 13, "Mesh entities"),
128 : : MessageFlag( 14, "Previously used; available for reuse."),
129 : : MessageFlag( 15, "Previously used; available for reuse."),
130 : : MessageFlag( 16, "Previously used; available for reuse."),
131 : : MessageFlag( 17, "Use Count debugging"),
132 : : MessageFlag( 18, "Webcut debugging"),
133 : : MessageFlag( 19, "Feature Merge / Unmerge debugging"),
134 : : MessageFlag( 20, "Parallel meshing activity"),
135 : : MessageFlag( 21, "Boundary Layer Tool Debugging"),
136 : : MessageFlag( 22, "ExodusMesh sizing function debugging"),
137 : : MessageFlag( 23, "Draw after joining chords in WW"),
138 : : MessageFlag( 24, "SelfCrossingLoop (and derivatives) debug info"),
139 : : MessageFlag( 25, "Extra invalidity checking in WW"),
140 : : MessageFlag( 26, "Surface Smoothing"),
141 : : MessageFlag( 27, "Primal Construction debugging, see also flag 70"),
142 : : MessageFlag( 28, "Plastering debugging"),
143 : : MessageFlag( 29, "Volume SubMapping"),
144 : : MessageFlag( 30, "Previously used; available for reuse."),
145 : : MessageFlag( 31, "CleanUp debugging"),
146 : : MessageFlag( 32, "Previously used; available for reuse."),
147 : : MessageFlag( 33, "Whisker Weaving inside chord list face drawing"),
148 : : MessageFlag( 34, "If on Whisker Weaving doesn't merge sheets"),
149 : : MessageFlag( 35, "If on WW query displays sheets before joining chords"),
150 : : MessageFlag( 36, "Enable/Disable idr_keyword_debugger function"),
151 : : MessageFlag( 37, "Previously used; available for reuse."),
152 : : MessageFlag( 38, "WW hex formation messages"),
153 : : MessageFlag( 39, "Doublet Pillower graphics output"),
154 : : MessageFlag( 40, "Previously used; available for reuse."),
155 : : MessageFlag( 41, "Previously used; available for reuse."),
156 : : MessageFlag( 42, "Auto vertex type and sweep verification"),
157 : : MessageFlag( 43, "Programmer Errors for SubMapping"),
158 : : MessageFlag( 44, "Submapping Graphics Debugging"),
159 : : MessageFlag( 45, "Pillow Sheet debugging"),
160 : : MessageFlag( 46, "Paver breakout detection (expensive)"),
161 : : MessageFlag( 47, "Extra LP debugging (see flag 8 also)"),
162 : : MessageFlag( 48, "Previously used; available for reuse."),
163 : : MessageFlag( 49, "Draws Face by Face Creation in Paving"),
164 : : MessageFlag( 50, "Debugging for AutoSchemeSelect"),
165 : : MessageFlag( 51, "Previously used; available for reuse."),
166 : : MessageFlag( 52, "User Interface: If flag is enabled, filenames being\n"
167 : : "\t\t\t\tused for input will be echoed and each input\n"
168 : : "\t\t\t\tline will be echoed prior to being parsed."),
169 : : MessageFlag( 53, "Surface Morpher debugging"),
170 : : MessageFlag( 54, "Parser debugging"),
171 : : MessageFlag( 55, "Previously used; available for reuse."),
172 : : MessageFlag( 56, "Previously used; available for reuse."),
173 : : MessageFlag( 57, "Relative Interval/Length setting"),
174 : : MessageFlag( 58, "StcVertex debugging of Whisker Weaving"),
175 : : MessageFlag( 59, "Previously used; available for reuse."),
176 : : MessageFlag( 60, "StcVertex debugging of Looping"),
177 : : MessageFlag( 61, "List number of points used in curve faceting"),
178 : : MessageFlag( 62, "Print verbose information on group operations"),
179 : : MessageFlag( 63, "Label Whisker Weaving diagrams tersely"),
180 : : MessageFlag( 64, "No label on Whisker Weaving diagrams"),
181 : : MessageFlag( 65, "Volume Morpher debugging"),
182 : : MessageFlag( 66, "Print debug information on importing Pro/E geometry"),
183 : : MessageFlag( 67, "List number of triangles used in surface faceting"),
184 : : MessageFlag( 68, "Previously used; available for reuse."),
185 : : MessageFlag( 69, "Previously used; available for reuse."),
186 : : MessageFlag( 70, "STC Pillowing, see also flag 27"),
187 : : MessageFlag( 71, "Previously used; available for reuse."),
188 : : MessageFlag( 72, "DoubletPillower text messages"),
189 : : MessageFlag( 73, "Auto Surface debugging (use new auto surf select)"),
190 : : MessageFlag( 74, "Feature-based decomposition info"),
191 : : MessageFlag( 75, "Many-to-many sweep imprint debugging"),
192 : : MessageFlag( 76, "Virtual point and partition curve"),
193 : : MessageFlag( 77, "Volume interval matching"),
194 : : MessageFlag( 78, "Tipton Smoother jacobian modification enabler"),
195 : : MessageFlag( 79, "Previously used; available for reuse."),
196 : : MessageFlag( 80, "Previously used; available for reuse."),
197 : : MessageFlag( 81, "Curve Morpher Debugging"),
198 : : MessageFlag( 82, "Previously used; available for reuse."),
199 : : MessageFlag( 83, "Previously used; available for reuse."),
200 : : MessageFlag( 84, "Surface auto decomposition"),
201 : : MessageFlag( 85, "U-SubMapping debugging"),
202 : : MessageFlag( 86, "Virtual curve and partition surface"),
203 : : MessageFlag( 87, "Composite curve and composite surface"),
204 : : MessageFlag( 88, "Volume partitioning"),
205 : : MessageFlag( 89, "Previously used; available for reuse."),
206 : : MessageFlag( 90, "Geometry attributes"),
207 : : MessageFlag( 91, "Smoothing Debug Output"),
208 : : MessageFlag( 92, "Print name changed warnings"),
209 : : MessageFlag( 93, "Hex Fix Up"),
210 : : MessageFlag( 94, "Entity name attribute"),
211 : : MessageFlag( 95, "Group imprint errors"),
212 : : MessageFlag( 96, "GraftTool debugging"),
213 : : MessageFlag( 97, "Previously used; available for reuse."),
214 : : MessageFlag( 98, "Color code imported THEX meshes"),
215 : : MessageFlag( 99, "Geometry creation"),
216 : : MessageFlag(100, "Skew Control debugging"),
217 : : MessageFlag(101, "Previously used; available for reuse."),
218 : : MessageFlag(102, "CAEntityId debugging"),
219 : : MessageFlag(103, "Print compact interval assignment constraints"),
220 : : MessageFlag(104, "Report interval matching progress"),
221 : : MessageFlag(105, "Previously used; available for reuse."),
222 : : MessageFlag(106, "Mesh Cleaver debugging"),
223 : : MessageFlag(107, "Midpoint_subdivision debugging"),
224 : : MessageFlag(108, "Simulog tetmesher debugging"),
225 : : MessageFlag(109, "Transition schemes debugging"),
226 : : MessageFlag(110, "Mesh Defined Geometry"),
227 : : MessageFlag(111, "TriAdvance mesher debugging"),
228 : : MessageFlag(112, "Auto Detail Suppression"),
229 : : MessageFlag(113, "Previously used; available for reuse."),
230 : : MessageFlag(114, "Blend Finder Debugging"),
231 : : MessageFlag(115, "Exporting Feature Debugging Files"),
232 : : MessageFlag(116, "Sizing function tool data information"),
233 : : MessageFlag(117, "Extra Information on Autoscheme Decision Making"),
234 : : MessageFlag(118, "Blend finding optimization file"),
235 : : MessageFlag(119, "Laminate Tool debugging"),
236 : : MessageFlag(120, "Print unassociated node locations on import mesh"),
237 : : MessageFlag(121, "Print verbose infeasible match interval messages"),
238 : : MessageFlag(122, "Mesh-Based Geometry Debug Information"),
239 : : MessageFlag(123, "Collect memory statistics from Tetmesher"),
240 : : MessageFlag(124, "Print verbose Tetmesher debugging information"),
241 : : MessageFlag(125, "Mesh refinement debugging"),
242 : : MessageFlag(126, "Previously used; available for reuse."),
243 : : MessageFlag(127, "SculptingTool debug flag"),
244 : : MessageFlag(128, "Previously used; available for reuse."),
245 : : MessageFlag(129, "Virtual Imprint Debugging"),
246 : : MessageFlag(130, "Hexsheet Insertion Debugging"),
247 : : MessageFlag(131, "Mesh Cutting Debugging"),
248 : : MessageFlag(132, "Global Collection Smoothing"),
249 : : MessageFlag(133, "Print verbose import mesh progress"),
250 : : MessageFlag(134, "Previously used; available for reuse."),
251 : : MessageFlag(135, "Keep WhiskerWeave data after meshing"),
252 : : MessageFlag(136, "Previously used; available for reuse."),
253 : : MessageFlag(137, "GJoin"),
254 : : MessageFlag(138, "Parallel CGM timing"),
255 : : MessageFlag(139, "RTree Debugging"),
256 : : MessageFlag(140, "Previously used; available for reuse."),
257 : : MessageFlag(141, "Settings save/restore"),
258 : : MessageFlag(142, "Decompose Sweep Debugging"),
259 : : MessageFlag(143, "Decomp Sweep Imprint Debugging"),
260 : : MessageFlag(144, "Medial Axis/Chordal Axis Debugging"),
261 : : MessageFlag(145, "Virtual Geometry Facet Operations"),
262 : : MessageFlag(146, "Sector Tool Meshing Scheme"),
263 : : MessageFlag(147, "Previously used; available for reuse."),
264 : : MessageFlag(148, "Meshing Benchmarks"),
265 : : MessageFlag(149, "MeshCutting Graphical debugging"),
266 : : MessageFlag(150, "MBG to Acis conversion debugging"),
267 : : MessageFlag(151, "Previously used; available for reuse."),
268 : : MessageFlag(152, "Boundary Conditions Debugging"),
269 : : MessageFlag(153, "Print Body information in Geometry operations"),
270 : : MessageFlag(154, "Split Surface Debugging"),
271 : : MessageFlag(155, "Meshing Benchmarks Summary"),
272 : : MessageFlag(156, "CAMAL Paver CleanUp debuging"),
273 : : MessageFlag(157, "Skeleton Sizing Function timing and counts"),
274 : : MessageFlag(158, "Previously used; available for reuse."),
275 : : MessageFlag(159, "Previously used; available for reuse."),
276 : : MessageFlag(160, "Previously used; available for reuse."),
277 : : MessageFlag(161, "Previously used; available for reuse."),
278 : : MessageFlag(162, "Previously used; available for reuse."),
279 : : MessageFlag(163, "Previously used; available for reuse."),
280 : : MessageFlag(164, "Previously used; available for reuse."),
281 : : MessageFlag(165, "Previously used; available for reuse."),
282 : : MessageFlag(166, "Unconstrained Paving debugging"),
283 : : MessageFlag(167, "Skeleton Sizing Function Debugging (messages)"),
284 : : MessageFlag(168, "Tweak Target Multiple Debugging "),
285 : : MessageFlag(169, "Enable Knupp affine transformation instead of Roca"),
286 : : MessageFlag(170, "Previously used; available for reuse."),
287 : : MessageFlag(171, "Previously used; available for reuse."),
288 : : MessageFlag(172, "Previously used; available for reuse."),
289 : : MessageFlag(173, "Previously used; available for reuse."),
290 : : MessageFlag(174, "Previously used; available for reuse."),
291 : : MessageFlag(175, "Previously used; available for reuse."),
292 : : MessageFlag(176, "Enable UCP database checking"),
293 : : MessageFlag(177, "Enable Unconstrained Plastering Debug Drawing"),
294 : : MessageFlag(178, "Enable Harris instead of Parrish hex refinement"),
295 : : MessageFlag(179, "Enable Camal Sweeper for UCP Front Advancements.\n"
296 : : "\t\t\t\tIgnored if debug 189 is on"),
297 : : MessageFlag(180, "DecompAide (decomposition helper) debugging"),
298 : : MessageFlag(181, "MBG. Draw curve paths."),
299 : : MessageFlag(182, "UCP Detailed Debug Printing."),
300 : : MessageFlag(183, "Previously used; available for reuse."),
301 : : MessageFlag(184, "Enable old sheet refinement command."),
302 : : MessageFlag(185, "Enable straddle elements on hardlines."),
303 : : MessageFlag(186, "Disable parametric coordinates in TriAdvMesher"),
304 : : MessageFlag(187, "Previously used; available for reuse."),
305 : : MessageFlag(188, "Tolerant Triangle Meshing"),
306 : : MessageFlag(189, "Previously used; available for reuse."),
307 : : MessageFlag(190, "Count CAMAL calls to move_to and normal_at"),
308 : : MessageFlag(191, "Auto clean messages"),
309 : : MessageFlag(192, "Previously used; available for reuse."),
310 : : MessageFlag(193, "Tetmesh with stand-alone INRIA execuable thru files"),
311 : : MessageFlag(194, "Hex Mesh Matching Debug drawing"),
312 : : MessageFlag(195, "Previously used; available for reuse."),
313 : : MessageFlag(196, "Previously used; available for reuse."),
314 : : MessageFlag(197, "CAMAL Paver debugging (no Cubit smoothing, etc.)"),
315 : : MessageFlag(198, "Auto Midsurface debugging"),
316 : : MessageFlag(199, "Angle smoothing debugging"),
317 : : MessageFlag(200, "Paver quality data output"),
318 : : MessageFlag(201, "Paver cleanup edge metrics"),
319 : : MessageFlag(202, "Disable Paver cleanup 3-3 replace"),
320 : : MessageFlag(203, "Disable Paver cleanup 3-offset-3/5 replace"),
321 : : MessageFlag(204, "Enable Paver cleanup 3-valent quad cluster"),
322 : : MessageFlag(205, "Enable Paver cleanup partial chord collapse"),
323 : : MessageFlag(206, "Hex Mesh Matching, match chords one at a time."),
324 : : MessageFlag(207, "Defeature and Geometry tolerant meshing"),
325 : : MessageFlag(208, "Previously used; available for reuse."),
326 : : MessageFlag(209, "Change sense of partial/full tet remesh (v = !v)"),
327 : : MessageFlag(210, "Use tetgen tetmesher via files"),
328 : : MessageFlag(211, "Use tetgen tetmesher via direct interface"),
329 : : MessageFlag(212, "Create debugging groups when doing geometry/meshing association for parallel refinement"),
330 : : MessageFlag(213, "Previously used; available for reuse."),
331 : : MessageFlag(214, "Boundary Layers"),
332 : : MessageFlag(215, "Command Parser"),
333 : : MessageFlag(216, "Command Parser Detailed"),
334 : : MessageFlag(217, "Graphics debugging for unite dissimilar mesh command"),
335 : : MessageFlag(218, "Previously used; available for reuse."),
336 : : MessageFlag(219, "Materials Interface"),
337 : : MessageFlag(220, "Previously used; available for reuse."),
338 : : MessageFlag(221, "Turn ON Boundary Layer Correction in New Sweeper; ignored if target evaluator is NULL."),
339 : : MessageFlag(222, "Turn ON Scale Mesh option to maximize percentage of model which gets scaled."),
340 : : MessageFlag(223, "Turn ON Scale Mesh Debug Drawing."),
341 : : MessageFlag(224, "Turn ON Scale Mesh Extended Debug Drawing."),
342 : : MessageFlag(225, "unassigned")
343 : :
344 : : // IMPORTANT!!!
345 : : // If you add a new debug flag, make sure that you change
346 : : // the result of CubitMessage::number_of_debug_flags().
347 : : // In order to use this type of static initialization,
348 : : // we can't use the sizeof operator, so change it manually.
349 [ + - ][ + - ]: 161445 : };
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ # # # # ]
[ + + ]
350 : 705 : debugFlag = staticDebugFlag;
351 : :
352 : : // Check initialization of debugFlag array.
353 [ + + ]: 158625 : for (int i=number_of_debug_flags(); i > 0; i--)
354 : : {
355 : 157920 : debugFlag[i].setting = CUBIT_FALSE;
356 [ - + ]: 157920 : assert(i == debugFlag[i].flagNumber);
357 [ - + ]: 157920 : assert(debugFlag[i].description != NULL);
358 : : }
359 [ # # ]: 705 : }
360 : :
361 : 0 : CubitMessage::~CubitMessage()
362 : : {
363 : : // Close all streams associated with debug flags.
364 : : // If the same stream is being used for debug and logging, it
365 : : // will get closed below.
366 [ # # ]: 0 : for (int i=number_of_debug_flags(); i > 0; i--)
367 : 0 : remove_debug_stream(i);
368 : :
369 : : // At this time, the only open streams possible are loggingStream and loggingErrorStream.
370 [ # # ]: 0 : if (loggingStream != NULL)
371 : : {
372 : 0 : loggingStream->close();
373 [ # # ]: 0 : delete loggingStream;
374 [ # # ]: 0 : delete loggingFile;
375 : : }
376 [ # # ]: 0 : if (loggingErrorStream != NULL)
377 : : {
378 : 0 : loggingErrorStream->close();
379 [ # # ]: 0 : delete loggingErrorStream;
380 [ # # ]: 0 : delete loggingErrorFile;
381 : : }
382 : :
383 : : // Set static instance_ to zero to indicated that we are dead.
384 : 0 : instance_ = 0;
385 [ # # ]: 0 : }
386 : :
387 : 0 : void CubitMessage::delete_instance()
388 : : {
389 [ # # ]: 0 : delete instance_;
390 : 0 : instance_ = NULL;
391 : 0 : }
392 : :
393 : 705 : int CubitMessage::number_of_debug_flags()
394 : : {
395 : 705 : return NUM_DEBUG_FLAGS;
396 : : // return sizeof(debugFlag)/sizeof(debugFlag[0])-1;
397 : : }
398 : :
399 : 8242 : void CubitMessage::internal_error ( const int message_type,
400 : : std::ofstream *output_stream,
401 : : const CubitString& msgbuf)
402 : : {
403 : 8242 : int print_it = CUBIT_FALSE;
404 : :
405 [ + - ]: 8242 : CubitString prefix;
406 : :
407 [ + - + + : 8242 : switch (message_type)
- - ]
408 : : {
409 : : case CUBIT_ERROR:
410 [ + - ]: 561 : if (errorFlag)
411 : : {
412 : 561 : print_it = CUBIT_TRUE;
413 [ + - ][ + - ]: 561 : prefix = "ERROR: ";
[ + - ]
414 : : }
415 : 561 : break;
416 : : case CUBIT_ERROR_EXPECTED:
417 [ # # ]: 0 : if (errorFlag)
418 : : {
419 : 0 : print_it = CUBIT_TRUE;
420 [ # # ][ # # ]: 0 : prefix = "ERROR_EXPECTED: ";
[ # # ]
421 : : }
422 : 0 : break;
423 : : case CUBIT_WARNING:
424 [ + - ]: 66 : if (warningFlag)
425 : : {
426 : 66 : print_it = CUBIT_TRUE;
427 [ + - ][ + - ]: 66 : prefix = "WARNING: ";
[ + - ]
428 : : }
429 : 66 : break;
430 : : case CUBIT_INFO:
431 [ + - ]: 7615 : if (infoFlag)
432 : 7615 : print_it = CUBIT_TRUE;
433 : 7615 : break;
434 : : case CUBIT_DIAGNOSTIC:
435 [ # # ]: 0 : if (diagnosticFlag)
436 : : {
437 : 0 : print_it = CUBIT_TRUE;
438 [ # # ][ # # ]: 0 : prefix = "DIAGNOSTIC: ";
[ # # ]
439 : : }
440 : 0 : break;
441 : : default:
442 [ # # ][ # # ]: 0 : if (message_type >= CUBIT_DEBUG_1 && message_type <= number_of_debug_flags()+10)
[ # # ][ # # ]
443 : : {
444 [ # # ]: 0 : if (debugFlag[message_type-10].setting) print_it = CUBIT_TRUE;
445 : 0 : break;
446 : : }
447 : : }
448 : :
449 [ + - ]: 8242 : if (print_it)
450 : : {
451 : : // loggingStream is used to journal error, warning, and info messages.
452 : : // debug messages can also be journalled there by setting the
453 : : // output stream for the debug flag to the same file.
454 [ - + ][ # # ]: 8242 : if (loggingStream != NULL && (message_type == CUBIT_ERROR ||
[ # # ]
455 [ # # ]: 0 : message_type == CUBIT_WARNING ||
456 : : message_type == CUBIT_INFO))
457 : : {
458 [ # # ][ # # ]: 0 : *loggingStream << prefix.c_str() << msgbuf.c_str();
[ # # ][ # # ]
459 [ # # ]: 0 : loggingStream->flush();
460 : : }
461 : : //loggingErrorStream is used to (if the user has requested it)
462 : : // log only ERROR: messages
463 [ - + ][ # # ]: 8242 : if (loggingErrorStream != NULL && message_type == CUBIT_ERROR)
464 : : {
465 [ # # ][ # # ]: 0 : *loggingErrorStream << prefix.c_str() << msgbuf.c_str();
[ # # ][ # # ]
466 [ # # ]: 0 : loggingErrorStream->flush();
467 : : }
468 : :
469 [ + - ]: 8242 : if (output_stream == NULL)
470 : : {
471 [ + + ]: 8242 : if(message_type == CUBIT_ERROR)
472 : : {
473 [ + - ]: 561 : CubitString ctx;
474 [ - + ]: 561 : if(CubitMessage::mErrorHandler)
475 : : {
476 [ # # ][ # # ]: 0 : ctx = CubitMessage::mErrorHandler->error_context().c_str();
[ # # ][ # # ]
[ # # ][ # # ]
477 : : }
478 [ + - ][ + - ]: 1122 : CubitString msg = prefix + ctx + msgbuf;
[ + - ][ + - ]
479 [ + - ][ + - ]: 1122 : CubitMessage::mHandler->print_error(msg.c_str());
[ + - ]
480 : : }
481 : : else
482 : : {
483 [ + - ]: 7681 : CubitString msg = prefix + msgbuf;
484 [ + - ][ + - ]: 8242 : CubitMessage::mHandler->print_message(msg.c_str());
[ + - ]
485 : : }
486 : : }
487 : : else
488 : : {
489 [ # # ][ # # ]: 0 : *output_stream << prefix.c_str() << msgbuf.c_str();
[ # # ][ # # ]
490 [ # # ]: 8242 : output_stream->flush();
491 : : }
492 [ + - ]: 8242 : }
493 : 8242 : }
494 : :
495 : 561 : int CubitMessage::print_error ( const CubitString& str )
496 : : {
497 : 561 : int error_type = CUBIT_ERROR;
498 [ - + ][ # # ]: 561 : if(expectedStartErrorCount != -1 && expectedEndErrorCount > expectedStartErrorCount)
499 : : {
500 : 0 : error_type = CUBIT_ERROR_EXPECTED;
501 : : }
502 : : else
503 : : {
504 : 561 : add_to_error_count();
505 : : }
506 : :
507 [ - + ]: 561 : if(expectedStartErrorCount != -1)
508 : : {
509 : 0 : expectedStartErrorCount++;
510 : : }
511 : :
512 [ + + ][ + - ]: 561 : static char* cubit_ctest = getenv("CUBIT_CTEST");
513 [ - + ][ # # ]: 561 : if(cubit_ctest && error_type == CUBIT_ERROR)
514 : : {
515 [ # # ]: 0 : internal_error(CUBIT_INFO, NULL, "<DartMeasurement name=\"Error\" type=\"text/plain\">\n");
516 : 0 : internal_error(error_type, NULL, str);
517 [ # # ]: 0 : internal_error(CUBIT_INFO, NULL, "</DartMeasurement>\n");
518 : : }
519 : :
520 : 561 : internal_error(error_type, NULL, str);
521 : :
522 : 561 : return CUBIT_FAILURE;
523 : : }
524 : :
525 : 66 : int CubitMessage::print_warning ( const CubitString& str )
526 : : {
527 : 66 : internal_error(CUBIT_WARNING, NULL, str);
528 : 66 : add_to_warning_count();
529 : 66 : return CUBIT_FAILURE;
530 : : }
531 : :
532 : 7615 : int CubitMessage::print_info ( const CubitString& str )
533 : : {
534 : 7615 : internal_error(CUBIT_INFO, NULL, str);
535 : 7615 : return CUBIT_FAILURE;
536 : : }
537 : :
538 : 618656 : int CubitMessage::is_debug_flag_set( int flag )
539 : : {
540 [ - + ]: 618656 : if( DEBUG_FLAG( flag ))
541 : : {
542 : 0 : currentDebugFlag = flag;
543 : 0 : return CUBIT_TRUE;
544 : : }
545 : 618656 : return CUBIT_FALSE;
546 : : }
547 : :
548 : 0 : int CubitMessage::print_debug( const CubitString& str )
549 : : {
550 : : internal_error(currentDebugFlag+10,
551 : 0 : debugFlag[currentDebugFlag].outputStream,
552 : 0 : str);
553 : 0 : return CUBIT_FAILURE;
554 : : }
555 : :
556 : 0 : void CubitMessage::print_diagnostic ( const CubitString& str )
557 : : {
558 : 0 : internal_error(CUBIT_DIAGNOSTIC, NULL, str);
559 : 0 : }
560 : :
561 : 0 : int CubitMessage::reset_error_count(int value)
562 : : {
563 : 0 : int current_value = errorCount;
564 [ # # ]: 0 : if (errorCount != value) {
565 : 0 : errorCount = value;
566 [ # # ]: 0 : PRINT_WARNING("Error count manually changed from %d to %d\n\n",
567 [ # # ]: 0 : current_value, value);
568 : : }
569 : 0 : return current_value;
570 : : }
571 : :
572 : 143 : int CubitMessage::error_count()
573 : : {
574 : 143 : return errorCount;
575 : : }
576 : :
577 : 561 : void CubitMessage::add_to_error_count()
578 : : {
579 : 561 : errorCount++;
580 : 561 : }
581 : :
582 : 0 : int CubitMessage::reset_warning_count(int value)
583 : : {
584 : 0 : int current_value = warningCount;
585 [ # # ]: 0 : if (warningCount != value) {
586 : 0 : warningCount = value;
587 [ # # ]: 0 : PRINT_INFO("Warning count manually changed from %d to %d\n\n",
588 [ # # ]: 0 : current_value, value);
589 : : }
590 : 0 : return current_value;
591 : : }
592 : :
593 : 0 : int CubitMessage::warning_count()
594 : : {
595 : 0 : return warningCount;
596 : : }
597 : :
598 : 66 : void CubitMessage::add_to_warning_count()
599 : : {
600 : 66 : warningCount++;
601 : 66 : }
602 : :
603 : 0 : void CubitMessage::output_debug_information(int from, int to, int step)
604 : : {
605 [ # # ]: 0 : if (to == -1)
606 : 0 : to = number_of_debug_flags();
607 : :
608 [ # # ]: 0 : PRINT_INFO("Debug Flag Settings "
609 [ # # ]: 0 : "(flag number, setting, output to, description):\n");
610 [ # # ]: 0 : for (int i=from; i <= to; i+=step) {
611 : 0 : debugFlag[i].output();
612 : : }
613 [ # # ][ # # ]: 0 : PRINT_INFO("\n");
614 : 0 : }
615 : :
616 : 0 : void CubitMessage::output_debug_information(CubitString &match)
617 : : {
618 : 0 : int count = 0;
619 [ # # ]: 0 : for (int i=1; i <= number_of_debug_flags(); i++) {
620 : 0 : char *tmp = CubitUtil::util_strdup((char*)(debugFlag[i].description));
621 [ # # ][ # # ]: 0 : if (tmp && strlen(tmp) > 0) {
622 [ # # ]: 0 : CubitString debug_description(tmp);
623 [ # # ]: 0 : debug_description.to_lower();
624 [ # # ][ # # ]: 0 : if (debug_description.find(match, 0) < debug_description.length()) {
[ # # ]
625 [ # # ]: 0 : if (count == 0) {
626 [ # # ][ # # ]: 0 : PRINT_INFO("Debug Flag Settings "
[ # # ]
627 [ # # ]: 0 : "(flag number, setting, output to, description):\n");
628 : : }
629 [ # # ]: 0 : debugFlag[i].output();
630 : 0 : count++;
631 [ # # ]: 0 : }
632 : : }
633 : 0 : CubitUtil::util_strdup_free(tmp);
634 : : }
635 [ # # ]: 0 : if (count == 0) {
636 [ # # ]: 0 : PRINT_WARNING("No debug descriptions contain the "
637 [ # # ]: 0 : "substring '%s'\n", match.c_str());
638 : : }
639 [ # # ][ # # ]: 0 : PRINT_INFO("\n");
640 : 0 : }
641 : :
642 : 0 : void CubitMessage::output_logging_information()
643 : : {
644 [ # # ]: 0 : if (loggingStream != NULL)
645 [ # # ][ # # ]: 0 : PRINT_INFO("logging = On, log file = '%s'\n", loggingFile->c_str());
646 : : else
647 [ # # ][ # # ]: 0 : PRINT_INFO("logging = Off\n");
648 [ # # ]: 0 : if (loggingErrorStream != NULL)
649 [ # # ][ # # ]: 0 : PRINT_INFO("logging Errors = On, log file = '%s'\n",loggingErrorFile->c_str());
650 : :
651 : 0 : }
652 : :
653 : 0 : void MessageFlag::output()
654 : : {
655 : : CubitMessage::instance()->
656 : : print_info(
657 : : CubitString::format("%2d %3s %-16s %s\n",
658 : 0 : flagNumber, (setting == 1 ? "ON " : "OFF"),
659 : 0 : (filename == NULL ? "terminal" : filename->c_str()),
660 : : description)
661 [ # # ][ # # ]: 0 : );
[ # # ][ # # ]
662 : 0 : }
663 : :
664 : 0 : int CubitMessage::find_file_use(const CubitString &filename)
665 : : {
666 [ # # ][ # # ]: 0 : if (filename == "terminal") {
667 : : // remove_debug_stream has set the outputStream and filename to NULL.
668 : 0 : return -1;
669 : : }
670 : :
671 : : // See if any of the other debug flags have this file open
672 [ # # ]: 0 : for (int i=number_of_debug_flags(); i > 0; i--) {
673 [ # # ][ # # ]: 0 : if (debugFlag[i].filename && *(debugFlag[i].filename) == filename) {
[ # # ]
674 : 0 : return i;
675 : : }
676 : : }
677 [ # # ][ # # ]: 0 : if (loggingFile && *(loggingFile) == filename)
[ # # ]
678 : 0 : return -2;
679 : :
680 [ # # ][ # # ]: 0 : if (loggingErrorFile && *(loggingErrorFile) == filename)
[ # # ]
681 : 0 : return -3;
682 : :
683 : 0 : return 0;
684 : : }
685 : :
686 : 0 : int CubitMessage::count_stream_users(const std::ofstream *stream)
687 : : {
688 : 0 : int match = 0;
689 [ # # ]: 0 : if (stream != NULL)
690 : : {
691 [ # # ]: 0 : for (int i=number_of_debug_flags(); i > 0; i--)
692 : : {
693 [ # # ]: 0 : if (debugFlag[i].outputStream == stream)
694 : : {
695 : 0 : match++;
696 : : }
697 : : }
698 : :
699 [ # # ]: 0 : if (loggingStream == stream)
700 : 0 : match++;
701 [ # # ]: 0 : if (loggingErrorStream == stream)
702 : 0 : match++;
703 : : }
704 : 0 : return match;
705 : : }
706 : :
707 : 0 : void CubitMessage::set_logging_file_setting(const CubitString &filename, CubitBoolean resume_flag)
708 : : {
709 : : // If logging is currently outputting to a file, close it if
710 : : // it is the only thing using that file. (and the filenames don't match)
711 [ # # ][ # # ]: 0 : if (loggingFile && *loggingFile == filename)
[ # # ]
712 : 0 : return;
713 : :
714 [ # # ][ # # ]: 0 : if (loggingErrorFile && *loggingErrorFile == filename)
[ # # ]
715 : : {
716 [ # # ][ # # ]: 0 : PRINT_ERROR("Can't set the logging file to be the same as the Error logging file.\n");
717 : 0 : return;
718 : : }
719 : :
720 : 0 : int users = count_stream_users(loggingStream);
721 [ # # ]: 0 : if (users == 1) { // Just us...
722 : 0 : loggingStream->close();
723 [ # # ]: 0 : delete loggingStream;
724 : 0 : loggingStream = NULL;
725 [ # # ]: 0 : delete loggingFile;
726 : 0 : loggingFile = NULL;
727 : : }
728 : :
729 : 0 : int match = find_file_use(filename);
730 : :
731 [ # # ]: 0 : if (match == -1) // Filename is 'terminal'
732 : 0 : return;
733 [ # # ]: 0 : else if (match != 0)
734 : : {
735 : 0 : loggingFile = debugFlag[match].filename;
736 : 0 : loggingStream = debugFlag[match].outputStream;
737 : : }
738 : : else
739 : : {
740 [ # # ]: 0 : loggingFile = new CubitString(filename);
741 [ # # ]: 0 : if(resume_flag)
742 [ # # ][ # # ]: 0 : loggingStream = new std::ofstream(CubitString::toNative(filename).c_str(), std::ios::out | std::ios::app);
[ # # ][ # # ]
743 : : else
744 [ # # ][ # # ]: 0 : loggingStream = new std::ofstream(CubitString::toNative(filename).c_str());
[ # # ][ # # ]
745 : : }
746 : : }
747 : :
748 : 0 : void CubitMessage::set_debug_file_setting(const int index, const CubitString &filename)
749 : : {
750 : : // If this flag is currently outputting to a file, close it if
751 : : // this is the only flag using that file.
752 : 0 : remove_debug_stream(index);
753 : :
754 : 0 : int match = find_file_use(filename);
755 : :
756 [ # # ]: 0 : if (match == -1) // Filename is 'terminal'
757 : 0 : return;
758 [ # # ][ # # ]: 0 : if (match == -2 || match == -3) {// Filename is same as loggingFile or loggingErrorFile;
759 : 0 : debugFlag[index].filename = loggingFile;
760 : 0 : debugFlag[index].outputStream = loggingStream;
761 : : }
762 [ # # ]: 0 : else if (match == index)
763 : 0 : return;
764 [ # # ]: 0 : else if (match != 0) {
765 : 0 : debugFlag[index].filename = debugFlag[match].filename;
766 : 0 : debugFlag[index].outputStream = debugFlag[match].outputStream;
767 : : }
768 : : else {
769 [ # # ]: 0 : debugFlag[index].filename = new CubitString(filename);
770 [ # # ][ # # ]: 0 : debugFlag[index].outputStream = new std::ofstream(CubitString::toNative(filename).c_str());
[ # # ][ # # ]
771 : : }
772 : : }
773 : :
774 : 0 : void CubitMessage::remove_debug_stream(const int index)
775 : : {
776 : : // NOTE: DO NOT USE PRINT_* CALLS, THIS IS CALLED FROM DESTRUCTOR.
777 : :
778 : : // Multiple debug flags may be using the same output stream,
779 : : // Go through the list and count who is using this stream,
780 : : // If only one use, close and delete the stream.
781 [ # # ]: 0 : if (debugFlag[index].outputStream == NULL)
782 : 0 : return;
783 : :
784 : 0 : int match = count_stream_users(debugFlag[index].outputStream);
785 : :
786 [ # # ]: 0 : if (match == 1) {
787 : 0 : debugFlag[index].outputStream->close();
788 [ # # ]: 0 : delete debugFlag[index].outputStream;
789 [ # # ]: 0 : delete debugFlag[index].filename;
790 : : }
791 : 0 : debugFlag[index].filename = NULL;
792 : 0 : debugFlag[index].outputStream = NULL;
793 : : }
794 : :
795 : 0 : void CubitMessage::set_message_handler(CubitMessageHandler *handler)
796 : : {
797 : 0 : CubitMessage::mHandler = handler;
798 [ # # ]: 0 : if(CubitMessage::mHandler == NULL)
799 : 0 : CubitMessage::mHandler = &mDefaultHandler;
800 : 0 : }
801 : :
802 : 0 : CubitMessageHandler* CubitMessage::get_message_handler()
803 : : {
804 : 0 : return CubitMessage::mHandler;
805 : : }
806 : :
807 : 0 : void CubitMessage::set_error_handler(CubitMessageErrorHandler *handler)
808 : : {
809 : 0 : CubitMessage::mErrorHandler = handler;
810 : 0 : }
811 : :
812 : 0 : CubitMessageErrorHandler* CubitMessage::get_error_handler()
813 : : {
814 : 0 : return CubitMessage::mErrorHandler;
815 : : }
816 : :
817 : 159330 : MessageFlag::MessageFlag(int flag_number, const char *desc)
818 : : : flagNumber(flag_number), setting(CUBIT_FALSE),
819 : 159330 : description(desc), filename(NULL), outputStream(NULL)
820 : : {
821 : 159330 : }
822 : :
823 : 0 : MessageFlag::MessageFlag()
824 : : {
825 : 0 : flagNumber = 0;
826 : 0 : setting = CUBIT_FALSE;
827 : 0 : description = NULL;
828 : 0 : filename = NULL;
829 : 0 : outputStream = NULL;
830 : 0 : }
831 : :
832 : :
833 : 0 : void CubitMessage::set_logging_file_setting(const char* filename)
834 : : {
835 [ # # ][ # # ]: 0 : if (loggingFile && *loggingFile == filename)
[ # # ][ # # ]
[ # # ]
[ # # # # ]
836 : 0 : return;
837 : :
838 [ # # ]: 0 : if (CubitUtil::compare(filename,"terminal")) { // Filename is 'terminal'
839 [ # # ]: 0 : if (loggingStream != NULL) {
840 : 0 : loggingStream->close();
841 [ # # ]: 0 : delete loggingStream;
842 : 0 : loggingStream = NULL;
843 [ # # ]: 0 : delete loggingFile;
844 : 0 : loggingFile = NULL;
845 : : }
846 : 0 : return;
847 : : }
848 : : else {
849 [ # # ]: 0 : loggingFile = new CubitString(filename);
850 [ # # ][ # # ]: 0 : loggingStream = new std::ofstream(CubitString::toNative(filename).c_str(), std::ios::out | std::ios::app );
[ # # ][ # # ]
851 : : }
852 : : }
853 : :
854 : 0 : void CubitMessage::set_error_logging_file_setting(const char* filename, CubitBoolean resume_flag)
855 : : {
856 [ # # ][ # # ]: 0 : if (loggingErrorFile && *loggingErrorFile == filename)
[ # # ][ # # ]
[ # # ]
[ # # # # ]
857 : 0 : return;
858 : :
859 [ # # ][ # # ]: 0 : if(loggingFile && *loggingFile == filename)
[ # # ][ # # ]
[ # # ]
[ # # # # ]
860 : : {
861 [ # # ][ # # ]: 0 : PRINT_ERROR("Can't explicitly set the Error logging file to be the same as the logging file.\n");
862 : 0 : return;
863 : : }
864 : :
865 [ # # ]: 0 : if (CubitUtil::compare(filename,"terminal")) { // Filename is 'terminal'
866 [ # # ]: 0 : if (loggingErrorStream != NULL) {
867 : 0 : loggingErrorStream->close();
868 [ # # ]: 0 : delete loggingErrorStream;
869 : 0 : loggingErrorStream = NULL;
870 [ # # ]: 0 : delete loggingErrorFile;
871 : 0 : loggingErrorFile = NULL;
872 : : }
873 : 0 : return;
874 : : }
875 : : else {
876 [ # # ]: 0 : loggingErrorFile = new CubitString(filename);
877 [ # # ]: 0 : if(resume_flag)
878 [ # # ][ # # ]: 0 : loggingErrorStream = new std::ofstream(CubitString::toNative(filename).c_str(), std::ios::out | std::ios::app );
[ # # ][ # # ]
879 : : else
880 [ # # ][ # # ]: 0 : loggingErrorStream = new std::ofstream(CubitString::toNative(filename).c_str());
[ # # ][ # # ]
881 : : }
882 : : }
883 : :
884 : : //Initialize all settings in this class
885 : 874 : void CubitMessage::initialize_settings()
886 : : {
887 : :
888 : : SettingHandler::instance()->add_setting("Info",
889 : : CubitMessage::set_info_flag,
890 : 874 : CubitMessage::get_info_flag);
891 : :
892 : : /*SettingHandler::instance()->add_setting("Logging",
893 : : CubitMessage::set_logging_file_setting,
894 : : CubitMessage::get_logging_file_setting);*/
895 : :
896 : : SettingHandler::instance()->add_setting("Diagnostic",
897 : : CubitMessage::set_diagnostic_flag,
898 : 874 : CubitMessage::get_diagnostic_flag);
899 : :
900 : : SettingHandler::instance()->add_setting("Warning",
901 : : CubitMessage::set_warning_flag,
902 : 874 : CubitMessage::get_warning_flag);
903 : 874 : }
904 : :
905 : 0 : CubitString CubitMessage::logging_filename() const
906 : : {
907 : 0 : CubitString temp_string;
908 [ # # ]: 0 : if(loggingStream != NULL)
909 [ # # ][ # # ]: 0 : temp_string = loggingFile->c_str();
[ # # ][ # # ]
910 : :
911 : 0 : return temp_string;
912 : : }
913 : :
914 : 0 : CubitString CubitMessage::logging_errors_filename() const
915 : : {
916 : 0 : CubitString temp_string;
917 [ # # ]: 0 : if(loggingErrorStream != NULL)
918 [ # # ][ # # ]: 0 : temp_string = loggingErrorFile->c_str();
[ # # ][ # # ]
919 : :
920 : 0 : return temp_string;
921 : : }
922 : :
923 : 0 : void CubitMessage::start_expected_error_count(int error_count, bool less_than_accepted)
924 : : {
925 : 0 : this->expectedStartErrorCount = errorCount;
926 : 0 : this->expectedEndErrorCount = errorCount + error_count;
927 : 0 : this->expectedLessErrorCountAccepted = less_than_accepted;
928 : 0 : }
929 : :
930 : 0 : void CubitMessage::stop_expected_error_count(const CubitString &message)
931 : : {
932 : 0 : bool has_error = false;
933 [ # # ][ # # ]: 0 : if((expectedEndErrorCount != expectedStartErrorCount && expectedLessErrorCountAccepted == false) ||
[ # # ]
934 [ # # ]: 0 : (expectedEndErrorCount < expectedStartErrorCount && expectedLessErrorCountAccepted == true))
935 : : {
936 : 0 : has_error = true;
937 : : }
938 : 0 : this->expectedStartErrorCount = -1;
939 : 0 : this->expectedEndErrorCount = -1;
940 [ # # ]: 0 : if(has_error)
941 : : {
942 [ # # ]: 0 : CubitString msg = message;
943 [ # # ][ # # ]: 0 : if(message.length() == 0)
944 : : {
945 [ # # ][ # # ]: 0 : msg = "unexpected errors";
[ # # ]
946 : : }
947 [ # # ][ # # ]: 0 : print_error(msg + "\n");
[ # # ][ # # ]
[ # # ][ # # ]
948 : : }
949 : 0 : }
950 : :
951 : 159330 : MessageFlag::~MessageFlag()
952 : : {
953 : : // It is not safe to delete either the stream or the filename here
954 : : // since multiple instances (debug flags) may refer to the same memory
955 [ + - ][ + - ]: 6540 : }
956 : :
957 : : #ifdef STANDALONE
958 : : void main() {
959 : : CubitMessage::instance()->output_debug_information(1, 10, 2);
960 : : CubitMessage::instance()->output_debug_information(12);
961 : : CubitMessage::instance()->set_debug_file(5, "Debug_Test.file");
962 : : DEBUG_FLAG(5, CUBIT_TRUE);
963 : : PRINT_DEBUG_5("This is a test\n");
964 : : CubitMessage::instance()->output_debug_information(5,5);
965 : : }
966 : : #endif
|