mirror of https://github.com/gabime/spdlog.git
Merge branch 'static-lib' of https://github.com/gabime/spdlog into static-lib
commit
92387b1527
@ -1,31 +0,0 @@
|
|||||||
CXX ?= g++
|
|
||||||
CXXFLAGS = -march=native -Wall -Wextra -pedantic -Wconversion -std=c++11 -pthread -I../include -fmax-errors=1
|
|
||||||
CXX_RELEASE_FLAGS = -O3 -flto -Wl,--no-as-needed
|
|
||||||
|
|
||||||
|
|
||||||
binaries=bench async_bench latency formatter-bench
|
|
||||||
|
|
||||||
all: $(binaries)
|
|
||||||
|
|
||||||
bench: bench.cpp
|
|
||||||
$(CXX) bench.cpp -o bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
async_bench: async_bench.cpp
|
|
||||||
$(CXX) async_bench.cpp -o async_bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
latency: latency.cpp
|
|
||||||
$(CXX) latency.cpp -o latency $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -lbenchmark
|
|
||||||
|
|
||||||
|
|
||||||
formatter-bench: formatter-bench.cpp
|
|
||||||
$(CXX) formatter-bench.cpp -o formatter-bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -lbenchmark
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o logs/* latecy_logs $(binaries)
|
|
||||||
|
|
||||||
rebuild: clean all
|
|
@ -1,21 +0,0 @@
|
|||||||
CXX ?= g++
|
|
||||||
CXX_FLAGS = -Wall -Wextra -pedantic -std=c++11 -pthread -I../include -fmax-errors=1 -Wconversion
|
|
||||||
CXX_RELEASE_FLAGS = -O3 -march=native
|
|
||||||
CXX_DEBUG_FLAGS= -g
|
|
||||||
|
|
||||||
all: example
|
|
||||||
debug: example-debug
|
|
||||||
|
|
||||||
example: example.cpp
|
|
||||||
$(CXX) example.cpp -o example $(CXX_FLAGS) $(CXX_RELEASE_FLAGS) $(CXXFLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
example-debug: example.cpp
|
|
||||||
$(CXX) example.cpp -o example-debug $(CXX_FLAGS) $(CXX_DEBUG_FLAGS) $(CXXFLAGS)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o logs/*.txt example example-debug
|
|
||||||
|
|
||||||
|
|
||||||
rebuild: clean all
|
|
||||||
rebuild-debug: clean debug
|
|
@ -1,22 +0,0 @@
|
|||||||
#-Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded
|
|
||||||
CXX ?= g++
|
|
||||||
CXX_FLAGS = -Wall -Wextra -pedantic -std=c++11 -pthread -I../include -fmax-errors=1 -Wconversion -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-weak-vtables -Wno-global-constructors
|
|
||||||
CXX_RELEASE_FLAGS = -O3 -march=native
|
|
||||||
CXX_DEBUG_FLAGS= -g
|
|
||||||
|
|
||||||
all: example
|
|
||||||
debug: example-debug
|
|
||||||
|
|
||||||
example: example.cpp
|
|
||||||
$(CXX) example.cpp -o example $(CXX_FLAGS) $(CXX_RELEASE_FLAGS) $(CXXFLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
example-debug: example.cpp
|
|
||||||
$(CXX) example.cpp -o example-debug $(CXX_FLAGS) $(CXX_DEBUG_FLAGS) $(CXXFLAGS)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o logs/*.txt example example-debug
|
|
||||||
|
|
||||||
|
|
||||||
rebuild: clean all
|
|
||||||
rebuild-debug: clean debug
|
|
@ -1,26 +0,0 @@
|
|||||||
CXX = clang++
|
|
||||||
CXXFLAGS = -march=native -Wall -Wextra -Wshadow -pedantic -std=c++11 -pthread -I../include
|
|
||||||
CXX_RELEASE_FLAGS = -O2
|
|
||||||
CXX_DEBUG_FLAGS= -g
|
|
||||||
|
|
||||||
|
|
||||||
all: example
|
|
||||||
debug: example-debug
|
|
||||||
|
|
||||||
example: example.cpp
|
|
||||||
$(CXX) example.cpp -o example-clang $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
example-debug: example.cpp
|
|
||||||
$(CXX) example.cpp -o example-clang-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o logs/*.txt example-clang example-clang-debug
|
|
||||||
|
|
||||||
|
|
||||||
rebuild: clean all
|
|
||||||
rebuild-debug: clean debug
|
|
||||||
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
|||||||
CXX ?= g++
|
|
||||||
CXXFLAGS = -D_WIN32_WINNT=0x600 -march=native -Wall -Wextra -pedantic -std=gnu++0x -pthread -Wl,--no-as-needed -I../include
|
|
||||||
CXX_RELEASE_FLAGS = -O3
|
|
||||||
CXX_DEBUG_FLAGS= -g
|
|
||||||
|
|
||||||
|
|
||||||
all: example
|
|
||||||
debug: example-debug
|
|
||||||
|
|
||||||
example: example.cpp
|
|
||||||
$(CXX) example.cpp -o example $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
example-debug: example.cpp
|
|
||||||
$(CXX) example.cpp -o example-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o logs/*.txt example example-debug
|
|
||||||
|
|
||||||
|
|
||||||
rebuild: clean all
|
|
||||||
rebuild-debug: clean debug
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
|||||||
|
// Copyright(c) 2015-present Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef SPDLOG_HEADER_ONLY
|
||||||
|
#include "spdlog/sinks/basic_file_sink.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "spdlog/common.h"
|
||||||
|
#include "spdlog/details/os.h"
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace sinks {
|
||||||
|
|
||||||
|
template<typename Mutex>
|
||||||
|
SPDLOG_INLINE basic_file_sink<Mutex>::basic_file_sink(const filename_t &filename, bool truncate)
|
||||||
|
{
|
||||||
|
file_helper_.open(filename, truncate);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Mutex>
|
||||||
|
SPDLOG_INLINE const filename_t &basic_file_sink<Mutex>::filename() const
|
||||||
|
{
|
||||||
|
return file_helper_.filename();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Mutex>
|
||||||
|
SPDLOG_INLINE void basic_file_sink<Mutex>::sink_it_(const details::log_msg &msg)
|
||||||
|
{
|
||||||
|
fmt::memory_buffer formatted;
|
||||||
|
sink::formatter_->format(msg, formatted);
|
||||||
|
file_helper_.write(formatted);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Mutex>
|
||||||
|
SPDLOG_INLINE void basic_file_sink<Mutex>::flush_()
|
||||||
|
{
|
||||||
|
file_helper_.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace sinks
|
||||||
|
} // namespace spdlog
|
@ -0,0 +1,100 @@
|
|||||||
|
// Copyright(c) 2015-present Gabi Melman & spdlog contributors.
|
||||||
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef SPDLOG_HEADER_ONLY
|
||||||
|
#include "spdlog/spdlog.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#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
|
@ -1,22 +0,0 @@
|
|||||||
CXX ?= g++
|
|
||||||
CXXFLAGS = -Wall -pedantic -std=c++11 -pthread -Wconversion -O3 -I../include -fmax-errors=1
|
|
||||||
LDPFALGS = -pthread -lsystemd
|
|
||||||
|
|
||||||
CPP_FILES := $(wildcard *.cpp)
|
|
||||||
OBJ_FILES := $(addprefix ./,$(notdir $(CPP_FILES:.cpp=.o)))
|
|
||||||
|
|
||||||
|
|
||||||
tests: $(OBJ_FILES)
|
|
||||||
$(CXX) $(CXXFLAGS) $(LDPFALGS) -o $@ $^
|
|
||||||
mkdir -p logs
|
|
||||||
|
|
||||||
%.o: %.cpp
|
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f tests *.o logs/*.txt
|
|
||||||
|
|
||||||
rebuild: clean tests
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="Source Files">
|
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
|
||||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Header Files">
|
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
||||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Resource Files">
|
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="file_log.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="main.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="registry.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="file_helper.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="utils.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="errors.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="test_macros.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="test_pattern_formatter.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="test_misc.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="test_async.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="includes.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="catch.hpp">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="utils.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup />
|
|
||||||
</Project>
|
|
Loading…
Reference in New Issue