replace constexpr with const becasuse vs2013 lack of support
This commit is contained in:
		
							parent
							
								
									3d5ee3ff56
								
							
						
					
					
						commit
						ed6532b9f0
					
				
							
								
								
									
										40
									
								
								c11logtest/c11logtest/ReadMe.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								c11logtest/c11logtest/ReadMe.txt
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | ||||
| ======================================================================== | ||||
|     CONSOLE APPLICATION : c11logtest Project Overview | ||||
| ======================================================================== | ||||
| 
 | ||||
| AppWizard has created this c11logtest application for you. | ||||
| 
 | ||||
| This file contains a summary of what you will find in each of the files that | ||||
| make up your c11logtest application. | ||||
| 
 | ||||
| 
 | ||||
| c11logtest.vcxproj | ||||
|     This is the main project file for VC++ projects generated using an Application Wizard. | ||||
|     It contains information about the version of Visual C++ that generated the file, and | ||||
|     information about the platforms, configurations, and project features selected with the | ||||
|     Application Wizard. | ||||
| 
 | ||||
| c11logtest.vcxproj.filters | ||||
|     This is the filters file for VC++ projects generated using an Application Wizard.  | ||||
|     It contains information about the association between the files in your project  | ||||
|     and the filters. This association is used in the IDE to show grouping of files with | ||||
|     similar extensions under a specific node (for e.g. ".cpp" files are associated with the | ||||
|     "Source Files" filter). | ||||
| 
 | ||||
| c11logtest.cpp | ||||
|     This is the main application source file. | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
| Other standard files: | ||||
| 
 | ||||
| StdAfx.h, StdAfx.cpp | ||||
|     These files are used to build a precompiled header (PCH) file | ||||
|     named c11logtest.pch and a precompiled types file named StdAfx.obj. | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
| Other notes: | ||||
| 
 | ||||
| AppWizard uses "TODO:" comments to indicate parts of the source code you | ||||
| should add to or customize. | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
							
								
								
									
										112
									
								
								c11logtest/c11logtest/c11logtest.vcxproj
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										112
									
								
								c11logtest/c11logtest/c11logtest.vcxproj
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,112 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||
|   <ItemGroup Label="ProjectConfigurations"> | ||||
|     <ProjectConfiguration Include="Debug|Win32"> | ||||
|       <Configuration>Debug</Configuration> | ||||
|       <Platform>Win32</Platform> | ||||
|     </ProjectConfiguration> | ||||
|     <ProjectConfiguration Include="Release|Win32"> | ||||
|       <Configuration>Release</Configuration> | ||||
|       <Platform>Win32</Platform> | ||||
|     </ProjectConfiguration> | ||||
|   </ItemGroup> | ||||
|   <PropertyGroup Label="Globals"> | ||||
|     <ProjectGuid>{DC7F2F3E-0D0E-4324-A278-410DBC4045AD}</ProjectGuid> | ||||
|     <Keyword>Win32Proj</Keyword> | ||||
|     <RootNamespace>c11logtest</RootNamespace> | ||||
|   </PropertyGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>true</UseDebugLibraries> | ||||
|     <PlatformToolset>v120</PlatformToolset> | ||||
|     <CharacterSet>Unicode</CharacterSet> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>false</UseDebugLibraries> | ||||
|     <PlatformToolset>v120</PlatformToolset> | ||||
|     <WholeProgramOptimization>true</WholeProgramOptimization> | ||||
|     <CharacterSet>Unicode</CharacterSet> | ||||
|   </PropertyGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||||
|   <ImportGroup Label="ExtensionSettings"> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <PropertyGroup Label="UserMacros" /> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
|     <LinkIncremental>true</LinkIncremental> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||||
|     <LinkIncremental>false</LinkIncremental> | ||||
|   </PropertyGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
|     <ClCompile> | ||||
|       <PrecompiledHeader> | ||||
|       </PrecompiledHeader> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <Optimization>Disabled</Optimization> | ||||
|       <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <AdditionalIncludeDirectories>../../include</AdditionalIncludeDirectories> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Console</SubSystem> | ||||
|       <GenerateDebugInformation>true</GenerateDebugInformation> | ||||
|     </Link> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||||
|     <ClCompile> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <PrecompiledHeader> | ||||
|       </PrecompiledHeader> | ||||
|       <Optimization>MaxSpeed</Optimization> | ||||
|       <FunctionLevelLinking>true</FunctionLevelLinking> | ||||
|       <IntrinsicFunctions>true</IntrinsicFunctions> | ||||
|       <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <AdditionalIncludeDirectories>../../include</AdditionalIncludeDirectories> | ||||
|       <BufferSecurityCheck>false</BufferSecurityCheck> | ||||
|       <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Console</SubSystem> | ||||
|       <GenerateDebugInformation>true</GenerateDebugInformation> | ||||
|       <EnableCOMDATFolding>true</EnableCOMDATFolding> | ||||
|       <OptimizeReferences>true</OptimizeReferences> | ||||
|       <Profile>true</Profile> | ||||
|     </Link> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemGroup> | ||||
|     <Text Include="ReadMe.txt" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="..\..\include\c11log\common_types.h" /> | ||||
|     <ClInclude Include="..\..\include\c11log\details\blocking_queue.h" /> | ||||
|     <ClInclude Include="..\..\include\c11log\details\factory.h" /> | ||||
|     <ClInclude Include="..\..\include\c11log\details\fast_oss.h" /> | ||||
|     <ClInclude Include="..\..\include\c11log\details\flush_helper.h" /> | ||||
|     <ClInclude Include="..\..\include\c11log\details\line_logger.h" /> | ||||
|     <ClInclude Include="..\..\include\c11log\details\log_msg.h" /> | ||||
|     <ClInclude Include="..\..\include\c11log\details\os.h" /> | ||||
|     <ClInclude Include="..\..\include\c11log\details\stack_buf.h" /> | ||||
|     <ClInclude Include="..\..\include\c11log\formatter.h" /> | ||||
|     <ClInclude Include="..\..\include\c11log\logger.h" /> | ||||
|     <ClInclude Include="..\..\include\c11log\sinks\async_sink.h" /> | ||||
|     <ClInclude Include="..\..\include\c11log\sinks\base_sink.h" /> | ||||
|     <ClInclude Include="..\..\include\c11log\sinks\console_sinks.h" /> | ||||
|     <ClInclude Include="..\..\include\c11log\sinks\file_sinks.h" /> | ||||
|     <ClInclude Include="stdafx.h" /> | ||||
|     <ClInclude Include="targetver.h" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="..\..\example\example.cpp" /> | ||||
|     <ClCompile Include="stdafx.cpp" /> | ||||
|   </ItemGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||||
|   <ImportGroup Label="ExtensionTargets"> | ||||
|   </ImportGroup> | ||||
| </Project> | ||||
							
								
								
									
										90
									
								
								c11logtest/c11logtest/c11logtest.vcxproj.filters
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								c11logtest/c11logtest/c11logtest.vcxproj.filters
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,90 @@ | ||||
| <?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> | ||||
|     <Filter Include="Header Files\c11log"> | ||||
|       <UniqueIdentifier>{bad4e9e3-82bd-4b02-9b4a-43198cc65844}</UniqueIdentifier> | ||||
|     </Filter> | ||||
|     <Filter Include="Header Files\c11log\details"> | ||||
|       <UniqueIdentifier>{a4cc3c0e-8713-4146-98c7-1e7ab4ed95f8}</UniqueIdentifier> | ||||
|     </Filter> | ||||
|     <Filter Include="Header Files\c11log\sinks"> | ||||
|       <UniqueIdentifier>{87170f3b-5292-49b8-8581-7db7cb9abd29}</UniqueIdentifier> | ||||
|     </Filter> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Text Include="ReadMe.txt" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="stdafx.h"> | ||||
|       <Filter>Header Files</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="targetver.h"> | ||||
|       <Filter>Header Files</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="..\..\include\c11log\common_types.h"> | ||||
|       <Filter>Header Files\c11log</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="..\..\include\c11log\formatter.h"> | ||||
|       <Filter>Header Files\c11log</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="..\..\include\c11log\logger.h"> | ||||
|       <Filter>Header Files\c11log</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="..\..\include\c11log\details\blocking_queue.h"> | ||||
|       <Filter>Header Files\c11log\details</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="..\..\include\c11log\details\factory.h"> | ||||
|       <Filter>Header Files\c11log\details</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="..\..\include\c11log\details\fast_oss.h"> | ||||
|       <Filter>Header Files\c11log\details</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="..\..\include\c11log\details\flush_helper.h"> | ||||
|       <Filter>Header Files\c11log\details</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="..\..\include\c11log\details\line_logger.h"> | ||||
|       <Filter>Header Files\c11log\details</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="..\..\include\c11log\details\log_msg.h"> | ||||
|       <Filter>Header Files\c11log\details</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="..\..\include\c11log\details\os.h"> | ||||
|       <Filter>Header Files\c11log\details</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="..\..\include\c11log\details\stack_buf.h"> | ||||
|       <Filter>Header Files\c11log\details</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="..\..\include\c11log\sinks\async_sink.h"> | ||||
|       <Filter>Header Files\c11log\sinks</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="..\..\include\c11log\sinks\base_sink.h"> | ||||
|       <Filter>Header Files\c11log\sinks</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="..\..\include\c11log\sinks\console_sinks.h"> | ||||
|       <Filter>Header Files\c11log\sinks</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="..\..\include\c11log\sinks\file_sinks.h"> | ||||
|       <Filter>Header Files\c11log\sinks</Filter> | ||||
|     </ClInclude> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="stdafx.cpp"> | ||||
|       <Filter>Source Files</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="..\..\example\example.cpp"> | ||||
|       <Filter>Source Files</Filter> | ||||
|     </ClCompile> | ||||
|   </ItemGroup> | ||||
| </Project> | ||||
							
								
								
									
										8
									
								
								c11logtest/c11logtest/stdafx.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								c11logtest/c11logtest/stdafx.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| // stdafx.cpp : source file that includes just the standard includes
 | ||||
| // c11logtest.pch will be the pre-compiled header
 | ||||
| // stdafx.obj will contain the pre-compiled type information
 | ||||
| 
 | ||||
| #include "stdafx.h" | ||||
| 
 | ||||
| // TODO: reference any additional headers you need in STDAFX.H
 | ||||
| // and not in this file
 | ||||
							
								
								
									
										15
									
								
								c11logtest/c11logtest/stdafx.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								c11logtest/c11logtest/stdafx.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | ||||
| // stdafx.h : include file for standard system include files,
 | ||||
| // or project specific include files that are used frequently, but
 | ||||
| // are changed infrequently
 | ||||
| //
 | ||||
| 
 | ||||
| #pragma once | ||||
| 
 | ||||
| #include "targetver.h" | ||||
| 
 | ||||
| #include <stdio.h> | ||||
| #include <tchar.h> | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| // TODO: reference additional headers your program requires here
 | ||||
							
								
								
									
										8
									
								
								c11logtest/c11logtest/targetver.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								c11logtest/c11logtest/targetver.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| #pragma once | ||||
| 
 | ||||
| // Including SDKDDKVer.h defines the highest available Windows platform.
 | ||||
| 
 | ||||
| // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
 | ||||
| // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
 | ||||
| 
 | ||||
| #include <SDKDDKVer.h> | ||||
| @ -15,8 +15,8 @@ using namespace c11log; | ||||
| using namespace utils; | ||||
| 
 | ||||
| int main(int argc, char* argv[]) | ||||
| {     | ||||
|     const unsigned int howmany = argc <= 1 ? 1000000:atoi(argv[1]); | ||||
| { | ||||
|     const unsigned int howmany = argc <= 1 ? 5000000:atoi(argv[1]); | ||||
| 
 | ||||
|     logger cout_logger ("example", sinks::stdout_sink()); | ||||
|     cout_logger.info() << "Hello logger"; | ||||
| @ -37,9 +37,9 @@ int main(int argc, char* argv[]) | ||||
|     auto delta = system_clock::now() - start; | ||||
|     auto delta_d = duration_cast<duration<double>> (delta).count(); | ||||
| 
 | ||||
|     cout_logger.info("Total:") << format(howmany); | ||||
|     cout_logger.info("Delta:") << format(delta_d); | ||||
|     cout_logger.info("Rate:") << format(howmany/delta_d) << "/sec"; | ||||
|     cout << "Total:" << format(howmany) << endl; | ||||
|     cout<< "Delta:" << format(delta_d) << endl; | ||||
|     cout << "Rate:" << format(howmany/delta_d) << "/sec" << endl; | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -4,6 +4,7 @@ | ||||
| // uses stack_buf as the underlying buffer (upto 192 bytes before using the heap)
 | ||||
| 
 | ||||
| #include <ostream> | ||||
| #include <iomanip> | ||||
| #include "stack_buf.h" | ||||
| 
 | ||||
| namespace c11log | ||||
| @ -13,8 +14,8 @@ namespace details | ||||
| 
 | ||||
| class stack_devicebuf :public std::streambuf | ||||
| { | ||||
| public:     | ||||
| 	static constexpr unsigned short stack_size = 192; | ||||
| public: | ||||
|     static const unsigned short stack_size = 192; | ||||
|     using stackbuf_t = stack_buf<stack_size>; | ||||
| 
 | ||||
|     stack_devicebuf() = default; | ||||
|  | ||||
| @ -6,7 +6,6 @@ | ||||
| #include "fast_oss.h" | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| // line_logger class.
 | ||||
| // aggregates single log line (on the stack if possibe) and calls the logger upon destruction
 | ||||
| 
 | ||||
|  | ||||
| @ -17,7 +17,7 @@ class stack_buf | ||||
| public: | ||||
|     using bufpair_t = std::pair<const char*, std::size_t>; | ||||
|     using iterator = char const*; | ||||
|     static constexpr unsigned short stack_size = STACK_SIZE; | ||||
|     static const unsigned short stack_size = STACK_SIZE; | ||||
|     stack_buf() :_v(), _stack_size(0) {} | ||||
|     ~stack_buf() = default; | ||||
| 
 | ||||
|  | ||||
| @ -34,10 +34,12 @@ public: | ||||
|     { | ||||
|         details::fast_oss oss; | ||||
|         _format_time(msg.time, oss); | ||||
| 
 | ||||
|         if(!msg.logger_name.empty()) | ||||
|             oss << " [" <<  msg.logger_name << ':' << c11log::level::to_str(msg.level) << "] "; | ||||
|         else | ||||
|             oss << " [" << c11log::level::to_str(msg.level) << "] "; | ||||
| 
 | ||||
|         oss << msg.raw << details::os::eol(); | ||||
|         msg.formatted = oss.str(); | ||||
|     } | ||||
|  | ||||
| @ -31,7 +31,7 @@ public: | ||||
|     using sinks_vector_t = std::vector<sink_ptr>; | ||||
|     using sinks_init_list = std::initializer_list<sink_ptr>; | ||||
| 
 | ||||
|     using formatter_ptr = std::shared_ptr<c11log::formatters::formatter>; | ||||
|     using formatter_ptr = std::unique_ptr<c11log::formatters::formatter>; | ||||
| 
 | ||||
|     logger(const std::string& name, sinks_init_list, formatter_ptr = nullptr); | ||||
|     logger(const std::string& name, sink_ptr, formatter_ptr = nullptr); | ||||
| @ -92,18 +92,19 @@ logger& get_logger(const std::string& name); | ||||
| 
 | ||||
| inline c11log::logger::logger(const std::string& name, sinks_init_list sinks_list, formatter_ptr f) : | ||||
|     _logger_name(name), | ||||
|     _formatter(f), | ||||
|     _formatter(std::move(f)), | ||||
|     _sinks(sinks_list) | ||||
| { | ||||
|     //Seems that vs2013 doesnt support std::atomic member initialization, so its done here
 | ||||
|     _min_level = level::INFO; | ||||
|     if(!_formatter) | ||||
|         _formatter = std::make_shared<formatters::default_formatter>(); | ||||
|         _formatter = std::make_unique<formatters::default_formatter>(); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| inline c11log::logger::logger(const std::string& name, sink_ptr sink, formatter_ptr f) : | ||||
|     logger(name, {sink}, f) {} | ||||
|     logger(name, {sink}, std::move(f)) {} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user