Skip to content

Commit

Permalink
Ported pull #3023 with some changes and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gabime committed Mar 16, 2024
1 parent 167bf98 commit 8e10782
Show file tree
Hide file tree
Showing 5 changed files with 240 additions and 192 deletions.
3 changes: 3 additions & 0 deletions include/spdlog/details/registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <memory>
#include <mutex>
#include <string>
#include <string_view>
#include <unordered_map>

#include "../common.h"
Expand All @@ -35,6 +36,8 @@ class SPDLOG_API registry {
void register_logger(std::shared_ptr<logger> new_logger);
void initialize_logger(std::shared_ptr<logger> new_logger);
std::shared_ptr<logger> get(const std::string &logger_name);
std::shared_ptr<logger> get(std::string_view logger_name);
std::shared_ptr<logger> get(const char *logger_name);
std::shared_ptr<logger> default_logger();

// Return raw ptr to the default logger.
Expand Down
3 changes: 3 additions & 0 deletions include/spdlog/spdlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <memory>
#include <mutex>
#include <string>
#include <string_view>

#include "./common.h"
#include "./details/registry.h"
Expand Down Expand Up @@ -50,6 +51,8 @@ SPDLOG_API void initialize_logger(std::shared_ptr<logger> logger);
// exist.
// example: spdlog::get("my_logger")->info("hello {}", "world");
SPDLOG_API std::shared_ptr<logger> get(const std::string &name);
SPDLOG_API std::shared_ptr<logger> get(std::string_view name);
SPDLOG_API std::shared_ptr<logger> get(const char *name);

// Set global formatter. Each sink in each logger will get a clone of this object
SPDLOG_API void set_formatter(std::unique_ptr<spdlog::formatter> formatter);
Expand Down
Loading

0 comments on commit 8e10782

Please sign in to comment.