Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Log.C

00001 /* $Id: Log.C,v 1.2 2000/11/03 22:03:28 rpav Exp $
00002  *
00003  * SFW - Studio FrameWork
00004  * Copyright (C) 2000  Ryan Pavlik
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019  *
00020  */
00021 
00022 /*
00023  * Logging class
00024  *
00025  */ 
00026 
00027 #include <iostream>
00028 #include <cstdlib>
00029 #include <cstdio>
00030 #include <stdarg.h>
00031 #include <SFW/Log.H>
00032 
00033 TYPE_INIT(SFW::Logger);
00034 
00035 using namespace SFW;
00036 
00037 Logger SFW::Log;
00038 
00039 Logger::Logger(LOG_LEVEL _level) {
00040     curLevel = _level;
00041 }
00042 
00043 void Logger::operator() (LOG_LEVEL _level, char *_fmt, ...) {
00044     char buf[2048];
00045     va_list _ap;
00046     va_start(_ap, _fmt);
00047 
00048     if(curLevel >= _level) {
00049     vsnprintf(buf, sizeof(buf), _fmt, _ap);
00050     cerr << buf << endl;
00051     }
00052 
00053     va_end(_ap);
00054 }
00055 
00056 void Logger::operator() (char *_fmt, ...) {
00057     char buf[2048];
00058     va_list _ap;
00059     va_start(_ap, _fmt);
00060 
00061     if(curLevel >= L_NORM) {
00062     vsnprintf(buf, sizeof(buf), _fmt, _ap);
00063     cerr << buf << endl;
00064     }
00065 
00066     va_end(_ap);
00067 }
00068 
00069 void Logger::setLevel(LOG_LEVEL _level) {
00070     curLevel = _level;
00071 }

Generated at Tue Jan 2 15:38:34 2001 for SFW by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000