LCOV - code coverage report
Current view: top level - flagging/Flagging - SLog.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 14 28 50.0 %
Date: 2024-11-06 17:42:47 Functions: 3 7 42.9 %

          Line data    Source code
       1             : //# SLog.cc: 
       2             : //# Copyright (C) 2007
       3             : //# Associated Universities, Inc. Washington DC, USA.
       4             : //#
       5             : //# This library is free software; you can redistribute it and/or modify it
       6             : //# under the terms of the GNU Library General Public License as published by
       7             : //# the Free Software Foundation; either version 2 of the License, or (at your
       8             : //# option) any later version.
       9             : //#
      10             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      11             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      13             : //# License for more details.
      14             : //#
      15             : //# You should have received a copy of the GNU Library General Public License
      16             : //# along with this library; if not, write to the Free Software Foundation,
      17             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      18             : //#
      19             : //# Correspondence concerning AIPS++ should be addressed as follows:
      20             : //#        Internet email: casa-feedback@nrao.edu.
      21             : //#        Postal address: AIPS++ Project Office
      22             : //#                        National Radio Astronomy Observatory
      23             : //#                        520 Edgemont Road
      24             : //#                        Charlottesville, VA 22903-2475 USA
      25             : //#
      26             : //#
      27             : //#
      28             : //# -------------------------------------------------------------------------
      29             : 
      30             : 
      31             : #include <flagging/Flagging/SLog.h>
      32             :     
      33             : #define LOGLEVEL 3
      34             : //debuglevel{DEBUGGING, DEBUG2, DEBUG1, NORMAL5, ..., WARN, SEVERE}
      35             : //  loglevel{LOG0,      LOG1,   LOG2,   LOG3,    ..., LOG9, LOG10}
      36             : //set LOGLEVEL to 3 to filter out all debug message
      37             :   
      38             : using namespace casacore;
      39             : namespace casa {
      40             : 
      41             : SLog* SLog::instance = 0;
      42             : //uInt SLog::refCount = 0;
      43             : 
      44         686 : SLog* SLog::slog() {
      45         686 :    if (!instance) {
      46           1 :       instance = new SLog();
      47             :    }
      48             :    //refCount++;
      49             :    //cout << "slog::refCount=" << refCount << endl;   
      50         686 :    return instance;
      51             : }
      52             : 
      53           0 : SLog::~SLog() {
      54           0 :    out("destroy logger");
      55             : 
      56             :    //generally speaking, there is no need to destruct
      57             :    //SLog because it has at most 1 real object, others
      58             :    //are just pointers. The real log object will be 
      59             :    //removed when the whole process is done.
      60             :    //cout << "----------------- destroy slog---------" << endl; 
      61             :    //delete instance;
      62             :    //instance = 0;
      63             :    //this destruct never get called anyway
      64             :   
      65           0 : }
      66             :     
      67           1 : SLog::SLog() {
      68           1 :    out("create logger");
      69           1 : }
      70             : 
      71           0 : void SLog::FnEnter(String fnname, String clname) {
      72           0 :    out("---->> Enter", fnname, clname, LogMessage::DEBUG1);
      73           0 : }
      74             :     
      75           0 : void SLog::FnExit(String fnname, String clname) {
      76           0 :    out("<<---- Exit", fnname, clname, LogMessage::DEBUG1);
      77           0 : }
      78             : 
      79           0 : void SLog::FnPass(String fnname, String clname) {
      80           0 :    out("-- Pass --", fnname, clname, LogMessage::DEBUG1);
      81           0 : }
      82             : 
      83         357 : void SLog::out(const String &msg, const String& /*fnname*/,
      84             :                const String& /*clname*/,
      85             :                LogMessage::Priority msglevel,
      86             :                Bool onconsole) {
      87         357 :    if (msglevel >= LOGLEVEL) {
      88         356 :       priority(msglevel);
      89         356 :       output() << (const char *)msg.c_str();
      90         356 :       post();
      91         356 :       if (onconsole) {
      92           0 :          cout << LogMessage::toString(msglevel)
      93             :              // << " from " << clname << "::" << fnname
      94             :              // << " ==>> " 
      95           0 :               << " " << msg << endl;
      96             :       } 
      97             :    }
      98         357 : }
      99             : 
     100             : };
     101             : 

Generated by: LCOV version 1.16