Skip to content

Commit 8c1dad3

Browse files
authored
Review/add the API doc (logging) (#1201)
In olp-cpp-sdk-core/include/olp/core/logging, review and modify the existing documentation and add missing descriptions so that we have fewer errors when building the API ref. Relates-To: OLPEDGE-1446 Signed-off-by: Halyna Dumych <[email protected]>
1 parent a77410b commit 8c1dad3

File tree

10 files changed

+431
-281
lines changed

10 files changed

+431
-281
lines changed

olp-cpp-sdk-core/include/olp/core/logging/Appender.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@
2424
namespace olp {
2525
namespace logging {
2626
/**
27-
* @brief Abstract base class for an appender, which appends a message to the
28-
* log.
27+
* @brief Appends a message to the log.
2928
*
30-
* Subclasses should derive from Appender instead of IAppender in order for the
31-
* type to be automatically registered.
29+
* To automatically register the type, base subclasses on
30+
* `Appender` instead of `IAppender`.
3231
*/
3332
class CORE_API IAppender {
3433
public:
3534
virtual ~IAppender() = default;
3635

3736
/**
38-
* @brief Appends a message using char strings.
37+
* @brief Appends the message using char strings.
38+
*
3939
* @param message The message to append.
4040
*/
4141
virtual IAppender& append(const LogMessage& message) = 0;

olp-cpp-sdk-core/include/olp/core/logging/Configuration.h

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,19 @@
3030
namespace olp {
3131
namespace logging {
3232
/**
33-
* @brief Class for configuring the appenders and loggers available by the
34-
* logging system.
33+
* @brief Configures appenders and loggers available in
34+
* the logging system.
3535
*/
3636
class CORE_API Configuration {
3737
public:
3838
/**
39-
* @brief Struct containing an appender and a log level that the appender is
40-
* enabled with.
39+
* @brief Contains an appender and its log level.
4140
*/
4241
struct AppenderWithLogLevel {
4342
/**
44-
* @brief The log level the appender is enabled with.
43+
* @brief The log level of the appender.
4544
*
46-
* Any log levels less than this level will be ignored.
45+
* Any log level that is less than this level is ignored.
4746
*/
4847
logging::Level logLevel;
4948

@@ -53,7 +52,8 @@ class CORE_API Configuration {
5352
std::shared_ptr<IAppender> appender;
5453

5554
/**
56-
* @brief Checks to see if the appender is enabled for a log level.
55+
* @brief Checks whether the appender is enabled for the log level.
56+
*
5757
* @param level The log level.
5858
*/
5959
bool isEnabled(logging::Level level) const {
@@ -62,27 +62,30 @@ class CORE_API Configuration {
6262
};
6363

6464
/**
65-
* @brief Typedef for a list of appenders
65+
* @brief A typedef for a list of appenders.
6666
*/
6767
using AppenderList = std::vector<AppenderWithLogLevel>;
6868

6969
/**
70-
* @brief Creates a default configuration by adding the DebugAppender and the
71-
* ConsoleAppender as appenders.
70+
* @brief Creates a default configuration by adding
71+
* an instance of `DebugAppender` and `ConsoleAppender` as appenders.
72+
*
7273
* @return The default configuration.
7374
*/
7475
static Configuration createDefault();
7576

7677
/**
77-
* @brief Returns whether or not the configuration is valid.
78-
* @return Whether or not the configuration is valid.
78+
* @brief Checks whether the configuration is valid.
79+
*
80+
* @return True if the configuration is valid; false otherwise.
7981
*/
8082
inline bool isValid() const;
8183

8284
/**
83-
* @brief Adds an appender along with its logging level to the configuration.
85+
* @brief Adds the appender along with its log level to the configuration.
86+
*
8487
* @param appender The appender to add.
85-
* @param level The log level belonging to appender.
88+
* @param level The log level of the appender.
8689
*/
8790
inline Configuration& addAppender(
8891
std::shared_ptr<IAppender> appender,
@@ -95,7 +98,8 @@ class CORE_API Configuration {
9598

9699
/**
97100
* @brief Gets the appenders from the configuration.
98-
* @return The appenders and belonging log levels.
101+
*
102+
* @return The appenders and their log levels.
99103
*/
100104
inline const AppenderList& getAppenders() const;
101105

olp-cpp-sdk-core/include/olp/core/logging/ConsoleAppender.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,28 @@
2828
namespace olp {
2929
namespace logging {
3030
/**
31-
* @brief Appender for printing to the console.
31+
* @brief An appender that prints messages to the console.
3232
*/
3333
class CORE_API ConsoleAppender : public IAppender {
3434
public:
3535
/**
36-
* @brief Constructs this with the message formatter.
36+
* @brief Creates a `ConsoleAppender` instance with a message formatter.
37+
*
3738
* @param formatter The message formatter.
3839
*/
3940
inline explicit ConsoleAppender(
4041
MessageFormatter formatter = MessageFormatter::createDefault());
4142

4243
/**
4344
* @brief Gets the message formatter.
45+
*
4446
* @return The message formatter.
4547
*/
4648
inline const MessageFormatter& getMessageFormatter() const;
4749

4850
/**
4951
* @brief Sets the message formatter.
52+
*
5053
* @param formatter The message formatter.
5154
*/
5255
inline ConsoleAppender& setMessageFormatter(MessageFormatter formatter);

olp-cpp-sdk-core/include/olp/core/logging/DebugAppender.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
namespace olp {
2626
namespace logging {
2727
/**
28-
* @brief Appender for printing to the debug output.
28+
* @brief An appender that prints messages to the debug output.
2929
*/
3030
class CORE_API DebugAppender : public IAppender {
3131
public:
3232
/**
33-
* @brief Returns whether or not the debug appender is implemented for this
34-
* platform.
35-
* @return Whether or not this is implemented.
33+
* @brief Checks whether this platform has the debug appender implemented.
34+
*
35+
* @return True if this platform has the debug appender; false otherwise.
3636
*/
3737
static bool isImplemented();
3838

olp-cpp-sdk-core/include/olp/core/logging/FileAppender.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@
3030
namespace olp {
3131
namespace logging {
3232
/**
33-
* @brief Appender for printing to a file.
33+
* @brief An appender that prints messages to a file.
3434
*/
3535
class CORE_API FileAppender : public IAppender {
3636
public:
3737
/**
38-
* @brief Constructs a file appender.
38+
* @brief Creates a `FileAppender` instance.
39+
*
3940
* @param fileName The name of the file to write to.
40-
* @param append True to append to an existing file if it exists.
41+
* @param append True to append to an existing file; false otherwise.
4142
* @param formatter The message formatter.
4243
*/
4344
explicit FileAppender(
@@ -46,31 +47,36 @@ class CORE_API FileAppender : public IAppender {
4647
~FileAppender() override;
4748

4849
/**
49-
* @brief Returns whether or not the stream is opened and can be written to.
50-
* @return True if this is valid.
50+
* @brief Checks whether the stream is open and can be written to.
51+
*
52+
* @return True if the stream is open and can be written to; false otherwise.
5153
*/
5254
bool isValid() const;
5355

5456
/**
55-
* @brief Gets the name of the file this was created with.
57+
* @brief Gets the name of the file.
58+
*
5659
* @return The file name.
5760
*/
5861
inline const std::string& getFileName() const;
5962

6063
/**
61-
* @brief Returns whether or not the file is being appended to.
62-
* @return True if appending to the file.
64+
* @brief Checks whether the file has the appender.
65+
*
66+
* @return True if the file has the appender; false otherwise.
6367
*/
6468
inline bool getAppendFile() const;
6569

6670
/**
6771
* @brief Gets the message formatter.
72+
*
6873
* @return The message formatter.
6974
*/
7075
inline const MessageFormatter& getMessageFormatter() const;
7176

7277
/**
7378
* @brief Sets the message formatter.
79+
*
7480
* @param formatter The message formatter.
7581
*/
7682
inline FileAppender& setMessageFormatter(MessageFormatter formatter);

olp-cpp-sdk-core/include/olp/core/logging/FilterGroup.h

Lines changed: 56 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -33,98 +33,120 @@
3333
namespace olp {
3434
namespace logging {
3535
/**
36-
* @brief Class that groups together log levels for different tags. This makes
37-
* it easier to apply groups of level filters together.
36+
* @brief Groups together log levels for different tags.
37+
*
38+
* It helps to apply groups of level filters together.
3839
*/
3940
class CORE_API FilterGroup {
4041
public:
4142
inline FilterGroup();
43+
44+
/// The default copy constructor.
4245
FilterGroup(const FilterGroup&) = default;
46+
47+
/// The default copy assignment operator.
4348
FilterGroup& operator=(const FilterGroup&) = default;
49+
50+
/// The default move constructor.
4451
inline FilterGroup(FilterGroup&& other) noexcept;
52+
53+
/// The default move assignment operator.
4554
inline FilterGroup& operator=(FilterGroup&& other) noexcept;
4655

4756
/**
4857
* @brief Gets the default log level.
49-
* @return The default log level, or boost::none if not set.
58+
*
59+
* @return The default log level or `boost::none` if the level is not set.
5060
*/
5161
inline boost::optional<Level> getLevel() const;
5262

5363
/**
5464
* @brief Sets the default log level.
65+
*
5566
* @param level The default log level.
5667
*/
5768
inline FilterGroup& setLevel(Level level);
5869

5970
/**
60-
* @brief Clears the default log level to be unset.
71+
* @brief Clears the default log level.
6172
*
62-
* Leaving the default log level unset prevents the default level in Log from
63-
* changing when the filter group is applied.
73+
* If the default log level is unset, it does not change
74+
* when the filter group is applied.
6475
*/
6576
inline FilterGroup& clearLevel();
6677

6778
/**
68-
* @brief Gets the log level for a tag
69-
* @param tag The tag to get the log level for.
70-
* @return The log level for the tag, or boost::none if not set.
79+
* @brief Gets the log level for a tag.
80+
*
81+
* @param tag The tag for which to get the log level.
82+
*
83+
* @return The log level for the tag, or `boost::none` if the level is not set.
7184
*/
7285
inline boost::optional<Level> getLevel(const std::string& tag) const;
7386

7487
/**
7588
* @brief Sets the log level for a tag.
89+
*
7690
* @param level The log level for a tag.
77-
* @param tag The tag to set the level for.
91+
* @param tag The tag for which to set the level.
7892
*/
7993
inline FilterGroup& setLevel(Level level, const std::string& tag);
8094

8195
/**
82-
* @brief Clears the log level to be unset for a tag.
96+
* @brief Clears the log level for a tag.
8397
*
84-
* Leaving the log level for a tag unset causes it to use the default log
85-
* level instead.
98+
* If the log level for a tag is unset, the default log
99+
* level is used instead.
86100
*/
87101
inline FilterGroup& clearLevel(const std::string& tag);
88102

89103
/**
90-
* @brief Clears the filter group to be unset.
104+
* @brief Clears the filter group.
91105
*/
92106
inline FilterGroup& clear();
93107

94108
/**
95109
* @brief Loads the filter group from a file.
96-
* @param fileName The file to load the configuration from.
97-
* @return Whether or not the load was successful. If unsuccessful, this will
98-
* be cleared.
110+
*
111+
* @param fileName The file from which to load the configuration.
112+
*
113+
* @return True if the load was successful; false otherwise. If unsuccessful,
114+
* this is cleared.
99115
*/
100116
bool load(const std::string& fileName);
101117

102118
/**
103119
* @brief Loads the filter group from a stream.
104120
*
105-
* The stream is expected contain text data. The format is as follows:
106-
* - Blank lines, or lines that start with # are ignored.
107-
* - Setting the log level for the tag is of the format "tag: level". For
108-
* example:
109-
* - mylib: warning
110-
* - theirlib: info
111-
* - otherlib: off
112-
* - Setting the default log level is of the format ": level". For
113-
* example: ": error"
114-
* - Whitespace is trimmed and case is ignored for the levels.
121+
* The stream should contain text data.
122+
* The format of the stream:
123+
* - Blank lines or lines that start with "#" are ignored.
124+
* - Use the following format for tag log levels: `tag: level`.
125+
* For example:
126+
* - `mylib: warning`
127+
* - `theirlib: info`
128+
* - `otherlib: off`
129+
* - Use the following format for the default log level: `: level`.
130+
* For example: `: error`
131+
* - Whitespaces are trimmed.
132+
* - The case is ignored for levels.
115133
*
116-
* The filter group will be cleared before the contents of the stream are
134+
* The filter groups are cleared before the content of the stream is
117135
* applied.
118-
* @param stream The stream to load the configuration from.
119-
* @return Whether or not the load was successful. If unsuccessful, this will
120-
* be cleared.
136+
*
137+
* @param stream The stream from which to load the configuration.
138+
*
139+
* @return True if the load was successful; false otherwise. If unsuccessful,
140+
* this is cleared.
121141
*/
122142
bool load(std::istream& stream);
123143

124144
/**
125-
* @brief Converts string logging level to enum Level format.
126-
* @param levelStr string level to convert.
127-
* @return Converted level
145+
* @brief Converts the string log level to the enum level format.
146+
*
147+
* @param levelStr The string level to convert.
148+
*
149+
* @return The converted level.
128150
*/
129151
static boost::optional<Level> stringToLevel(const std::string& levelStr);
130152

0 commit comments

Comments
 (0)