Claw  1.7.0
log_stream_concise.hpp
Go to the documentation of this file.
00001 /*
00002   CLAW - a C++ Library Absolutely Wonderful
00003 
00004   CLAW is a free library without any particular aim but being useful to 
00005   anyone.
00006 
00007   Copyright (C) 2005-2011 Julien Jorge
00008 
00009   This library is free software; you can redistribute it and/or
00010   modify it under the terms of the GNU Lesser General Public
00011   License as published by the Free Software Foundation; either
00012   version 2.1 of the License, or (at your option) any later version.
00013 
00014   This library is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017   Lesser General Public License for more details.
00018 
00019   You should have received a copy of the GNU Lesser General Public
00020   License along with this library; if not, write to the Free Software
00021   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023   contact: julien.jorge@gamned.org
00024 */
00031 #ifndef __CLAW_LOG_STREAM_CONCISE_HPP__
00032 #define __CLAW_LOG_STREAM_CONCISE_HPP__
00033 
00034 #include <list>
00035 #include <string>
00036 #include <claw/log_stream.hpp>
00037 
00038 #ifndef CLAW_LOGGER_EXPORT
00039 #  ifdef CLAW_LOGGER_NO_EXPORT
00040 #    define CLAW_LOGGER_EXPORT
00041 #  else
00042 #    ifdef _WIN32
00043 #      ifdef claw_logger_EXPORTS
00044 #        define CLAW_LOGGER_EXPORT __declspec(dllexport)
00045 #      else
00046 #        define CLAW_LOGGER_EXPORT __declspec(dllimport)
00047 #      endif // def claw_logger_EXPORTS
00048 #    else // def _WIN32
00049 #      define CLAW_LOGGER_EXPORT
00050 #    endif // def _WIN32
00051 #  endif // def CLAW_LOGGER_NO_EXPORT
00052 #endif // ndef CLAW_LOGGER_EXPORT
00053 
00054 namespace claw
00055 {
00061   class CLAW_LOGGER_EXPORT log_stream_concise:
00062     public log_stream,
00063     public pattern::non_copyable
00064   {
00065   public:
00066     explicit log_stream_concise
00067       ( log_stream* s, std::size_t max_history_size = 25 );
00068     virtual ~log_stream_concise();
00069 
00070     virtual void write( const std::string& str );
00071     virtual void flush();
00072 
00073   private:
00074     void output_current_line();
00075 
00076   private:
00078     log_stream* m_stream;
00079 
00081     std::string m_current_line;
00082 
00084     std::list<std::string> m_previous_lines;
00085 
00087     std::size_t m_max_history_size;
00088 
00089   }; // class log_stream_concise
00090 } // namespace claw
00091 
00092 #endif // __CLAW_LOG_STREAM_CONCISE_HPP__