Commit d5c9bac3 authored by gabime's avatar gabime

wip static-lib

parent 5220ac4a
......@@ -2,7 +2,6 @@
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
// spdlog usage example
#include <cstdio>
......
......@@ -11,6 +11,7 @@
#include "spdlog/details/null_mutex.h"
#include "spdlog/fmt/fmt.h"
#include "spdlog/sinks/base_sink.h"
#include "spdlog/details/os.h"
#include <chrono>
#include <cstdio>
......
......@@ -9,6 +9,7 @@
#include "spdlog/details/console_globals.h"
#include "spdlog/details/null_mutex.h"
#include "spdlog/details/pattern_formatter.h"
#include <cstdio>
#include <memory>
......
......@@ -100,5 +100,5 @@ void SPDLOG_INLINE wincolor_sink<TargetStream, ConsoleMutex>::print_range_(const
::WriteConsoleA(out_handle_, formatted.data() + start, size, nullptr, nullptr);
}
}
} // namespace sinks
} // namespace spdlog
\ No newline at end of file
......@@ -48,7 +48,6 @@ public:
void set_pattern(const std::string &pattern) override final;
void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) override final;
private:
using mutex_t = typename ConsoleMutex::mutex_t;
HANDLE out_handle_;
......
// Copyright(c) 2015-present Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#include "spdlog/common.h"
#include "spdlog/details/pattern_formatter.h"
namespace spdlog {
SPDLOG_INLINE void initialize_logger(std::shared_ptr<logger> logger)
{
details::registry::instance().initialize_logger(std::move(logger));
}
SPDLOG_INLINE std::shared_ptr<logger> get(const std::string &name)
{
return details::registry::instance().get(name);
}
SPDLOG_INLINE void set_formatter(std::unique_ptr<spdlog::formatter> formatter)
{
details::registry::instance().set_formatter(std::move(formatter));
}
SPDLOG_INLINE void set_pattern(std::string pattern, pattern_time_type time_type)
{
set_formatter(std::unique_ptr<spdlog::formatter>(new pattern_formatter(std::move(pattern), time_type)));
}
SPDLOG_INLINE void set_level(level::level_enum log_level)
{
details::registry::instance().set_level(log_level);
}
SPDLOG_INLINE void flush_on(level::level_enum log_level)
{
details::registry::instance().flush_on(log_level);
}
SPDLOG_INLINE void flush_every(std::chrono::seconds interval)
{
details::registry::instance().flush_every(interval);
}
SPDLOG_INLINE void set_error_handler(void (*handler)(const std::string &msg))
{
details::registry::instance().set_error_handler(handler);
}
SPDLOG_INLINE void register_logger(std::shared_ptr<logger> logger)
{
details::registry::instance().register_logger(std::move(logger));
}
SPDLOG_INLINE void apply_all(const std::function<void(std::shared_ptr<logger>)> &fun)
{
details::registry::instance().apply_all(fun);
}
SPDLOG_INLINE void drop(const std::string &name)
{
details::registry::instance().drop(name);
}
SPDLOG_INLINE void drop_all()
{
details::registry::instance().drop_all();
}
SPDLOG_INLINE void shutdown()
{
details::registry::instance().shutdown();
}
SPDLOG_INLINE void set_automatic_registration(bool automatic_registation)
{
details::registry::instance().set_automatic_registration(automatic_registation);
}
SPDLOG_INLINE std::shared_ptr<spdlog::logger> default_logger()
{
return details::registry::instance().default_logger();
}
SPDLOG_INLINE spdlog::logger *default_logger_raw()
{
return details::registry::instance().get_default_raw();
}
SPDLOG_INLINE void set_default_logger(std::shared_ptr<spdlog::logger> default_logger)
{
details::registry::instance().set_default_logger(std::move(default_logger));
}
} // namespace spdlog
\ No newline at end of file
......@@ -11,7 +11,6 @@
#include "spdlog/common.h"
#include "spdlog/details/registry.h"
#include "spdlog/details/pattern_formatter.h"
#include "spdlog/logger.h"
#include "spdlog/version.h"
......@@ -58,94 +57,52 @@ inline std::shared_ptr<spdlog::logger> create(std::string logger_name, SinkArgs
// auto console_sink = std::make_shared<spdlog::sinks::stdout_sink_mt>();
// auto console_logger = std::make_shared<spdlog::logger>("console_logger", console_sink);
// spdlog::initialize_logger(console_logger);
inline void initialize_logger(std::shared_ptr<logger> logger)
{
details::registry::instance().initialize_logger(std::move(logger));
}
void initialize_logger(std::shared_ptr<logger> logger);
// Return an existing logger or nullptr if a logger with such name doesn't
// exist.
// example: spdlog::get("my_logger")->info("hello {}", "world");
inline std::shared_ptr<logger> get(const std::string &name)
{
return details::registry::instance().get(name);
}
std::shared_ptr<logger> get(const std::string &name);
// Set global formatter. Each sink in each logger will get a clone of this object
inline void set_formatter(std::unique_ptr<spdlog::formatter> formatter)
{
details::registry::instance().set_formatter(std::move(formatter));
}
void set_formatter(std::unique_ptr<spdlog::formatter> formatter);
// Set global format string.
// example: spdlog::set_pattern("%Y-%m-%d %H:%M:%S.%e %l : %v");
inline void set_pattern(std::string pattern, pattern_time_type time_type = pattern_time_type::local)
{
set_formatter(std::unique_ptr<spdlog::formatter>(new pattern_formatter(std::move(pattern), time_type)));
}
void set_pattern(std::string pattern, pattern_time_type time_type = pattern_time_type::local);
// Set global logging level
inline void set_level(level::level_enum log_level)
{
details::registry::instance().set_level(log_level);
}
void set_level(level::level_enum log_level);
// Set global flush level
inline void flush_on(level::level_enum log_level)
{
details::registry::instance().flush_on(log_level);
}
void flush_on(level::level_enum log_level);
// Start/Restart a periodic flusher thread
// Warning: Use only if all your loggers are thread safe!
inline void flush_every(std::chrono::seconds interval)
{
details::registry::instance().flush_every(interval);
}
void flush_every(std::chrono::seconds interval);
// Set global error handler
inline void set_error_handler(void (*handler)(const std::string &msg))
{
details::registry::instance().set_error_handler(handler);
}
void set_error_handler(void (*handler)(const std::string &msg));
// Register the given logger with the given name
inline void register_logger(std::shared_ptr<logger> logger)
{
details::registry::instance().register_logger(std::move(logger));
}
void register_logger(std::shared_ptr<logger> logger);
// Apply a user defined function on all registered loggers
// Example:
// spdlog::apply_all([&](std::shared_ptr<spdlog::logger> l) {l->flush();});
inline void apply_all(const std::function<void(std::shared_ptr<logger>)> &fun)
{
details::registry::instance().apply_all(fun);
}
void apply_all(const std::function<void(std::shared_ptr<logger>)> &fun);
// Drop the reference to the given logger
inline void drop(const std::string &name)
{
details::registry::instance().drop(name);
}
void drop(const std::string &name);
// Drop all references from the registry
inline void drop_all()
{
details::registry::instance().drop_all();
}
void drop_all();
// stop any running threads started by spdlog and clean registry loggers
inline void shutdown()
{
details::registry::instance().shutdown();
}
void shutdown();
// Automatic registration of loggers when using spdlog::create() or spdlog::create_async
inline void set_automatic_registration(bool automatic_registation)
{
details::registry::instance().set_automatic_registration(automatic_registation);
}
void set_automatic_registration(bool automatic_registation);
// API for using default logger (stdout_color_mt),
// e.g: spdlog::info("Message {}", 1);
......@@ -162,20 +119,11 @@ inline void set_automatic_registration(bool automatic_registation)
// set_default_logger() *should not* be used concurrently with the default API.
// e.g do not call set_default_logger() from one thread while calling spdlog::info() from another.
inline std::shared_ptr<spdlog::logger> default_logger()
{
return details::registry::instance().default_logger();
}
std::shared_ptr<spdlog::logger> default_logger();
inline spdlog::logger *default_logger_raw()
{
return details::registry::instance().get_default_raw();
}
spdlog::logger *default_logger_raw();
inline void set_default_logger(std::shared_ptr<spdlog::logger> default_logger)
{
details::registry::instance().set_default_logger(std::move(default_logger));
}
void set_default_logger(std::shared_ptr<spdlog::logger> default_logger);
template<typename... Args>
inline void log(source_loc source, level::level_enum lvl, const char *fmt, const Args &... args)
......@@ -382,4 +330,8 @@ inline void critical(const wchar_t *fmt, const Args &... args)
#define SPDLOG_CRITICAL(...) (void)0
#endif
#ifdef SPDLOG_HEADER_ONLY
#include "spdlog-inl.h"
#endif
#endif // SPDLOG_H
......@@ -9,6 +9,8 @@
#include <chrono>
#include "spdlog/spdlog.h"
#include "spdlog/spdlog-inl.h"
#include "spdlog/async.h"
#include "spdlog/common.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment