mirror of https://github.com/gabime/spdlog.git
clang format and SPLDOG_HEADER_ONLY macro
parent
540f865355
commit
6bcb422c80
@ -1,23 +1,53 @@
|
|||||||
// Copyright(c) 2015-present Gabi Melman & spdlog contributors.
|
// Copyright(c) 2015-present Gabi Melman & spdlog contributors.
|
||||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace level {
|
||||||
|
static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES;
|
||||||
|
|
||||||
SPDLOG_INLINE spdlog::spdlog_ex::spdlog_ex(std::string msg)
|
static const char *short_level_names[] SPDLOG_SHORT_LEVEL_NAMES;
|
||||||
: msg_(std::move(msg))
|
|
||||||
|
SPDLOG_INLINE string_view_t &to_string_view(spdlog::level::level_enum l) SPDLOG_NOEXCEPT
|
||||||
|
{
|
||||||
|
return level_string_views[l];
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDLOG_INLINE const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT
|
||||||
{
|
{
|
||||||
|
return short_level_names[l];
|
||||||
}
|
}
|
||||||
|
|
||||||
SPDLOG_INLINE spdlog::spdlog_ex::spdlog_ex(const std::string &msg, int last_errno)
|
SPDLOG_INLINE spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT
|
||||||
|
{
|
||||||
|
int level = 0;
|
||||||
|
for (const auto &level_str : level_string_views)
|
||||||
|
{
|
||||||
|
if (level_str == name)
|
||||||
|
{
|
||||||
|
return static_cast<level::level_enum>(level);
|
||||||
|
}
|
||||||
|
level++;
|
||||||
|
}
|
||||||
|
return level::off;
|
||||||
|
}
|
||||||
|
} // namespace level
|
||||||
|
|
||||||
|
SPDLOG_INLINE spdlog_ex::spdlog_ex(std::string msg)
|
||||||
|
: msg_(std::move(msg))
|
||||||
|
{}
|
||||||
|
|
||||||
|
SPDLOG_INLINE spdlog_ex::spdlog_ex(const std::string &msg, int last_errno)
|
||||||
{
|
{
|
||||||
fmt::memory_buffer outbuf;
|
fmt::memory_buffer outbuf;
|
||||||
fmt::format_system_error(outbuf, last_errno, msg);
|
fmt::format_system_error(outbuf, last_errno, msg);
|
||||||
msg_ = fmt::to_string(outbuf);
|
msg_ = fmt::to_string(outbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
SPDLOG_INLINE const char *spdlog::spdlog_ex::what() const SPDLOG_NOEXCEPT
|
SPDLOG_INLINE const char *spdlog_ex::what() const SPDLOG_NOEXCEPT
|
||||||
{
|
{
|
||||||
return msg_.c_str();
|
return msg_.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace spdlog
|
||||||
|
@ -1,65 +0,0 @@
|
|||||||
// Copyright (c) 2012 - 2016, Victor Zverovich
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// For the license information refer to format.h.
|
|
||||||
|
|
||||||
|
|
||||||
// Slightly modified version of fmt lib to include bundled format-inl.h
|
|
||||||
|
|
||||||
|
|
||||||
#if !defined(SPDLOG_FMT_EXTERNAL)
|
|
||||||
#include "spdlog/fmt/bundled/format-inl.h"
|
|
||||||
#else
|
|
||||||
#include "fmt/format-inl.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FMT_BEGIN_NAMESPACE
|
|
||||||
template struct internal::basic_data<void>;
|
|
||||||
template FMT_API internal::locale_ref::locale_ref(const std::locale &loc);
|
|
||||||
template FMT_API std::locale internal::locale_ref::get<std::locale>() const;
|
|
||||||
|
|
||||||
// Explicit instantiations for char.
|
|
||||||
|
|
||||||
template FMT_API char internal::thousands_sep_impl(locale_ref);
|
|
||||||
|
|
||||||
template FMT_API void internal::basic_buffer<char>::append(const char *, const char *);
|
|
||||||
|
|
||||||
template FMT_API void internal::arg_map<format_context>::init(
|
|
||||||
const basic_format_args<format_context> &args);
|
|
||||||
|
|
||||||
template FMT_API int internal::char_traits<char>::format_float(
|
|
||||||
char *, std::size_t, const char *, int, double);
|
|
||||||
|
|
||||||
template FMT_API int internal::char_traits<char>::format_float(
|
|
||||||
char *, std::size_t, const char *, int, long double);
|
|
||||||
|
|
||||||
template FMT_API std::string internal::vformat<char>(
|
|
||||||
string_view, basic_format_args<format_context>);
|
|
||||||
|
|
||||||
template FMT_API format_context::iterator internal::vformat_to(
|
|
||||||
internal::buffer &, string_view, basic_format_args<format_context>);
|
|
||||||
|
|
||||||
template FMT_API void internal::sprintf_format(
|
|
||||||
double, internal::buffer &, core_format_specs);
|
|
||||||
template FMT_API void internal::sprintf_format(
|
|
||||||
long double, internal::buffer &, core_format_specs);
|
|
||||||
|
|
||||||
// Explicit instantiations for wchar_t.
|
|
||||||
|
|
||||||
template FMT_API wchar_t internal::thousands_sep_impl(locale_ref);
|
|
||||||
|
|
||||||
template FMT_API void internal::basic_buffer<wchar_t>::append(
|
|
||||||
const wchar_t *, const wchar_t *);
|
|
||||||
|
|
||||||
template FMT_API void internal::arg_map<wformat_context>::init(
|
|
||||||
const basic_format_args<wformat_context> &);
|
|
||||||
|
|
||||||
template FMT_API int internal::char_traits<wchar_t>::format_float(
|
|
||||||
wchar_t *, std::size_t, const wchar_t *, int, double);
|
|
||||||
|
|
||||||
template FMT_API int internal::char_traits<wchar_t>::format_float(
|
|
||||||
wchar_t *, std::size_t, const wchar_t *, int, long double);
|
|
||||||
|
|
||||||
template FMT_API std::wstring internal::vformat<wchar_t>(
|
|
||||||
wstring_view, basic_format_args<wformat_context>);
|
|
||||||
FMT_END_NAMESPACE
|
|
@ -0,0 +1,51 @@
|
|||||||
|
// Copyright (c) 2012 - 2016, Victor Zverovich
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// For the license information refer to format.h.
|
||||||
|
|
||||||
|
// Slightly modified version of fmt lib to include bundled format-inl.h
|
||||||
|
|
||||||
|
#if !defined(SPDLOG_FMT_EXTERNAL)
|
||||||
|
#include "spdlog/fmt/bundled/format-inl.h"
|
||||||
|
#else
|
||||||
|
#include "fmt/format-inl.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FMT_BEGIN_NAMESPACE
|
||||||
|
template struct internal::basic_data<void>;
|
||||||
|
template FMT_API internal::locale_ref::locale_ref(const std::locale &loc);
|
||||||
|
template FMT_API std::locale internal::locale_ref::get<std::locale>() const;
|
||||||
|
|
||||||
|
// Explicit instantiations for char.
|
||||||
|
|
||||||
|
template FMT_API char internal::thousands_sep_impl(locale_ref);
|
||||||
|
|
||||||
|
template FMT_API void internal::basic_buffer<char>::append(const char *, const char *);
|
||||||
|
|
||||||
|
template FMT_API void internal::arg_map<format_context>::init(const basic_format_args<format_context> &args);
|
||||||
|
|
||||||
|
template FMT_API int internal::char_traits<char>::format_float(char *, std::size_t, const char *, int, double);
|
||||||
|
|
||||||
|
template FMT_API int internal::char_traits<char>::format_float(char *, std::size_t, const char *, int, long double);
|
||||||
|
|
||||||
|
template FMT_API std::string internal::vformat<char>(string_view, basic_format_args<format_context>);
|
||||||
|
|
||||||
|
template FMT_API format_context::iterator internal::vformat_to(internal::buffer &, string_view, basic_format_args<format_context>);
|
||||||
|
|
||||||
|
template FMT_API void internal::sprintf_format(double, internal::buffer &, core_format_specs);
|
||||||
|
template FMT_API void internal::sprintf_format(long double, internal::buffer &, core_format_specs);
|
||||||
|
|
||||||
|
// Explicit instantiations for wchar_t.
|
||||||
|
|
||||||
|
template FMT_API wchar_t internal::thousands_sep_impl(locale_ref);
|
||||||
|
|
||||||
|
template FMT_API void internal::basic_buffer<wchar_t>::append(const wchar_t *, const wchar_t *);
|
||||||
|
|
||||||
|
template FMT_API void internal::arg_map<wformat_context>::init(const basic_format_args<wformat_context> &);
|
||||||
|
|
||||||
|
template FMT_API int internal::char_traits<wchar_t>::format_float(wchar_t *, std::size_t, const wchar_t *, int, double);
|
||||||
|
|
||||||
|
template FMT_API int internal::char_traits<wchar_t>::format_float(wchar_t *, std::size_t, const wchar_t *, int, long double);
|
||||||
|
|
||||||
|
template FMT_API std::wstring internal::vformat<wchar_t>(wstring_view, basic_format_args<wformat_context>);
|
||||||
|
FMT_END_NAMESPACE
|
Loading…
Reference in New Issue