Skip to content

Commit

Permalink
feat: Update Logger and BaseComponent to return tag/name as const…
Browse files Browse the repository at this point in the history
… ref (#245)

* feat: Update `Logger` and `BaseComponent` to return tag/name as const ref

* fix sa
  • Loading branch information
finger563 authored May 28, 2024
1 parent bfe9f28 commit c9f236c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions components/base_component/include/base_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ namespace espp {
class BaseComponent {
public:
/// Get the name of the component
/// \return The name of the component
/// \return A const reference to the name of the component
/// \note This is the tag of the logger
std::string get_name() { return logger_.get_tag(); }
const std::string &get_name() const { return logger_.get_tag(); }

/// Set the tag for the logger
/// \param tag The tag to use for the logger
Expand Down
7 changes: 2 additions & 5 deletions components/logger/include/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,9 @@ class Logger {

/**
* @brief Get the current tag for the logger.
* @return The current tag.
* @return A const reference to the current tag.
*/
std::string get_tag() {
std::lock_guard<std::mutex> lock(tag_mutex_);
return tag_;
}
const std::string &get_tag() const { return tag_; }

/**
* @brief Whether to include the time in the log.
Expand Down

0 comments on commit c9f236c

Please sign in to comment.