Line | Branch | Exec | Source |
---|---|---|---|
1 | #pragma once | ||
2 | |||
3 | #include <memory> | ||
4 | #include <string> | ||
5 | |||
6 | #include "Logger.h" | ||
7 | |||
8 | namespace iguana { | ||
9 | |||
10 | /// @brief A named object with a `Logger` instance | ||
11 | class Object | ||
12 | { | ||
13 | |||
14 | public: | ||
15 | |||
16 | /// @param name the name of this object | ||
17 | /// @param lev the log level | ||
18 | Object(std::string_view name = "", Logger::Level lev = Logger::DEFAULT_LEVEL); | ||
19 |
1/2✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
|
372 | ~Object() {} |
20 | |||
21 | /// Get the logger | ||
22 | /// @return the logger used by this object | ||
23 | std::unique_ptr<Logger>& Log(); | ||
24 | |||
25 | /// Change the name of this object | ||
26 | /// @param name the new name | ||
27 | void SetName(std::string_view name); | ||
28 | |||
29 | /// @returns the name of this object | ||
30 | std::string GetName() const; | ||
31 | |||
32 | /// Set the log level to this level. Log messages with a lower level will not be printed. | ||
33 | /// @see `Logger::Level` for available levels. | ||
34 | /// @param lev the log level name | ||
35 | void SetLogLevel(std::string_view lev); | ||
36 | |||
37 | /// Set the log level to this level. Log messages with a lower level will not be printed. | ||
38 | /// @see `Logger::Level` for available levels. | ||
39 | /// @param lev the log level | ||
40 | void SetLogLevel(Logger::Level const lev); | ||
41 | |||
42 | /// @returns reference to this object's logger | ||
43 | std::unique_ptr<Logger>& GetLog(); | ||
44 | |||
45 | |||
46 | protected: | ||
47 | |||
48 | /// The name of this object | ||
49 | std::string m_name; | ||
50 | |||
51 | /// `Logger` instance for this object | ||
52 | std::unique_ptr<Logger> m_log; | ||
53 | }; | ||
54 | } | ||
55 |