modm API documentation
prefix.hpp
1 /*
2  * Copyright (c) 2009-2010, Fabian Greif
3  * Copyright (c) 2009-2010, Martin Rosekeit
4  * Copyright (c) 2012, Niklas Hauser
5  *
6  * This file is part of the modm project.
7  *
8  * This Source Code Form is subject to the terms of the Mozilla Public
9  * License, v. 2.0. If a copy of the MPL was not distributed with this
10  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11  */
12 // ----------------------------------------------------------------------------
13 
14 #ifndef MODM_LOG_PREFIX_HPP
15 #define MODM_LOG_PREFIX_HPP
16 
17 #include <cstring>
18 
19 #include "../style.hpp"
20 
21 namespace modm
22 {
23  namespace log
24  {
25  /**
26  * \class Prefix
27  * \brief Add a prefix to the log message
28  *
29  * \code
30  * modm::log::StyleWrapper< modm::log::Prefix< char[9] > > loggerDevicePrefix (
31  * modm::log::Prefix< char[9] > ( "Prefix: ", loggerDevice ) );
32  * modm::log::Logger loggerPrefix( loggerDevicePrefix );
33  * \endcode
34  *
35  * \ingroup modm_debug
36  * \author Martin Rosekeit <martin.rosekeit@rwth-aachen.de>
37  */
38  template <typename T, typename STYLE = DefaultStyle>
39  class Prefix : public Style<STYLE>
40  {
41  public:
42  Prefix(const T& str, STYLE style);
43 
44  Prefix(const T& str, IODevice &device);
45 
46  /// Write one char to the sink.
47  void
48  write( char c );
49 
50  /// Write a string that terminates with \c '\\0' to the sink.
51  void
52  write( const char* s );
53 
54  /// The message is complete and can be written/send/displayed.
55  void
56  flush();
57 
58  private:
59  bool flushed;
60  T value;
61 
62  };
63  }
64 }
65 
66 #include "prefix_impl.hpp"
67 
68 #endif // MODM_LOG_PREFIX_HPP
void flush()
The message is complete and can be written/send/displayed.
void write(char c)
Write one char to the sink.
Definition: modm/src/modm/io/iodevice.hpp:26
This is the interface to all style-classes of the logger.
Definition: style.hpp:78
Add a prefix to the log message.
Definition: prefix.hpp:39