Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gabime/spdlog.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgabime <gmelman1@gmail.com>2019-09-05 18:51:28 +0300
committergabime <gmelman1@gmail.com>2019-09-05 18:51:28 +0300
commit7f0398ca25b4505dc83620a505fdada940f28d99 (patch)
tree6f5320670996f04aa4eaf8766ae75933468748a7
parentd7f05722d428997ee00b1b93a30748a7e61236f8 (diff)
Added version() function
-rw-r--r--example/example.cpp2
-rw-r--r--include/spdlog/spdlog-inl.h5
-rw-r--r--include/spdlog/spdlog.h5
-rw-r--r--src/file_sinks.cpp3
4 files changed, 13 insertions, 2 deletions
diff --git a/example/example.cpp b/example/example.cpp
index 2a18677a..b2d9e3f6 100644
--- a/example/example.cpp
+++ b/example/example.cpp
@@ -22,7 +22,7 @@ void syslog_example();
int main(int, char *[])
{
- spdlog::info("Welcome to spdlog version {}.{}.{} !", SPDLOG_VER_MAJOR, SPDLOG_VER_MINOR, SPDLOG_VER_PATCH);
+ spdlog::info("Welcome to spdlog version {} !", spdlog::version());
spdlog::warn("Easy padding in numbers like {:08d}", 12);
spdlog::critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
spdlog::info("Support for floats {:03.2f}", 1.23456);
diff --git a/include/spdlog/spdlog-inl.h b/include/spdlog/spdlog-inl.h
index bbfb6e24..5b408678 100644
--- a/include/spdlog/spdlog-inl.h
+++ b/include/spdlog/spdlog-inl.h
@@ -112,4 +112,9 @@ SPDLOG_INLINE void set_default_logger(std::shared_ptr<spdlog::logger> default_lo
details::registry::instance().set_default_logger(std::move(default_logger));
}
+SPDLOG_INLINE std::string version()
+{
+ return fmt::format("{}.{}.{}", SPDLOG_VER_MAJOR, SPDLOG_VER_MINOR, SPDLOG_VER_PATCH);
+}
+
} // namespace spdlog \ No newline at end of file
diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h
index 3638ba12..96b6aabf 100644
--- a/include/spdlog/spdlog.h
+++ b/include/spdlog/spdlog.h
@@ -15,6 +15,7 @@
#include "spdlog/version.h"
#include "spdlog/details/synchronous_factory.h"
+
#include <chrono>
#include <functional>
#include <memory>
@@ -102,6 +103,10 @@ void shutdown();
// Automatic registration of loggers when using spdlog::create() or spdlog::create_async
void set_automatic_registration(bool automatic_registation);
+// return spdlog version
+std::string version();
+
+
// API for using default logger (stdout_color_mt),
// e.g: spdlog::info("Message {}", 1);
//
diff --git a/src/file_sinks.cpp b/src/file_sinks.cpp
index 3c0bd912..48adeb3c 100644
--- a/src/file_sinks.cpp
+++ b/src/file_sinks.cpp
@@ -5,12 +5,13 @@
#error Please define SPDLOG_COMPILED_LIB to compile this file.
#endif
-
#include <mutex>
#include "spdlog/sinks/base_sink.h"
#include "spdlog/details/null_mutex.h"
+
#include "spdlog/details/file_helper-inl.h"
#include "spdlog/sinks/base_sink-inl.h"
+
template class spdlog::sinks::base_sink<std::mutex>;
template class spdlog::sinks::base_sink<spdlog::details::null_mutex>;