/*************************************************************************** aon_debug.cpp - my logging class, see header ------------------- begin : copyright : (C) 2003 by Andrew O'Neill,HiRes Grad Student email : oneill@phys.columbia.edu ***************************************************************************/ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "aon_debug.h" #ifndef NDEBUG Debug::Debug() { } Debug::~Debug() { } ostream& Debug::operator() (const DebugLevelType& Level) { if (Level < itsLevel) { // just ignore these messages return nullstream; // a stream with no output, very quick } switch(Level) { case ALL: clog << " : "; break; case MEM: clog << " MEM: "; break; case FUNC: case LFUNC: clog << " FUNC : "; break; case BLANK: break; case TIMING: cout << " TIMING:"; return cout; break; case INFO: case LINFO: case RELEASE: clog << " INFO: "; return clog; break; case PROGRESS: cout << " "; return cout; break; case WARN: clog << "WARN : " << ""; //^G is a beep return clog; break; case ERR: clog << "ERR : " << ""; //^G is a beep return clog; break; default: break; } return clog; } string Debug::printLevel() { switch (itsLevel) { case ALL: return string("ALL"); break; case TIMING: return string("TIMING"); break; case LINFO: return string("LINFO"); break; case LFUNC: return string("LFUNC"); break; case FUNC: return string("FUNC"); break; case MEM: return string("MEM"); break; case BLANK: case INFO: return string("INFO"); break; case PROGRESS: return string("PROGRESS"); break; case RELEASE: return string("RELEASE"); break; case WARN: return string("WARN"); break; case ERR: return string("ERR"); break; default: return string("UNKNOWN!!!!!!"); } } void Debug::setLevel(const DebugLevelType& Level) { itsLevel = Level; clog << " INFO: DebugLevel set to: " << printLevel() << endl; } #endif