added: travMask to csm viewport
[opensg.git] / Source / Base / Base / OSGLog.cpp
blobf96e092b6a0b4c9322ef3ccc063e2b876b329d0a
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2003 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <cstdlib>
44 #include <cstdio>
46 #include "OSGConfig.h"
48 #include <iostream>
50 #include <cstdio>
51 #include <cstdarg>
53 #include "OSGLog.h"
54 #include "OSGStringUtils.h"
55 #include "OSGBaseInitFunctions.h"
56 #include "OSGThread.h"
58 OSG_USING_NAMESPACE
60 //---------------------------------------------------------------------------
61 // LogBuf
62 //---------------------------------------------------------------------------
65 LogBuf::LogBuf(UInt32 bufferSize) :
66 std::streambuf( ),
67 _enabled (true),
68 _chunkBag ( ),
69 _callback (NULL),
70 _clientData (NULL)
72 setg(0, 0, 0);
74 if(bufferSize > 0)
76 Char8 *buffer = new Char8[bufferSize];
78 setp(buffer, buffer + bufferSize - 1);
80 else
82 setp(0, 0);
86 LogBuf::~LogBuf(void)
88 delete [] pbase();
90 _callback = NULL;
93 /*! \brief clear the chunk bag
96 void LogBuf::clearChunkBag(void)
98 std::list<LogBuf::Chunk*>::iterator cI;
100 for(cI = _chunkBag.begin(); cI != _chunkBag.end(); ++cI)
101 delete *cI;
103 _chunkBag.clear();
107 void LogBuf::setCallback ( LogBuf::Callback cb, void *clientData,
108 bool flushData )
110 std::list<LogBuf::Chunk*>::iterator cI;
111 LogBuf::Chunk *chunk;
113 if(cb)
115 if(flushData)
117 for(cI = _chunkBag.begin(); cI != _chunkBag.end(); cI++)
119 if((chunk = *cI))
120 cb(chunk->data,chunk->size,clientData);
124 _callback = cb;
125 _clientData = clientData;
130 void LogBuf::removeCallback(void)
132 _callback = 0;
136 void LogBuf::write(const Char8 *buffer, std::streamsize size)
138 Chunk *chunk = 0;
139 Callback cb = NULL;
141 if(_enabled)
143 chunk = new Chunk;
145 chunk->size = size;
146 chunk->data = new Char8[size];
148 memcpy(chunk->data, buffer, size);
150 _chunkBag.push_back(chunk);
153 if ((cb = _callback))
154 cb(buffer,size, _clientData);
157 int LogBuf::overflow(Int32 c)
159 if(!pptr())
160 return EOF;
162 if(c != EOF)
164 // Put character into write buffer
165 *pptr() = c;
167 pbump(1);
169 // Flush write buffer
170 std::streamsize size = pptr() - pbase();
172 if(size > 0)
174 write(pbase(), size);
175 pbump(-size);
179 return 0;
182 int LogBuf::sync(void)
184 if(!pptr())
185 return EOF;
187 // Flush write buffer
188 std::streamsize size = pptr() - pbase();
190 if(size > 0)
192 write(pbase(), size);
193 pbump(-size);
196 return 0;
199 std::streamsize LogBuf::xsputn(const Char8 *buffer, std::streamsize size)
201 if(size > 0)
203 if(!pptr())
204 return 0;
206 std::streamsize s = epptr() - pptr();
208 if(s >= size)
210 // Put it into the write buffer
211 memcpy(pptr(), buffer, size);
212 pbump(size);
214 else
216 // Flush write buffer
217 s = pptr() - pbase();
219 if (s > 0)
221 write(pbase(), s);
222 pbump(-s);
225 // Write data
226 write(buffer, size);
230 return size;
233 //---------------------------------------------------------------------------
234 // Log
235 //---------------------------------------------------------------------------
237 /*! \brief holds the nil buffer
240 Log::nilbuf *Log::_nilbufP = NULL;
241 std::ostream *Log::_nilstreamP = NULL;
243 const Char8 *Log::_levelName[] =
245 "LOG", "FATAL", "WARNING", "NOTICE", "DEBUG_GV", "INFO", "DEBUG", 0
248 const Char8 *Log::_levelColor[] =
250 0, // LOG
251 "\x1b[31m", // FATAL
252 "\x1b[33m", // WARNING
253 0, // NOTICE
254 0, // DEBUG_GV
255 0, // INFO
256 0, // DEBUG
260 Char8 *Log::_buffer = NULL;
261 int Log::_bufferSize = 0;
263 LockRefPtr Log::_pLogLock = NULL;
264 InitFuncWrapper Log::_lockInit(&Log::initLock);
266 /*! \brief colorHeader which takes the log level for level color
268 bool Log::colorHeader(LogLevel level, const char *sep)
270 #if defined (OSG_WIN_TYPES) && !defined(OSG_NO_WINDOWD_H_INCLUDE)
271 bool ok = true;
272 std::string str("");
273 LPSTR colStr;
274 DWORD cWritten;
275 WORD oldColAttrs, colAttrs;
276 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
277 HANDLE hOutput = INVALID_HANDLE_VALUE;
279 switch (_logType)
281 case LOG_STDERR:
282 hOutput = GetStdHandle(STD_ERROR_HANDLE);
283 break;
284 case LOG_STDOUT:
285 hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
286 break;
287 default:
288 break;
291 if(hOutput == INVALID_HANDLE_VALUE ||
292 !GetConsoleScreenBufferInfo(hOutput, &csbiInfo) )
294 ok = false;
296 else
298 oldColAttrs = csbiInfo.wAttributes;
300 switch (level)
302 case LOG_FATAL:
303 colAttrs = FOREGROUND_RED | FOREGROUND_INTENSITY;
304 break;
305 case LOG_WARNING:
306 colAttrs = FOREGROUND_RED | FOREGROUND_GREEN;
307 break;
308 default:
309 colAttrs = oldColAttrs;
310 break;
313 if(_levelName[level] != NULL)
314 str = _levelName[level];
316 if(sep != NULL)
317 str += sep;
319 colStr = (LPSTR)str.c_str();
321 if(!SetConsoleTextAttribute(hOutput, colAttrs) ||
322 !WriteFile(hOutput, colStr, lstrlen(colStr), &cWritten, NULL) ||
323 !SetConsoleTextAttribute(hOutput, oldColAttrs) )
325 ok = false;
329 return ok;
330 #else
331 return false;
332 #endif
335 Log::Log(LogType logType, LogLevel logLevel) :
336 std::ostream (_nilbufP == NULL ?
337 _nilbufP = new Log::nilbuf() : _nilbufP),
338 _logType (logType ),
339 _logLevel (logLevel ),
340 _fileStream ( ),
341 _logBuf ( ),
342 _headerElem ( 0),
343 _moduleHandling(LOG_MODULE_ALL)
345 if(_nilstreamP == NULL)
346 _nilstreamP = new std::ostream(_nilbufP);
348 for(UInt32 i = 0; i < sizeof(_streamVec)/sizeof(LogOStream *); i++)
350 #ifdef OSG_HAS_NILBUF
351 _streamVec[i] = new LogOStream(_nilbufP);
352 #else
353 _streamVec[i] = new LogOStream(_nilStreamP->rdbuf());
354 #endif
357 setHeaderElem(LOG_TYPE_HEADER);
359 _refTime = getSystemTime();
361 setLogLevel(logLevel);
364 /*! \brief Constructor which takes a log file name
367 Log::Log(const Char8 *fileName, LogLevel logLevel) :
368 std::ostream (_nilbufP == NULL ?
369 _nilbufP = new Log::nilbuf() : _nilbufP),
370 _logType (LOG_FILE ),
371 _logLevel (logLevel ),
372 _fileStream ( ),
373 _logBuf ( ),
374 _headerElem ( 0),
375 _moduleHandling(LOG_MODULE_ALL)
377 if(_nilstreamP == NULL)
378 _nilstreamP = new std::ostream(_nilbufP);
380 for(UInt32 i = 0; i < sizeof(_streamVec)/sizeof(LogOStream *); i++)
382 #ifdef OSG_HAS_NILBUF
383 _streamVec[i] = new LogOStream(_nilbufP);
384 #else
385 _streamVec[i] = new LogOStream(_nilStreamP->rdbuf());
386 #endif
389 _refTime = getSystemTime();
391 setHeaderElem(LOG_TYPE_HEADER);
392 setLogFile (fileName);
393 setLogLevel (logLevel);
396 Log::~Log(void)
398 setLogFile(NULL, true);
400 delete _nilstreamP;
401 delete _nilbufP;
403 _nilstreamP = NULL;
404 _nilbufP = NULL;
406 for(UInt32 i = 0; i < sizeof(_streamVec)/sizeof(LogOStream *); i++)
408 delete _streamVec[i];
410 _streamVec[i] = NULL;
415 bool Log::initLock(void)
417 _pLogLock = Lock::get("OSG::Log::_pLogLock", true);
419 addPreMPExitFunction(&Log::finalizeLock);
421 return true;
424 bool Log::finalizeLock(void)
426 _pLogLock = NULL;
428 return true;
431 /*------------------------------ access -----------------------------------*/
433 /*! \brief set method for attribute _headerElem
436 void Log::setHeaderElem(UInt32 elemMask, bool force)
438 Char8 *env;
440 if((force == false ) &&
441 (this == osgLogP ) &&
442 (env = getenv(OSG_NAMESPACE_PREFIX"_LOG_HEADER")) )
444 osgLog() << "Log::setHeaderElem: overriden by envvar OSG_LOG_HEADER '"
445 << env << "'." << endLog;
447 elemMask = atoi(env);
450 _headerElem = elemMask;
453 /*! \brief add method for attribute _headerElem
456 void Log::addHeaderElem(LogHeaderElem elem, bool force)
458 setHeaderElem((_headerElem | elem), force);
461 /*! \brief delete method for attribute _headerElem
464 void Log::delHeaderElem(LogHeaderElem elem, bool force)
466 setHeaderElem((_headerElem & ~elem),force);
469 /*! \brief check for a single headerElem
472 bool Log::hasHeaderElem(LogHeaderElem elem)
474 return (_headerElem & elem) != 0;
477 void Log::addModuleHandling(LogModuleHandling handling,
478 bool OSG_CHECK_ARG(force))
480 _moduleHandling |= handling;
483 void Log::delModuleHandling(LogModuleHandling handling,
484 bool OSG_CHECK_ARG(force))
486 _moduleHandling &= ~handling;
489 void Log::addModuleName(const Char8 *module, bool isStatic)
491 Module m;
493 if(module && *module)
495 _moduleList.push_back(m);
497 if(isStatic)
499 _moduleList.back().name = module;
500 _moduleList.back().isStatic = true;
502 else
504 SizeT len = strlen(module);
506 _moduleList.back().name = new Char8[len + 1];
508 strcpy(const_cast<Char8 *>(_moduleList.back().name), module);
510 _moduleList.back().isStatic = false;
515 void Log::delModuleName(const Char8 *OSG_CHECK_ARG(module))
519 bool Log::hasModule(const Char8 *module)
521 bool retCode = false;
522 std::list<Module>::iterator mI;
524 if(module && *module)
526 for( mI = _moduleList.begin();
527 retCode || (mI != _moduleList.end());
528 ++mI)
530 retCode = (mI->isStatic) ?
531 (module == mI->name) : (!strcmp(module,mI->name));
535 return retCode;
538 bool Log::checkModule(const Char8 *module)
540 bool retCode = false;
541 std::list<Module>::iterator mI;
543 if(_moduleHandling != LOG_MODULE_NONE)
545 if(_moduleHandling == LOG_MODULE_ALL)
547 retCode = true;
549 else
551 if(module && *module)
553 if(hasModule(module))
555 if(_moduleHandling & LOG_MODULE_KNOWN)
556 retCode = true;
558 else
560 if(_moduleHandling & LOG_MODULE_UNKNOWN)
561 retCode = true;
564 else
566 if(_moduleHandling & LOG_MODULE_UNDEFINED)
567 retCode = true;
572 return retCode;
576 LogType Log::getLogType(void)
578 return _logType;
581 /*! \brief set method for attribute logType, checks OSG_LOG_TYPE env var
582 if not forced.
585 void Log::setLogType(LogType logType, bool force)
587 static const Char8 *typenames[] =
589 "none",
590 "-",
591 "stdout",
592 "stderr",
593 "file",
594 "buffer",
595 NULL
598 static LogType types [] =
600 LOG_NONE,
601 LOG_STDOUT,
602 LOG_STDOUT,
603 LOG_STDERR,
604 LOG_FILE,
605 LOG_BUFFER
608 static Int32 typeCount = sizeof(types) / sizeof(LogType);
610 Char8 *et;
611 Int32 lt;
612 Int32 i;
614 if((force == false ) &&
615 (this == osgLogP ) &&
616 (et = getenv(OSG_NAMESPACE_PREFIX"_LOG_TYPE")) )
618 osgLog() << "Log::setLogType: overriden by envvar OSG_LOG_TYPE '"
619 << et << "'." << std::endl;
621 if(sscanf(et, "%d", &lt) != 1)
623 for(i = 0; typenames[i]; i++)
625 if(!osgStringCaseCmp(et, typenames[i]))
627 _logType = types[i];
628 break;
632 if(! typenames[i])
634 _logType = LOG_STDERR;
636 osgLog() << "Log::setLogType: couldn't interpret envvar, "
637 << "set to LOG_STDERR!"
638 << std::endl;
641 else
643 if(lt < 0)
645 lt = 0;
647 else
649 if(lt >= typeCount)
650 lt = typeCount - 1;
653 _logType = types[lt];
656 else
658 _logType = logType;
661 connect();
665 LogLevel Log::getLogLevel(void)
667 return _logLevel;
671 /*! Set method for attribute logLevel, checks the env vars
672 OSG_LOG_LEVEL_STARTUP and OSG_LOG_LEVEL and uses their value, unless
673 \a force is true.
675 \param[in] logLevel The level for log messages to be emitted.
676 \param[in] force If true, ignore env variables and set level to \a logLevel.
678 void Log::setLogLevel(LogLevel logLevel, bool force)
680 static const Char8 *levelnames[] =
682 "log",
683 "fatal",
684 "warning",
685 "notice",
686 "debug_gv",
687 "info",
688 "debug",
689 NULL
692 static LogLevel levels [] =
694 LOG_LOG,
695 LOG_FATAL,
696 LOG_WARNING,
697 LOG_NOTICE,
698 LOG_DEBUG_GV,
699 LOG_INFO,
700 LOG_DEBUG
703 static Int32 levelCount = sizeof(levels) / sizeof(LogLevel);
705 Char8 *el;
706 Int32 ll;
707 Int32 i;
709 // unless forced, envvars override the argument
710 if(!force && (this == osgLogP))
712 // startup allows different log level
713 if(GlobalSystemState == Startup)
715 if((el = getenv(OSG_NAMESPACE_PREFIX"_LOG_LEVEL_STARTUP")) != 0)
717 // OSG_LOG_LEVEL_STARTUP has highest precedence
718 osgLog() << "OSGLog::setLogLevel: overridden by envvar "
719 << "OSG_LOG_LEVEL_STARTUP '" << el << "'."
720 << std::endl;
722 else if((el = getenv(OSG_NAMESPACE_PREFIX"_LOG_LEVEL")) != 0)
724 // fallback to OSG_LOG_LEVEL
725 osgLog() << "OSGLog::setLogLevel: overridden by envvar "
726 << "OSG_LOG_LEVEL '" << el << "'."
727 << std::endl;
730 else
732 if((el = getenv(OSG_NAMESPACE_PREFIX"_LOG_LEVEL")) != 0)
734 osgLog() << "OSGLog::setLogLevel: overridden by envvar "
735 << "OSG_LOG_LEVEL '" << el << "'."
736 << std::endl;
740 // if an envvar was set, interpret its value
741 if(el != 0)
743 if(sscanf(el, "%d", &ll) != 1)
745 // interpret the value as name of a level
746 for(i = 0; levelnames[i]; ++i)
748 if(!osgStringCaseCmp(el, levelnames[i]))
750 logLevel = levels[i];
751 break;
755 if(!levelnames[i])
757 logLevel = LOG_DEBUG;
759 osgLog() << "OSGLog::setLogLevel: Could not interpret "
760 << "envvar, setting to LOG_DEBUG."
761 << std::endl;
764 else
766 // interpret value as numerical level
767 if(ll < 0)
769 ll = 0;
771 else if(ll >= levelCount)
773 ll = levelCount - 1;
776 logLevel = levels[ll];
781 // if force is true this is the unmodified argument, otherwise envvars
782 // might have changed the value of logLevel
783 _logLevel = logLevel;
784 connect();
787 /*! \brief method to set and activate the log file, checks OSG_LOG_FILE env
788 var if not forced
791 void Log::setLogFile(const Char8 *fileName, bool force)
793 const Char8 *name;
795 #ifdef OSG_STREAM_HAS_ISOPEN
796 if(_fileStream.is_open())
797 #else
798 if(_fileStream.rdbuf()->is_open())
799 #endif
801 _fileStream.close();
804 if((force == false ) &&
805 (this == osgLogP ) &&
806 (name = getenv(OSG_NAMESPACE_PREFIX"_LOG_FILE")))
808 osgLog() << "Log::setLogFile: overriden by envvar OSG_LOG_FILE '"
809 << name << "'." << std::endl;
811 else
813 name = fileName;
816 if(name && *name)
818 _fileStream.open(name, std::ios::out);
820 #ifdef OSG_STREAM_HAS_ISOPEN
821 if(_fileStream.is_open())
822 #else
823 if(_fileStream.rdbuf()->is_open())
824 #endif
826 _logType = LOG_FILE;
827 connect();
832 /*! Write log header.
834 std::ostream &Log::doHeader( LogLevel level,
835 const Char8 *module,
836 const Char8 *file,
837 UInt32 line,
838 const Char8 *funcName)
840 LogOStream &sout = *(_streamVec[level]);
841 const char *sep = ( (_headerElem & LOG_TAB_HEADER) ? "\t" : ":" );
842 const char *color = ( (_headerElem & LOG_COLOR_HEADER) ?
843 _levelColor[level] : 0 );
844 const char *resetColor = "\x1b[0m";
846 if(_headerElem)
848 if(_headerElem & LOG_BEGIN_NEWLINE_HEADER)
849 sout << std::endl;
851 if(_headerElem & LOG_TYPE_HEADER)
853 #ifdef WIN32
854 if(_headerElem & LOG_ANSICOLOR_HEADER)
856 if(color)
857 sout << color;
859 sout << _levelName[level] << sep;
861 if(color)
862 sout << resetColor;
864 else
866 if(!color || !colorHeader(level, sep))
867 sout << _levelName[level] << sep;
869 #else
870 if(color)
871 sout << color;
873 sout << _levelName[level] << sep;
875 if(color)
876 sout << resetColor;
877 #endif
880 if(_headerElem & LOG_ASPECT_HEADER)
882 sout << "A" << Thread::getCurrentAspect() << sep;
885 if(_headerElem & LOG_TIMESTAMP_HEADER)
886 sout << (getSystemTime() - _refTime) << sep;
888 if(module && *module && (_headerElem & LOG_MODULE_HEADER))
889 sout << module << sep;
891 if(file && *file && (_headerElem & LOG_FILE_HEADER))
893 sout << file;
895 if(_headerElem & LOG_LINE_HEADER)
896 sout << ':' << line;
898 sout << sep;
900 else
902 if(_headerElem & LOG_LINE_HEADER)
903 sout << " line:" << line;
906 if(funcName && *funcName && (_headerElem & LOG_FUNCNAME_HEADER))
908 sout << funcName << sep;
911 if(_headerElem & LOG_END_NEWLINE_HEADER)
912 sout << std::endl;
913 else
914 sout << ' ';
917 return sout;
920 /*! \brief print for C-interface helper method
923 void Log::doLog(const Char8 * format, ...)
926 va_list args;
928 va_start( args, format );
930 #if defined(OSG_HAS_VSNPRINTF) && !defined(__sgi)
931 int count;
933 if(_buffer == NULL)
935 _bufferSize = 8;
936 _buffer = new Char8[_bufferSize];
939 // on windows it returns -1 if the output
940 // was truncated due to the buffer size limit.
941 // on irix this returns always buffer_size-1 ????
943 count = vsnprintf(_buffer, _bufferSize, format, args);
945 while(count >= _bufferSize || count == -1)
947 _bufferSize = osgMax(_bufferSize * 2, count + 1);
949 if(_buffer != NULL)
950 delete [] _buffer;
952 _buffer = new Char8[_bufferSize];
954 va_start(args, format);
956 count = vsnprintf(_buffer, _bufferSize, format, args);
958 #else
959 if(_bufferSize < 8192)
961 _bufferSize = 8192;
963 if(_buffer != NULL)
964 delete [] _buffer;
966 _buffer = new Char8[_bufferSize];
969 vsprintf(_buffer, format, args);
970 #endif
972 // *this << buffer;
973 // *this << std::flush;
974 // Work around VC71. Patch by Chad Austin.
975 std::ostream& os = *this;
976 os << _buffer;
977 os << std::flush;
979 va_end(args);
983 /*! \brief reconnects the streams for the current settings
986 void Log::connect(void)
988 Int32 i;
990 #ifndef OSG_STREAM_RDBUF_HAS_PARAM
991 switch(_logType)
993 case LOG_STDOUT:
994 this->bp = std::cout.rdbuf();
995 break;
996 case LOG_STDERR:
997 this->bp = std::cerr.rdbuf();
998 break;
999 case LOG_FILE:
1000 this->bp = _fileStream.rdbuf();
1001 break;
1002 case LOG_BUFFER:
1003 this->bp = _logBuf;
1004 break;
1005 case LOG_NONE:
1006 default:
1007 this->bp = _nilStreamP->rdbuf();
1008 break;
1010 #else
1011 switch(_logType)
1013 case LOG_STDOUT:
1014 this->rdbuf(std::cout.rdbuf());
1015 break;
1016 case LOG_STDERR:
1017 this->rdbuf(std::cerr.rdbuf());
1018 break;
1019 case LOG_FILE:
1020 this->rdbuf(_fileStream.rdbuf());
1021 break;
1022 case LOG_BUFFER:
1023 this->rdbuf(&_logBuf);
1024 break;
1025 case LOG_NONE:
1026 default:
1027 this->rdbuf(_nilbufP);
1028 break;
1030 #endif
1032 for(i = 0; i < int(sizeof(_streamVec)/sizeof(std::ostream*)); ++i)
1034 if (i <= _logLevel)
1036 _streamVec[i]->setrdbuf(this->rdbuf());
1038 else
1040 #ifdef OSG_HAS_NILBUF
1041 _streamVec[i]->setrdbuf(_nilbufP);
1042 #else
1043 _streamVec[i]->setrdbuf(_nilStreamP->rdbuf());
1044 #endif
1049 void Log::terminate(void)
1051 #ifdef OSG_HAS_NILBUF
1052 delete Log::_nilbufP;
1054 Log::_nilbufP = NULL;
1055 #else
1056 if(Log::_nilstreamP != NULL)
1058 Log::_nilstreamP->close();
1060 delete Log::_nilstreamP;
1062 Log::_nilstreamP = NULL;
1064 #endif
1066 delete osgLogP;
1068 osgLogP = NULL;
1070 delete [] Log::_buffer;
1072 Log::_bufferSize = 0;
1073 Log::_buffer = NULL;
1076 /** \var LogType Log::_logType;
1077 * \brief holds the log type
1080 /** \var LogLevel Log::_logLevel;
1081 * \brief holds the log level
1084 /** \var fstream Log::_fileStream;
1085 * \brief file stream
1088 /** \var LogOStream *Log::_streamVec[6];
1089 * \brief stream vector
1093 OSG_BEGIN_NAMESPACE
1095 OSG_BASE_DLLMAPPING LogP osgLogP = NULL;
1097 OSG_END_NAMESPACE
1100 void OSG::doInitLog(void)
1102 // Make sure no one reanimates the Log from the dead
1103 if(GlobalSystemState >= Shutdown)
1104 abort();
1106 #ifdef OSG_HAS_NILBUF
1107 if(Log::_nilbufP == NULL)
1108 Log::_nilbufP = new Log::nilbuf();
1109 #else
1110 if(Log::_nilstreamP == NULL)
1111 Log::_nilstreamP = new std::fstream("/dev/null", std::ios::out);
1112 #endif
1114 if(osgLogP == NULL)
1116 osgLogP = new Log();
1118 osgLogP->setLogLevel (OSG_DEFAULT_LOG_LEVEL );
1119 osgLogP->setLogFile (NULL );
1120 osgLogP->setLogType (OSG_DEFAULT_LOG_TYPE );
1121 osgLogP->setHeaderElem(OSG_DEFAULT_LOG_HEADER_ELEM);