MantisBT - Community
View Issue Details
0022929Community[OCCT] OCCT:Foundation Classespublic2012-01-26 22:362017-07-13 16:20
Roman Lygin 
bugmaster 
normalfeature 
closedfixed 
ALL
[OCCT] 6.5.2 
[OCCT] 7.2.0[OCCT] 6.8.0 
Not needed
0022929: [Coding Rules] Eliminate debug output
OCC should not contaminate output with own debug info. This is especially important for library solutions that are based on OCC. This should become part of the Coding Rules and part of the code review process.

Details:
OCC source code has numerous instances of debug output (e.g. using std::cerr or cout). Most often this is surrounded with #ifdef DEB (which is an OCC-specific macro instead of standard _DEBUG). Example STEPControl_ActorRead.cxx:
#ifdef DEB
cout << "//What is?// NB COMPOUNDS: " << nbCompounds << endl;
...
#endif

Sometimes it is surrounded with specific macros which were probably supposed to be defined in debug mode only but got into release mode as well and always contaminate the output. Example StepFile_Read.cxx:
#define CHRONOMESURE
...
#ifdef CHRONOMESURE
  sout << " ... STEP File Read ... " << endl;
  c.Show();
#endif

Thus, the output is contaminated both for the end-user app and for the libraries which are based on OCC. Normally the library should not output anything. Consider other options for debugging needs for own OCC developers.


Ideas for solutions:
0. Start with just enforcing this rule for any new modifications and prevent worsening the current situation.
1. Consider reuse of existing class(es) encapsulating debug output (e.g. similar to abstract CDM_MessageDriver and its subclasses; Message_* classes)
2. Design settings via API (e.g. trace level, destinations, etc) and environment variables.
3. Study other implementations (e.g. Qt's qDebug(), qWarning(),...)
4. Performance considerations. Avoid impact of this overhead infrastructure, e.g. by creating inlined no-ops in release mode.
Examples:
1. Launch Import/Export sample and see the log.
2. In DRAWEXE use stepread
No tags attached.
duplicate of 0025418closed bugmaster Community Debug output to be limited to OCC development environment 
related to 0024091closed abv Open CASCADE DEB usage in public headers 
Issue History
2012-01-26 22:36Roman LyginNew Issue
2012-01-26 22:36Roman LyginAssigned To => abv
2012-03-13 22:18Roman LyginNote Added: 0019958
2014-10-28 04:23abvRelationship addedduplicate of 0025418
2014-10-28 04:23abvTarget Version => 6.8.0
2014-10-28 04:26abvRelationship addedrelated to 0024091
2014-10-29 06:03abvTarget Version6.8.0 => 7.1.0
2014-10-29 06:06abvNote Added: 0033792
2016-11-03 17:07abvTarget Version7.1.0 => 7.2.0
2017-07-13 15:57mkvTest case number => Not needed
2017-07-13 15:59mkvNote Added: 0068264
2017-07-13 15:59mkvAssigned Toabv => bugmaster
2017-07-13 15:59mkvStatusnew => feedback
2017-07-13 15:59mkvNote Edited: 0068264bug_revision_view_page.php?bugnote_id=68264#r17088
2017-07-13 16:20bugmasterStatusfeedback => closed
2017-07-13 16:20bugmasterResolutionopen => fixed
2017-07-13 16:20bugmasterFixed in Version => 6.8.0

Notes
(0019958)
Roman Lygin   
2012-03-13 22:18   
Supportive community feedback:
http://www.opencascade.org/org/forum/thread_22961/ [^]
(0033792)
abv   
2014-10-29 06:06   
Debug output should be suppressed now due to fixes for #25266 and 0025418. It still remains to elaborate consistent rules for this and add them to docs.
(0068264)
mkv   
2017-07-13 15:59   
Dear BugMaster,
Problem is fixed by #0025266 and 0025418.
Could you please close it.