00001 // 00002 // LogStreambuf.hh 00003 // 00004 // Copyright (C) : 2000 - 2002 00005 // LifeLine Networks BV (www.lifeline.nl). All rights reserved. 00006 // Bastiaan Bakker. All rights reserved. 00007 // 00008 // 2004,2005,2006,2007,2008,2009,2010 00009 // Synchrotron SOLEIL 00010 // L'Orme des Merisiers 00011 // Saint-Aubin - BP 48 - France 00012 // 00013 // This file is part of log4tango. 00014 // 00015 // Log4ango is free software: you can redistribute it and/or modify 00016 // it under the terms of the GNU Lesser General Public License as published by 00017 // the Free Software Foundation, either version 3 of the License, or 00018 // (at your option) any later version. 00019 // 00020 // Log4tango is distributed in the hope that it will be useful, 00021 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 // GNU Lesser General Public License for more details. 00024 // 00025 // You should have received a copy of the GNU Lesser General Public License 00026 // along with Log4Tango. If not, see <http://www.gnu.org/licenses/>. 00027 00028 #ifndef _LOG4TANGO_STREAM_BUFFER_H 00029 #define _LOG4TANGO_STREAM_BUFFER_H 00030 00031 #include <log4tango/Portability.hh> 00032 #include <log4tango/Logger.hh> 00033 00034 //----------------------------------------------------------------------------- 00035 // #DEFINES 00036 //----------------------------------------------------------------------------- 00037 #define kDEFAULT_BUFFER_SIZE 512 00038 00039 namespace log4tango { 00040 00041 //----------------------------------------------------------------------------- 00042 // Class : LogStreamBuf 00043 //----------------------------------------------------------------------------- 00044 class LOG4TANGO_EXPORT LogStreamBuf : public std::streambuf 00045 { 00046 friend class LogStream; 00047 00048 public: 00049 00050 LogStreamBuf (Logger* logger, 00051 Level::Value level, 00052 bool filter = true, 00053 size_t bsize = kDEFAULT_BUFFER_SIZE); 00054 00055 virtual ~LogStreamBuf(); 00056 00057 protected: 00058 00059 virtual std::streamsize xsputn (const char*, std::streamsize); 00060 00061 00062 virtual int sync (void); 00063 00064 private: 00065 00066 int flush_buffer (void); 00067 00068 char *_buffer; 00069 00070 Logger* _logger; 00071 00072 Level::Value _level; 00073 00074 bool _filter; 00075 }; 00076 00077 } // namespace log4tango 00078 00079 #endif // _LOG4TANGO_STREAM_BUFFER_H 00080 00081