modm API documentation
style.hpp
1 /*
2  * Copyright (c) 2009, Martin Rosekeit
3  * Copyright (c) 2010, Fabian Greif
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_STYLE_HPP
15 #define MODM_LOG_STYLE_HPP
16 
17 #include <modm/io/iodevice.hpp>
18 
19 namespace modm
20 {
21  namespace log
22  {
23  /**
24  * \brief This is an empty style.
25  *
26  * \ingroup modm_debug
27  * \author Martin Rosekeit <martin.rosekeit@rwth-aachen.de>
28  */
30  {
31  public :
32  /// parse arguments that are given with the start of the program
33  inline void
34  parseArg( int argc, char * argv)
35  {
36  (void) argc;
37  (void) argv;
38  }
39 
40  /// Write one char to the sink.
41  inline void
42  write( char c )
43  {
44  (void) c;
45  }
46 
47  /// Write a string that terminates with \c '\\0' to the sink.
48  inline void
49  write( const char* s )
50  {
51  (void) s;
52  }
53 
54  /// The message is complete and can be written/send/displayed.
55  inline void
57  {
58  }
59  };
60 
61  /**
62  * \class Style
63  * \brief This is the interface to all style-classes of the logger.
64  *
65  * For each log level the logger provides a singleton. Because the
66  * format the log messages should be presented depends on the system
67  * and other circumstances. With the style-classes the user can
68  * set in the main-file the desired format of the output stream.
69  *
70  * This classes take the stream from the loglevel device, modify it in
71  * the given way and pass it to the next style class or device.
72  *
73  *
74  * \ingroup modm_debug
75  * \author Martin Rosekeit <martin.rosekeit@rwth-aachen.de>
76  */
77  template < typename STYLE = DefaultStyle >
78  class Style
79  {
80  public:
81  typedef STYLE Type;
82 
83  Style( STYLE style );
84 
85  Style( IODevice &device);
86 
87  virtual
88  ~Style();
89 
90  /// parse arguments that are given with the start of the program
91  inline void
92  parseArg( int argc, char * argv);
93 
94  /// Write one char to the sink.
95  inline void
96  write( char c );
97 
98  /// Write a string that terminates with \c '\\0' to the sink.
99  inline void
100  write( const char* s );
101 
102  /// The message is complete and can be written/send/displayed.
103  inline void
104  flush();
105 
106  private:
107  STYLE style;
108  IODevice* device;
109  };
110  }
111 }
112 
113 #include "style_impl.hpp"
114 
115 #endif // MODM_LOG_STYLE_HPP
void flush()
The message is complete and can be written/send/displayed.
void write(char c)
Write one char to the sink.
void parseArg(int argc, char *argv)
parse arguments that are given with the start of the program
Definition: modm/src/modm/io/iodevice.hpp:26
This is the interface to all style-classes of the logger.
Definition: style.hpp:78
void flush()
The message is complete and can be written/send/displayed.
Definition: style.hpp:56
void write(const char *s)
Write a string that terminates with '0' to the sink.
Definition: style.hpp:49
void write(char c)
Write one char to the sink.
Definition: style.hpp:42
void parseArg(int argc, char *argv)
parse arguments that are given with the start of the program
Definition: style.hpp:34
This is an empty style.
Definition: style.hpp:29