00001 // Stream based logging mechanism. 00002 // 00003 // Written by Bernie Bright, 1998 00004 // 00005 // Copyright (C) 1998 Bernie Bright - bbright@c031.aone.net.au 00006 // 00007 // This library is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU Library General Public 00009 // License as published by the Free Software Foundation; either 00010 // version 2 of the License, or (at your option) any later version. 00011 // 00012 // This library is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 // Library General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with this program; if not, write to the Free Software 00019 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00020 // 00021 // $Id: logstream_8cxx-source.html,v 1.15 2007-12-17 15:37:05 curt Exp $ 00022 00023 #include "logstream.hxx" 00024 00025 logstream *global_logstream = NULL; 00026 00027 bool logbuf::logging_enabled = true; 00028 #ifdef _MSC_VER 00029 bool logbuf::has_console = true; 00030 #endif 00031 sgDebugClass logbuf::logClass = SG_NONE; 00032 sgDebugPriority logbuf::logPriority = SG_INFO; 00033 streambuf* logbuf::sbuf = NULL; 00034 00035 logbuf::logbuf() 00036 { 00037 // if ( sbuf == NULL ) 00038 // sbuf = cerr.rdbuf(); 00039 } 00040 00041 logbuf::~logbuf() 00042 { 00043 if ( sbuf ) 00044 sync(); 00045 } 00046 00047 void 00048 logbuf::set_sb( streambuf* sb ) 00049 { 00050 if ( sbuf ) 00051 sync(); 00052 00053 sbuf = sb; 00054 } 00055 00056 void 00057 logbuf::set_log_level( sgDebugClass c, sgDebugPriority p ) 00058 { 00059 logClass = c; 00060 logPriority = p; 00061 } 00062 00063 void 00064 logbuf::set_log_classes (sgDebugClass c) 00065 { 00066 logClass = c; 00067 } 00068 00069 sgDebugClass 00070 logbuf::get_log_classes () 00071 { 00072 return logClass; 00073 } 00074 00075 void 00076 logbuf::set_log_priority (sgDebugPriority p) 00077 { 00078 logPriority = p; 00079 } 00080 00081 sgDebugPriority 00082 logbuf::get_log_priority () 00083 { 00084 return logPriority; 00085 } 00086 00087 void 00088 logstream::setLogLevels( sgDebugClass c, sgDebugPriority p ) 00089 { 00090 logbuf::set_log_level( c, p ); 00091 } 00092
1.5.1