claw  1.9.0
log_stream_concise.hpp
Go to the documentation of this file.
1 /*
2  CLAW - a C++ Library Absolutely Wonderful
3 
4  CLAW is a free library without any particular aim but being useful to
5  anyone.
6 
7  Copyright (C) 2005-2011 Julien Jorge
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 
23  contact: julien.jorge@stuff-o-matic.com
24 */
31 #ifndef __CLAW_LOG_STREAM_CONCISE_HPP__
32 #define __CLAW_LOG_STREAM_CONCISE_HPP__
33 
35 
36 #include <list>
37 #include <string>
38 
39 #ifndef CLAW_LOGGER_EXPORT
40 #ifdef CLAW_LOGGER_NO_EXPORT
41 #define CLAW_LOGGER_EXPORT
42 #else
43 #ifdef _WIN32
44 #ifdef claw_logger_EXPORTS
45 #define CLAW_LOGGER_EXPORT __declspec(dllexport)
46 #else
47 #define CLAW_LOGGER_EXPORT __declspec(dllimport)
48 #endif // def claw_logger_EXPORTS
49 #else // def _WIN32
50 #define CLAW_LOGGER_EXPORT
51 #endif // def _WIN32
52 #endif // def CLAW_LOGGER_NO_EXPORT
53 #endif // ndef CLAW_LOGGER_EXPORT
54 
55 namespace claw
56 {
62  class CLAW_LOGGER_EXPORT log_stream_concise
63  : public log_stream
64  , public pattern::non_copyable
65  {
66  public:
67  explicit log_stream_concise(log_stream* s,
68  std::size_t max_history_size = 25);
69  virtual ~log_stream_concise();
70 
71  virtual void write(const std::string& str);
72  virtual void flush();
73 
74  private:
75  void output_current_line();
76 
77  private:
79  log_stream* m_stream;
80 
82  std::string m_current_line;
83 
85  std::list<std::string> m_previous_lines;
86 
88  std::size_t m_max_history_size;
89 
90  }; // class log_stream_concise
91 }
92 
93 #endif // __CLAW_LOG_STREAM_CONCISE_HPP__
Inherit from this class to forbid construction of your class by copy.
Some basic classes for logging.
Base class for streams accepting log output.
Definition: log_stream.hpp:60
This is the main namespace.
Definition: application.hpp:49
A log stream that does not output a message that have been recently output.