diff --git a/Makefile b/Makefile deleted file mode 100644 index 261715b9..00000000 --- a/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -CC = g++ -CCFLAGS = -std=c++11 -pthread -Iinclude -O3 -flto - -all: testlog - -testlog: test.o lib - $(CC) -o testlog test.o libc11log.a $(CCFLAGS) - -lib: factory.o formatters.o line_logger.o os.o - ar rvs libc11log.a $^; - - -test.o: src/test.cpp - $(CC) -c -o $@ $^ $(CCFLAGS) - -factory.o: src/factory.cpp - $(CC) -c -o $@ $^ $(CCFLAGS) - -formatters.o: src/formatters.cpp - $(CC) -c -o $@ $^ $(CCFLAGS) - -line_logger.o: src/line_logger.cpp - $(CC) -c -o $@ $^ $(CCFLAGS) - -os.o: src/os.cpp - $(CC) -c -o $@ $^ $(CCFLAGS) - -.PHONY: clean -clean: - rm -f *.o libc11log.a testlog diff --git a/c11log.sln b/c11log.sln deleted file mode 100644 index 12cf0eaf..00000000 --- a/c11log.sln +++ /dev/null @@ -1,34 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30110.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c11log", "c11log.vcxproj", "{BBFA8622-1945-4EB0-BAF4-473BE753ED24}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcxproj", "{429A1E1E-6F89-4941-B4A7-7464CEA22587}" - ProjectSection(ProjectDependencies) = postProject - {BBFA8622-1945-4EB0-BAF4-473BE753ED24} = {BBFA8622-1945-4EB0-BAF4-473BE753ED24} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BBFA8622-1945-4EB0-BAF4-473BE753ED24}.Debug|Win32.ActiveCfg = Debug|Win32 - {BBFA8622-1945-4EB0-BAF4-473BE753ED24}.Debug|Win32.Build.0 = Debug|Win32 - {BBFA8622-1945-4EB0-BAF4-473BE753ED24}.Release|Win32.ActiveCfg = Release|Win32 - {BBFA8622-1945-4EB0-BAF4-473BE753ED24}.Release|Win32.Build.0 = Release|Win32 - {429A1E1E-6F89-4941-B4A7-7464CEA22587}.Debug|Win32.ActiveCfg = Debug|Win32 - {429A1E1E-6F89-4941-B4A7-7464CEA22587}.Debug|Win32.Build.0 = Debug|Win32 - {429A1E1E-6F89-4941-B4A7-7464CEA22587}.Release|Win32.ActiveCfg = Release|Win32 - {429A1E1E-6F89-4941-B4A7-7464CEA22587}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(Performance) = preSolution - HasPerformanceSessions = true - EndGlobalSection -EndGlobal diff --git a/c11log.v12.suo b/c11log.v12.suo deleted file mode 100644 index e9581de9..00000000 Binary files a/c11log.v12.suo and /dev/null differ diff --git a/c11log.vcxproj b/c11log.vcxproj deleted file mode 100644 index 6584ec34..00000000 --- a/c11log.vcxproj +++ /dev/null @@ -1,115 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {BBFA8622-1945-4EB0-BAF4-473BE753ED24} - Win32Proj - c11log - - - - StaticLibrary - true - v120 - Unicode - - - StaticLibrary - false - v120 - true - Unicode - - - - - - - - - - - - - $(ProjectDir)build\ - $(ProjectName)-debug - - - $(ProjectDir)build\ - $(ProjectName) - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - $(ProjectDir);$(ProjectDir)\include;%(AdditionalIncludeDirectories) - - - Windows - true - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - $(ProjectDir);$(ProjectDir)\include;%(AdditionalIncludeDirectories) - - - Windows - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - - - - - - \ No newline at end of file diff --git a/c11log.vcxproj.filters b/c11log.vcxproj.filters deleted file mode 100644 index 22e1df4f..00000000 --- a/c11log.vcxproj.filters +++ /dev/null @@ -1,102 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {3f3d8a51-d799-43e2-bd6e-3638f1cd4f54} - - - {d087c87d-8703-46a1-aa23-4509cf253e87} - - - {5af50a0f-d174-41cd-833c-ead8ba06199a} - - - {64fe6898-a191-4d60-9363-25ecfd196f30} - - - - - - - - Header Files - - - Header Files - - - Header Files\c11log - - - Header Files\c11log - - - Header Files\c11log\details - - - Header Files\c11log\formatters - - - Header Files\c11log\sinks - - - Header Files\c11log\sinks - - - Header Files\c11log\sinks - - - Header Files\c11log - - - Header Files\c11log\details - - - Header Files\c11log\details - - - Header Files\c11log\details - - - Header Files\c11log\details - - - Header Files\c11log\details - - - Header Files\c11log\sinks - - - Header Files\c11log\details - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/include/c11log/details/line_logger.h b/include/c11log/details/line_logger.h index 42c24a9b..e59b5684 100644 --- a/include/c11log/details/line_logger.h +++ b/include/c11log/details/line_logger.h @@ -9,8 +9,9 @@ namespace details { class line_logger { public: - c11log::details::line_logger::line_logger(logger* callback_logger, level::level_enum msg_level); - c11log::details::line_logger::line_logger(logger* callback_logger):_callback_logger(nullptr) {}; + line_logger(logger* callback_logger, level::level_enum msg_level); + line_logger(logger* callback_logger):_callback_logger(nullptr) {}; + line_logger(const line_logger&){}; ~line_logger(); template @@ -27,4 +28,4 @@ private: }; } //Namespace details -} // Namespace c11log \ No newline at end of file +} // Namespace c11log diff --git a/include/c11log/logger.h b/include/c11log/logger.h index 97f18b88..6b8f4b10 100644 --- a/include/c11log/logger.h +++ b/include/c11log/logger.h @@ -14,6 +14,8 @@ #include "details/factory.h" + + namespace c11log { class logger { diff --git a/include/c11log/sinks/base_sink.h b/include/c11log/sinks/base_sink.h index 21717a75..e46cfcd8 100644 --- a/include/c11log/sinks/base_sink.h +++ b/include/c11log/sinks/base_sink.h @@ -32,7 +32,7 @@ public: protected: virtual void sink_it_(const std::string& msg) = 0; - std::atomic _level = level::INFO; + std::atomic _level{level::INFO}; }; class null_sink:public base_sink { @@ -41,4 +41,4 @@ protected: {} }; } -} \ No newline at end of file +} diff --git a/include/c11log/sinks/file_sinks.h b/include/c11log/sinks/file_sinks.h index e17a07df..798c7c4a 100644 --- a/include/c11log/sinks/file_sinks.h +++ b/include/c11log/sinks/file_sinks.h @@ -150,9 +150,10 @@ private: static std::string _calc_filename(const std::string& basename, const std::string& extension) { std::ostringstream oss; - std::tm now_tm = c11log::details::os::localtime(); - oss << basename << std::put_time(&now_tm, ".%Y-%m-%d.") << extension; - return oss.str(); + std::tm tm = c11log::details::os::localtime(); + char buf[32]; + sprintf(buf, ".%Y-%m-%d.", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); + return buf; } std::string _base_filename; @@ -162,4 +163,4 @@ private: std::mutex mutex_; }; } -} \ No newline at end of file +} diff --git a/src/formatters.cpp b/src/formatters.cpp index ff384ac9..81900673 100644 --- a/src/formatters.cpp +++ b/src/formatters.cpp @@ -10,10 +10,10 @@ void c11log::formatters::format_time(const c11log::formatters::timepoint& tp, st int millis = static_cast(std::chrono::duration_cast(duration).count() % 1000); //std::put_time(&tm, "[ %Y-%m-%d %H:%M:%S ]") - seems too slow char buf[64]; - sprintf(buf, "[%d-%02d-%02d %02d:%02d:%02d.%03d]", + auto size = sprintf(buf, "[%d-%02d-%02d %02d:%02d:%02d.%03d]", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, millis); - dest << buf; + dest.write(buf, size); } void c11log::formatters::format_time(std::ostream& dest) @@ -33,4 +33,4 @@ std::string c11log::formatters::to_hex(const unsigned char* buf, std::size_t siz oss << _hex_chars[buf[i] & 0x0F]; } return oss.str(); -} \ No newline at end of file +} diff --git a/src/os.cpp b/src/os.cpp index 63956a9b..7fca8fc0 100644 --- a/src/os.cpp +++ b/src/os.cpp @@ -7,11 +7,14 @@ namespace details { namespace os { std::tm localtime(const std::time_t &time_t) { -#ifdef _MSC_VER + std::tm tm; +#ifdef _MSC_VER localtime_s(&tm, &time_t); - return tm; +#else + localtime_r(&time_t, &tm); #endif + return tm; } std::tm localtime() @@ -21,4 +24,4 @@ std::tm localtime() } } } -} \ No newline at end of file +}