logger
line.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <string>
10 #include <memory>
11 #include <sstream>
12 
13 #include "level.hpp"
14 #include "logger_export.hpp"
15 
16 namespace logger
17 {
21  class Line
22  {
23  public:
24  // public interface
25 
29  LOGGER_EXPORT ~Line();
30 
37  template<class T>
38  Line & operator <<(T value)
39  {
40  *m_stream << value;
41  return *this;
42  }
43 
44  // internal interface
45 
47  Line(const Level & level, std::string context);
49  const Level & level() const;
51  static std::string currentTimeString(const std::string & format);
53  std::string string() const;
54 
55  // explicit defaults as requested by clang-tidy (cppcoreguidelines-special-member-functions)
56 
58  Line(const Line & line) = default;
60  Line(Line&& line) = default;
62  Line & operator=(const Line & line) = default;
64  Line & operator=(Line && line) = default;
65 
66  private:
67  Level m_level;
68  std::string m_context;
69  std::shared_ptr<std::ostringstream> m_stream;
70  };
71 }
Level
Levels for filtering messages based on importance.
Definition: level.hpp:16
Allows piping content in order to build a log message. Once the object is destroyed, the piped content will be logged to the appropriate outputs.
Definition: line.hpp:21
~Line()
Logs all contents previously piped into the object to the outputs.
Line & operator<<(T value)
Add content to the log message.
Definition: line.hpp:38
Logger namespace. Contains all available functions and classes.
Definition: level.hpp:11
Log levels.