Line data Source code
1 : /*
2 : * Copyright (c) 2013-2019 Made to Order Software Corp. All Rights Reserved
3 : *
4 : * https://snapwebsites.org/project/snaplogger
5 : * contact@m2osw.com
6 : *
7 : * This program is free software; you can redistribute it and/or modify
8 : * it under the terms of the GNU General Public License as published by
9 : * the Free Software Foundation; either version 2 of the License, or
10 : * (at your option) any later version.
11 : *
12 : * This program is distributed in the hope that it will be useful,
13 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 : * GNU General Public License for more details.
16 : *
17 : * You should have received a copy of the GNU General Public License along
18 : * with this program; if not, write to the Free Software Foundation, Inc.,
19 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 : */
21 : #pragma once
22 :
23 : /** \file
24 : * \brief The buffer appender sends its output to a memory buffer.
25 : *
26 : * This file declares the buffer appender class.
27 : */
28 :
29 : // self
30 : //
31 : #include "snaplogger/appender.h"
32 :
33 :
34 : // C++ lib
35 : //
36 : #include <sstream>
37 :
38 :
39 :
40 : namespace snaplogger
41 : {
42 :
43 :
44 12 : class buffer_appender
45 : : public appender
46 : , public std::stringstream
47 : {
48 : public:
49 : typedef std::shared_ptr<buffer_appender> pointer_t;
50 :
51 : buffer_appender(std::string const name);
52 :
53 : bool empty() const;
54 : void clear(bool keep_buffer = false);
55 : std::string str();
56 : void str(std::string const & buf);
57 :
58 : protected:
59 : virtual void process_message(message const & msg, std::string const & formatted_message) override;
60 : };
61 :
62 :
63 : } // snaplogger namespace
64 : // vim: ts=4 sw=4 et
|