Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
cbddc879
Commit
cbddc879
authored
Oct 29, 2014
by
gabi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. renamed lib to to spitlog
2. Rotating bugfix
parent
cda4b9b4
Show whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
209 additions
and
180 deletions
+209
-180
ReadMe.txt
c11logtest/c11logtest/ReadMe.txt
+7
-7
c11logtest.vcxproj
c11logtest/c11logtest/c11logtest.vcxproj
+25
-25
c11logtest.vcxproj.filters
c11logtest/c11logtest/c11logtest.vcxproj.filters
+44
-44
stdafx.cpp
c11logtest/c11logtest/stdafx.cpp
+1
-1
bench.cpp
example/bench.cpp
+15
-14
example.cpp
example/example.cpp
+4
-4
common.h
include/spitlog/common.h
+4
-4
blocking_queue.h
include/spitlog/details/blocking_queue.h
+1
-1
fast_istostr.h
include/spitlog/details/fast_istostr.h
+1
-1
fast_oss.h
include/spitlog/details/fast_oss.h
+1
-1
file_helper.h
include/spitlog/details/file_helper.h
+20
-1
line_logger.h
include/spitlog/details/line_logger.h
+2
-2
log_msg.h
include/spitlog/details/log_msg.h
+1
-1
logger_impl.h
include/spitlog/details/logger_impl.h
+26
-26
null_mutex.h
include/spitlog/details/null_mutex.h
+1
-1
os.h
include/spitlog/details/os.h
+2
-2
pattern_formatter_impl.h
include/spitlog/details/pattern_formatter_impl.h
+5
-5
registry.h
include/spitlog/details/registry.h
+1
-1
stack_buf.h
include/spitlog/details/stack_buf.h
+2
-2
formatter.h
include/spitlog/formatter.h
+1
-1
logger.h
include/spitlog/logger.h
+6
-6
async_sink.h
include/spitlog/sinks/async_sink.h
+10
-10
base_sink.h
include/spitlog/sinks/base_sink.h
+1
-1
file_sinks.h
include/spitlog/sinks/file_sinks.h
+24
-15
null_sink.h
include/spitlog/sinks/null_sink.h
+1
-1
ostream_sink.h
include/spitlog/sinks/ostream_sink.h
+1
-1
sink.h
include/spitlog/sinks/sink.h
+1
-1
stdout_sinks.h
include/spitlog/sinks/stdout_sinks.h
+1
-1
No files found.
c11logtest/c11logtest/ReadMe.txt
View file @
cbddc879
========================================================================
========================================================================
CONSOLE APPLICATION :
c11
logtest Project Overview
CONSOLE APPLICATION :
spit
logtest Project Overview
========================================================================
========================================================================
AppWizard has created this
c11
logtest application for you.
AppWizard has created this
spit
logtest application for you.
This file contains a summary of what you will find in each of the files that
This file contains a summary of what you will find in each of the files that
make up your
c11
logtest application.
make up your
spit
logtest application.
c11
logtest.vcxproj
spit
logtest.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
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
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
information about the platforms, configurations, and project features selected with the
Application Wizard.
Application Wizard.
c11
logtest.vcxproj.filters
spit
logtest.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
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
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
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
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
"Source Files" filter).
c11
logtest.cpp
spit
logtest.cpp
This is the main application source file.
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
...
@@ -29,7 +29,7 @@ Other standard files:
...
@@ -29,7 +29,7 @@ Other standard files:
StdAfx.h, StdAfx.cpp
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
These files are used to build a precompiled header (PCH) file
named
c11
logtest.pch and a precompiled types file named StdAfx.obj.
named
spit
logtest.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
Other notes:
Other notes:
...
...
c11logtest/c11logtest/c11logtest.vcxproj
View file @
cbddc879
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
<PropertyGroup
Label=
"Globals"
>
<PropertyGroup
Label=
"Globals"
>
<ProjectGuid>
{DC7F2F3E-0D0E-4324-A278-410DBC4045AD}
</ProjectGuid>
<ProjectGuid>
{DC7F2F3E-0D0E-4324-A278-410DBC4045AD}
</ProjectGuid>
<Keyword>
Win32Proj
</Keyword>
<Keyword>
Win32Proj
</Keyword>
<RootNamespace>
c11
logtest
</RootNamespace>
<RootNamespace>
spit
logtest
</RootNamespace>
</PropertyGroup>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.Default.props"
/>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.Default.props"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label=
"Configuration"
>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label=
"Configuration"
>
...
@@ -52,7 +52,7 @@
...
@@ -52,7 +52,7 @@
<WarningLevel>
Level3
</WarningLevel>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<Optimization>
Disabled
</Optimization>
<PreprocessorDefinitions>
WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<PreprocessorDefinitions>
WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
../../include
</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>
E:\devel\c11log\example;
../../include
</AdditionalIncludeDirectories>
</ClCompile>
</ClCompile>
<Link>
<Link>
<SubSystem>
Console
</SubSystem>
<SubSystem>
Console
</SubSystem>
...
@@ -69,7 +69,7 @@
...
@@ -69,7 +69,7 @@
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<PreprocessorDefinitions>
WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<PreprocessorDefinitions>
WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
../../include
</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>
E:\devel\c11log\example;
../../include
</AdditionalIncludeDirectories>
<BufferSecurityCheck>
false
</BufferSecurityCheck>
<BufferSecurityCheck>
false
</BufferSecurityCheck>
<EnableEnhancedInstructionSet>
StreamingSIMDExtensions2
</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>
StreamingSIMDExtensions2
</EnableEnhancedInstructionSet>
</ClCompile>
</ClCompile>
...
@@ -85,28 +85,28 @@
...
@@ -85,28 +85,28 @@
<Text
Include=
"ReadMe.txt"
/>
<Text
Include=
"ReadMe.txt"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<ClInclude
Include=
"..\..\include\
c11
log\common.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\common.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\details\blocking_queue.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\details\blocking_queue.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\details\fast_oss.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\details\fast_oss.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\details\fast_istostr.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\details\fast_istostr.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\details\file_helper.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\details\file_helper.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\details\line_logger.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\details\line_logger.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\details\logger_impl.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\details\logger_impl.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\details\log_msg.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\details\log_msg.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\details\null_mutex.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\details\null_mutex.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\details\os.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\details\os.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\details\pattern_formatter_impl.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\details\pattern_formatter_impl.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\details\registry.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\details\registry.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\details\stack_buf.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\details\stack_buf.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\formatter.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\formatter.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\logger.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\logger.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\sinks\async_sink.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\sinks\async_sink.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\sinks\base_sink.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\sinks\base_sink.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\sinks\ostream_sink.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\sinks\ostream_sink.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\sinks\file_sinks.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\sinks\file_sinks.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\sinks\null_sink.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\sinks\null_sink.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\sinks\sink.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\sinks\sink.h"
/>
<ClInclude
Include=
"..\..\include\
c11
log\sinks\stdout_sinks.h"
/>
<ClInclude
Include=
"..\..\include\
spit
log\sinks\stdout_sinks.h"
/>
<ClInclude
Include=
"stdafx.h"
/>
<ClInclude
Include=
"stdafx.h"
/>
<ClInclude
Include=
"targetver.h"
/>
<ClInclude
Include=
"targetver.h"
/>
</ItemGroup>
</ItemGroup>
...
...
c11logtest/c11logtest/c11logtest.vcxproj.filters
View file @
cbddc879
...
@@ -33,71 +33,71 @@
...
@@ -33,71 +33,71 @@
<ClInclude
Include=
"targetver.h"
>
<ClInclude
Include=
"targetver.h"
>
<Filter>
Header Files
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\formatter
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\common
.h"
>
<Filter>
Header Files
\c11log
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\logger
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\details\blocking_queue
.h"
>
<Filter>
Header Files
\c11log
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\details\blocking_queue
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\details\fast_oss
.h"
>
<Filter>
Header Files
\c11log\details
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\details\fast_oss
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\details\fast_istostr
.h"
>
<Filter>
Header Files
\c11log\details
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\details\line_logg
er.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\details\file_help
er.h"
>
<Filter>
Header Files
\c11log\details
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\details\log_msg
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\details\line_logger
.h"
>
<Filter>
Header Files
\c11log\details
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\details\os
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\details\logger_impl
.h"
>
<Filter>
Header Files
\c11log\details
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\details\stack_buf
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\details\log_msg
.h"
>
<Filter>
Header Files
\c11log\details
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\sinks\async_sink
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\details\null_mutex
.h"
>
<Filter>
Header Files
\c11log\sinks
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\sinks\base_sink
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\details\os
.h"
>
<Filter>
Header Files
\c11log\sinks
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\sinks\file_sinks
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\details\pattern_formatter_impl
.h"
>
<Filter>
Header Files
\c11log\sinks
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\details\null_mutex
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\details\registry
.h"
>
<Filter>
Header Files
\c11log\details
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\sinks\null_sink
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\details\stack_buf
.h"
>
<Filter>
Header Files
\c11log\sinks
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\sinks\ostream_sink
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\formatter
.h"
>
<Filter>
Header Files
\c11log\sinks
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\sinks\stdout_sinks
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\logger
.h"
>
<Filter>
Header Files
\c11log\sinks
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\common
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\sinks\async_sink
.h"
>
<Filter>
Header Files
\c11log
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\details\fast_istostr
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\sinks\base_sink
.h"
>
<Filter>
Header Files
\c11log\details
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\sinks\
sink.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\sinks\ostream_
sink.h"
>
<Filter>
Header Files
\c11log\sinks
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\details\pattern_formatter_impl
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\sinks\file_sinks
.h"
>
<Filter>
Header Files
\c11log\details
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\details\logger_impl
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\sinks\null_sink
.h"
>
<Filter>
Header Files
\c11log\details
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\details\registry
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\sinks\sink
.h"
>
<Filter>
Header Files
\c11log\details
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"..\..\include\
c11log\details\file_helper
.h"
>
<ClInclude
Include=
"..\..\include\
spitlog\sinks\stdout_sinks
.h"
>
<Filter>
Header Files
\c11log\details
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
...
...
c11logtest/c11logtest/stdafx.cpp
View file @
cbddc879
// stdafx.cpp : source file that includes just the standard includes
// stdafx.cpp : source file that includes just the standard includes
//
c11
logtest.pch will be the pre-compiled header
//
spit
logtest.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
#include "stdafx.h"
...
...
example/bench.cpp
View file @
cbddc879
// example.cpp : Simple logger example
// example.cpp : Simple logger example
//
//
#include "
c11
log/logger.h"
#include "
spit
log/logger.h"
#include "
c11
log/sinks/async_sink.h"
#include "
spit
log/sinks/async_sink.h"
#include "
c11
log/sinks/file_sinks.h"
#include "
spit
log/sinks/file_sinks.h"
#include "
c11
log/sinks/stdout_sinks.h"
#include "
spit
log/sinks/stdout_sinks.h"
#include "
c11
log/sinks/null_sink.h"
#include "
spit
log/sinks/null_sink.h"
#include "utils.h"
#include "utils.h"
#include "
c11
log/details/registry.h"
#include "
spit
log/details/registry.h"
using
namespace
std
::
chrono
;
using
namespace
std
::
chrono
;
using
namespace
c11
log
;
using
namespace
spit
log
;
using
namespace
utils
;
using
namespace
utils
;
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
try
{
try
{
const
unsigned
int
howmany
=
argc
<=
1
?
500000
:
atoi
(
argv
[
1
]);
const
unsigned
int
howmany
=
argc
<=
1
?
1
500000
:
atoi
(
argv
[
1
]);
//
c11
log::set_format("%t");
//
spit
log::set_format("%t");
auto
console
=
c11
log
::
create
<
sinks
::
stdout_sink_st
>
(
"reporter"
);
auto
console
=
spit
log
::
create
<
sinks
::
stdout_sink_st
>
(
"reporter"
);
//console->set_format("[%n %l] %t");
//console->set_format("[%n %l] %t");
console
->
set_level
(
c11
log
::
level
::
INFO
);
console
->
set_level
(
spit
log
::
level
::
INFO
);
console
->
info
(
"Starting bench with"
,
howmany
,
"iterations.."
);
console
->
info
(
"Starting bench with"
,
howmany
,
"iterations.."
);
auto
bench
=
c11log
::
create
<
sinks
::
rotating_file_sink_st
>
(
"bench"
,
"myrotating"
,
"txt"
,
1024
*
1024
*
1
,
3
,
0
);
auto
bench
=
spitlog
::
create
<
sinks
::
rotating_file_sink_st
>
(
"bench"
,
"myrotating"
,
"txt"
,
1024
*
1024
*
1
,
10
,
0
);
//auto bench =
c11
log::create<sinks::simple_file_sink_st>("bench", "simplelog.txt", 1);
//auto bench =
spit
log::create<sinks::simple_file_sink_st>("bench", "simplelog.txt", 1);
//auto bench =
c11
log::create<sinks::null_sink_st>("bench");
//auto bench =
spit
log::create<sinks::null_sink_st>("bench");
auto
start
=
system_clock
::
now
();
auto
start
=
system_clock
::
now
();
for
(
unsigned
int
i
=
0
;
i
<
howmany
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
howmany
;
++
i
)
{
{
...
@@ -45,6 +45,7 @@ int main(int argc, char* argv[])
...
@@ -45,6 +45,7 @@ int main(int argc, char* argv[])
catch
(
std
::
exception
&
ex
)
catch
(
std
::
exception
&
ex
)
{
{
std
::
cerr
<<
"Exception: "
<<
ex
.
what
()
<<
std
::
endl
;
std
::
cerr
<<
"Exception: "
<<
ex
.
what
()
<<
std
::
endl
;
perror
(
"Last error"
);
}
}
return
0
;
return
0
;
}
}
...
...
example/example.cpp
View file @
cbddc879
...
@@ -3,11 +3,11 @@
...
@@ -3,11 +3,11 @@
#define FFLOG_ENABLE_TRACE
#define FFLOG_ENABLE_TRACE
#include <iostream>
#include <iostream>
#include "
c11
log/logger.h"
#include "
spit
log/logger.h"
#include "
c11
log/sinks/stdout_sinks.h"
#include "
spit
log/sinks/stdout_sinks.h"
#include "
c11
log/sinks/file_sinks.h"
#include "
spit
log/sinks/file_sinks.h"
using
namespace
std
;
using
namespace
std
;
using
namespace
c11
log
;
using
namespace
spit
log
;
details
::
fast_oss
f
(
const
std
::
string
&
what
)
details
::
fast_oss
f
(
const
std
::
string
&
what
)
...
...
include/
c11
log/common.h
→
include/
spit
log/common.h
View file @
cbddc879
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
#include<initializer_list>
#include<initializer_list>
#include<chrono>
#include<chrono>
namespace
c11
log
namespace
spit
log
{
{
class
formatter
;
class
formatter
;
namespace
sinks
{
namespace
sinks
{
...
@@ -14,7 +14,7 @@ class sink;
...
@@ -14,7 +14,7 @@ class sink;
using
log_clock
=
std
::
chrono
::
system_clock
;
using
log_clock
=
std
::
chrono
::
system_clock
;
using
sink_ptr
=
std
::
shared_ptr
<
sinks
::
sink
>
;
using
sink_ptr
=
std
::
shared_ptr
<
sinks
::
sink
>
;
using
sinks_init_list
=
std
::
initializer_list
<
sink_ptr
>
;
using
sinks_init_list
=
std
::
initializer_list
<
sink_ptr
>
;
using
formatter_ptr
=
std
::
shared_ptr
<
c11
log
::
formatter
>
;
using
formatter_ptr
=
std
::
shared_ptr
<
spit
log
::
formatter
>
;
//Log level enum
//Log level enum
namespace
level
namespace
level
...
@@ -31,7 +31,7 @@ typedef enum
...
@@ -31,7 +31,7 @@ typedef enum
}
level_enum
;
}
level_enum
;
static
const
char
*
level_names
[]
{
"trace"
,
"debug"
,
"info"
,
"warning"
,
"error"
,
"critical"
,
"fatal"
};
static
const
char
*
level_names
[]
{
"trace"
,
"debug"
,
"info"
,
"warning"
,
"error"
,
"critical"
,
"fatal"
};
inline
const
char
*
to_str
(
c11
log
::
level
::
level_enum
l
)
inline
const
char
*
to_str
(
spit
log
::
level
::
level_enum
l
)
{
{
return
level_names
[
l
];
return
level_names
[
l
];
}
}
...
@@ -52,4 +52,4 @@ private:
...
@@ -52,4 +52,4 @@ private:
};
};
}
//
c11
log
}
//
spit
log
include/
c11
log/details/blocking_queue.h
→
include/
spit
log/details/blocking_queue.h
View file @
cbddc879
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
#include <mutex>
#include <mutex>
#include <condition_variable>
#include <condition_variable>
namespace
c11
log
namespace
spit
log
{
{
namespace
details
namespace
details
{
{
...
...
include/
c11
log/details/fast_istostr.h
→
include/
spit
log/details/fast_istostr.h
View file @
cbddc879
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
//Source: http://stackoverflow.com/a/4351484/192001
//Source: http://stackoverflow.com/a/4351484/192001
//Modified version to pad zeros according to padding arg
//Modified version to pad zeros according to padding arg
namespace
c11
log
{
namespace
spit
log
{
namespace
details
{
namespace
details
{
const
char
digit_pairs
[
201
]
=
{
const
char
digit_pairs
[
201
]
=
{
...
...
include/
c11
log/details/fast_oss.h
→
include/
spit
log/details/fast_oss.h
View file @
cbddc879
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#include "stack_buf.h"
#include "stack_buf.h"
#include<iostream>
#include<iostream>
namespace
c11
log
namespace
spit
log
{
{
namespace
details
namespace
details
{
{
...
...
include/
c11
log/details/file_helper.h
→
include/
spit
log/details/file_helper.h
View file @
cbddc879
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
namespace
c11
log
namespace
spit
log
{
{
namespace
details
namespace
details
{
{
...
@@ -79,6 +79,25 @@ public:
...
@@ -79,6 +79,25 @@ public:
}
}
}
}
const
std
::
string
&
filename
()
const
{
return
_filename
;
}
static
bool
file_exists
(
const
std
::
string
&
name
)
{
FILE
*
file
;
if
(
!
os
::
fopen_s
(
&
file
,
name
.
c_str
(),
"r"
))
{
fclose
(
file
);
return
true
;
}
else
{
return
false
;
}
}
private
:
private
:
FILE
*
_fd
;
FILE
*
_fd
;
std
::
string
_filename
;
std
::
string
_filename
;
...
...
include/
c11
log/details/line_logger.h
→
include/
spit
log/details/line_logger.h
View file @
cbddc879
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
// Line logger class - aggregates operator<< calls to fast ostream
// Line logger class - aggregates operator<< calls to fast ostream
// and logs upon destruction
// and logs upon destruction
namespace
c11
log
namespace
spit
log
{
{
namespace
details
namespace
details
{
{
...
@@ -76,4 +76,4 @@ private:
...
@@ -76,4 +76,4 @@ private:
bool
_enabled
;
bool
_enabled
;
};
};
}
//Namespace details
}
//Namespace details
}
// Namespace
c11
log
}
// Namespace
spit
log
include/
c11
log/details/log_msg.h
→
include/
spit
log/details/log_msg.h
View file @
cbddc879
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
#include "../common.h"
#include "../common.h"
#include "./fast_oss.h"
#include "./fast_oss.h"
namespace
c11
log
namespace
spit
log
{
{
namespace
details
namespace
details
{
{
...
...
include/
c11
log/details/logger_impl.h
→
include/
spit
log/details/logger_impl.h
View file @
cbddc879
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#include "./line_logger.h"
#include "./line_logger.h"
inline
c11
log
::
logger
::
logger
(
const
std
::
string
&
logger_name
,
sinks_init_list
sinks_list
)
:
inline
spit
log
::
logger
::
logger
(
const
std
::
string
&
logger_name
,
sinks_init_list
sinks_list
)
:
_name
(
logger_name
),
_name
(
logger_name
),
_sinks
(
sinks_list
)
_sinks
(
sinks_list
)
{
{
...
@@ -16,30 +16,30 @@ inline c11log::logger::logger(const std::string& logger_name, sinks_init_list si
...
@@ -16,30 +16,30 @@ inline c11log::logger::logger(const std::string& logger_name, sinks_init_list si
}
}
template
<
class
It
>
template
<
class
It
>
inline
c11
log
::
logger
::
logger
(
const
std
::
string
&
logger_name
,
const
It
&
begin
,
const
It
&
end
)
:
inline
spit
log
::
logger
::
logger
(
const
std
::
string
&
logger_name
,
const
It
&
begin
,
const
It
&
end
)
:
_name
(
logger_name
),
_name
(
logger_name
),
_sinks
(
begin
,
end
)
_sinks
(
begin
,
end
)
{}
{}
inline
void
c11log
::
logger
::
set_formatter
(
c11
log
::
formatter_ptr
msg_formatter
)
inline
void
spitlog
::
logger
::
set_formatter
(
spit
log
::
formatter_ptr
msg_formatter
)
{
{
_formatter
=
msg_formatter
;
_formatter
=
msg_formatter
;
}
}
inline
void
c11
log
::
logger
::
set_format
(
const
std
::
string
&
format
)
inline
void
spit
log
::
logger
::
set_format
(
const
std
::
string
&
format
)
{
{
_formatter
=
std
::
make_shared
<
pattern_formatter
>
(
format
);
_formatter
=
std
::
make_shared
<
pattern_formatter
>
(
format
);
}
}
inline
c11log
::
formatter_ptr
c11
log
::
logger
::
get_formatter
()
const
inline
spitlog
::
formatter_ptr
spit
log
::
logger
::
get_formatter
()
const
{
{
return
_formatter
;
return
_formatter
;
}
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
inline
c11log
::
details
::
line_logger
c11
log
::
logger
::
log
(
level
::
level_enum
lvl
,
const
Args
&
...
args
)
{
inline
spitlog
::
details
::
line_logger
spit
log
::
logger
::
log
(
level
::
level_enum
lvl
,
const
Args
&
...
args
)
{
bool
msg_enabled
=
should_log
(
lvl
);
bool
msg_enabled
=
should_log
(
lvl
);
details
::
line_logger
l
(
this
,
lvl
,
msg_enabled
);
details
::
line_logger
l
(
this
,
lvl
,
msg_enabled
);
if
(
msg_enabled
)
if
(
msg_enabled
)
...
@@ -48,72 +48,72 @@ inline c11log::details::line_logger c11log::logger::log(level::level_enum lvl, c
...
@@ -48,72 +48,72 @@ inline c11log::details::line_logger c11log::logger::log(level::level_enum lvl, c
}
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
inline
c11log
::
details
::
line_logger
c11
log
::
logger
::
trace
(
const
Args
&
...
args
)
inline
spitlog
::
details
::
line_logger
spit
log
::
logger
::
trace
(
const
Args
&
...
args
)
{
{
return
log
(
level
::
TRACE
,
args
...);
return
log
(
level
::
TRACE
,
args
...);
}
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
inline
c11log
::
details
::
line_logger
c11
log
::
logger
::
debug
(
const
Args
&
...
args
)
inline
spitlog
::
details
::
line_logger
spit
log
::
logger
::
debug
(
const
Args
&
...
args
)
{
{
return
log
(
level
::
DEBUG
,
args
...);
return
log
(
level
::
DEBUG
,
args
...);
}
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
inline
c11log
::
details
::
line_logger
c11
log
::
logger
::
info
(
const
Args
&
...
args
)
inline
spitlog
::
details
::
line_logger
spit
log
::
logger
::
info
(
const
Args
&
...
args
)
{
{
return
log
(
level
::
INFO
,
args
...);
return
log
(
level
::
INFO
,
args
...);
}
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
inline
c11log
::
details
::
line_logger
c11
log
::
logger
::
warn
(
const
Args
&
...
args
)
inline
spitlog
::
details
::
line_logger
spit
log
::
logger
::
warn
(
const
Args
&
...
args
)
{
{
return
log
(
level
::
WARN
,
args
...);
return
log
(
level
::
WARN
,
args
...);
}
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
inline
c11log
::
details
::
line_logger
c11
log
::
logger
::
error
(
const
Args
&
...
args
)
inline
spitlog
::
details
::
line_logger
spit
log
::
logger
::
error
(
const
Args
&
...
args
)
{
{
return
log
(
level
::
ERR
,
args
...);
return
log
(
level
::
ERR
,
args
...);
}
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
inline
c11log
::
details
::
line_logger
c11
log
::
logger
::
critical
(
const
Args
&
...
args
)
inline
spitlog
::
details
::
line_logger
spit
log
::
logger
::
critical
(
const
Args
&
...
args
)
{
{
return
log
(
level
::
CRITICAL
,
args
...);
return
log
(
level
::
CRITICAL
,
args
...);
}
}
inline
const
std
::
string
&
c11
log
::
logger
::
name
()
const
inline
const
std
::
string
&
spit
log
::
logger
::
name
()
const
{
{
return
_name
;
return
_name
;
}
}
inline
void
c11log
::
logger
::
set_level
(
c11
log
::
level
::
level_enum
log_level
)
inline
void
spitlog
::
logger
::
set_level
(
spit
log
::
level
::
level_enum
log_level
)
{
{
_level
.
store
(
log_level
);
_level
.
store
(
log_level
);
}
}
inline
c11log
::
level
::
level_enum
c11
log
::
logger
::
level
()
const
inline
spitlog
::
level
::
level_enum
spit
log
::
logger
::
level
()
const
{
{
return
static_cast
<
c11
log
::
level
::
level_enum
>
(
_level
.
load
());
return
static_cast
<
spit
log
::
level
::
level_enum
>
(
_level
.
load
());
}
}
inline
bool
c11log
::
logger
::
should_log
(
c11
log
::
level
::
level_enum
msg_level
)
const
inline
bool
spitlog
::
logger
::
should_log
(
spit
log
::
level
::
level_enum
msg_level
)
const
{
{
return
msg_level
>=
_level
.
load
();
return
msg_level
>=
_level
.
load
();
}
}
inline
void
c11log
::
logger
::
_variadic_log
(
c11
log
::
details
::
line_logger
&
)
{}
inline
void
spitlog
::
logger
::
_variadic_log
(
spit
log
::
details
::
line_logger
&
)
{}
template
<
typename
First
,
typename
...
Rest
>
template
<
typename
First
,
typename
...
Rest
>
void
c11log
::
logger
::
_variadic_log
(
c11
log
::
details
::
line_logger
&
l
,
const
First
&
first
,
const
Rest
&
...
rest
)
void
spitlog
::
logger
::
_variadic_log
(
spit
log
::
details
::
line_logger
&
l
,
const
First
&
first
,
const
Rest
&
...
rest
)
{
{
l
.
write
(
first
);
l
.
write
(
first
);
l
.
write
(
' '
);
l
.
write
(
' '
);
_variadic_log
(
l
,
rest
...);
_variadic_log
(
l
,
rest
...);
}
}
inline
void
c11
log
::
logger
::
_log_msg
(
details
::
log_msg
&
msg
)
inline
void
spit
log
::
logger
::
_log_msg
(
details
::
log_msg
&
msg
)
{
{
//Use default formatter if not set
//Use default formatter if not set
if
(
!
_formatter
)
if
(
!
_formatter
)
...
@@ -127,19 +127,19 @@ inline void c11log::logger::_log_msg(details::log_msg& msg)
...
@@ -127,19 +127,19 @@ inline void c11log::logger::_log_msg(details::log_msg& msg)
// Global registry functions
// Global registry functions
//
//
#include "./registry.h"
#include "./registry.h"
inline
std
::
shared_ptr
<
c11log
::
logger
>
c11
log
::
get
(
const
std
::
string
&
name
)
inline
std
::
shared_ptr
<
spitlog
::
logger
>
spit
log
::
get
(
const
std
::
string
&
name
)
{
{
return
details
::
registry
::
instance
().
get
(
name
);
return
details
::
registry
::
instance
().
get
(
name
);
}
}
inline
std
::
shared_ptr
<
c11log
::
logger
>
c11log
::
create
(
const
std
::
string
&
logger_name
,
c11
log
::
sinks_init_list
sinks
)
inline
std
::
shared_ptr
<
spitlog
::
logger
>
spitlog
::
create
(
const
std
::
string
&
logger_name
,
spit
log
::
sinks_init_list
sinks
)
{
{
return
details
::
registry
::
instance
().
create
(
logger_name
,
sinks
);
return
details
::
registry
::
instance
().
create
(
logger_name
,
sinks
);
}
}
template
<
typename
Sink
,
typename
...
Args
>
template
<
typename
Sink
,
typename
...
Args
>
inline
std
::
shared_ptr
<
c11log
::
logger
>
c11
log
::
create
(
const
std
::
string
&
logger_name
,
const
Args
&
...
args
)
inline
std
::
shared_ptr
<
spitlog
::
logger
>
spit
log
::
create
(
const
std
::
string
&
logger_name
,
const
Args
&
...
args
)
{
{
sink_ptr
sink
=
std
::
make_shared
<
Sink
>
(
args
...);
sink_ptr
sink
=
std
::
make_shared
<
Sink
>
(
args
...);
return
details
::
registry
::
instance
().
create
(
logger_name
,
{
sink
});
return
details
::
registry
::
instance
().
create
(
logger_name
,
{
sink
});
...
@@ -147,17 +147,17 @@ inline std::shared_ptr<c11log::logger> c11log::create(const std::string& logger_
...
@@ -147,17 +147,17 @@ inline std::shared_ptr<c11log::logger> c11log::create(const std::string& logger_
template
<
class
It
>
template
<
class
It
>
inline
std
::
shared_ptr
<
c11log
::
logger
>
c11
log
::
create
(
const
std
::
string
&
logger_name
,
const
It
&
sinks_begin
,
const
It
&
sinks_end
)
inline
std
::
shared_ptr
<
spitlog
::
logger
>
spit
log
::
create
(
const
std
::
string
&
logger_name
,
const
It
&
sinks_begin
,
const
It
&
sinks_end
)
{
{
return
details
::
registry
::
instance
().
create
(
logger_name
,
std
::
forward
(
sinks_begin
),
std
::
forward
(
sinks_end
));
return
details
::
registry
::
instance
().
create
(
logger_name
,
std
::
forward
(
sinks_begin
),
std
::
forward
(
sinks_end
));
}
}
inline
void
c11log
::
set_formatter
(
c11
log
::
formatter_ptr
f
)
inline
void
spitlog
::
set_formatter
(
spit
log
::
formatter_ptr
f
)
{
{
details
::
registry
::
instance
().
formatter
(
f
);
details
::
registry
::
instance
().
formatter
(
f
);
}
}
inline
void
c11
log
::
set_format
(
const
std
::
string
&
format_string
)
inline
void
spit
log
::
set_format
(
const
std
::
string
&
format_string
)
{
{
return
details
::
registry
::
instance
().
set_format
(
format_string
);
return
details
::
registry
::
instance
().
set_format
(
format_string
);
}
}
include/
c11
log/details/null_mutex.h
→
include/
spit
log/details/null_mutex.h
View file @
cbddc879
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
// null, no cost mutex
// null, no cost mutex
namespace
c11
log
{
namespace
spit
log
{
namespace
details
{
namespace
details
{
struct
null_mutex
struct
null_mutex
{
{
...
...
include/
c11
log/details/os.h
→
include/
spit
log/details/os.h
View file @
cbddc879
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#include <Windows.h>
#include <Windows.h>
#endif
#endif
namespace
c11
log
namespace
spit
log
{
{
namespace
details
namespace
details
{
{
...
@@ -123,7 +123,7 @@ inline int utc_minutes_offset(const std::tm& tm = localtime())
...
@@ -123,7 +123,7 @@ inline int utc_minutes_offset(const std::tm& tm = localtime())
}
//os
}
//os
}
//details
}
//details
}
//
c11
log
}
//
spit
log
include/
c11
log/details/pattern_formatter_impl.h
→
include/
spit
log/details/pattern_formatter_impl.h
View file @
cbddc879
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
#include "./fast_oss.h"
#include "./fast_oss.h"
#include "./os.h"
#include "./os.h"
namespace
c11
log
namespace
spit
log
{
{
namespace
details
{
namespace
details
{
class
flag_formatter
class
flag_formatter
...
@@ -377,12 +377,12 @@ class full_formatter :public flag_formatter
...
@@ -377,12 +377,12 @@ class full_formatter :public flag_formatter
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// pattern_formatter inline impl
// pattern_formatter inline impl
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
inline
c11
log
::
pattern_formatter
::
pattern_formatter
(
const
std
::
string
&
pattern
)
inline
spit
log
::
pattern_formatter
::
pattern_formatter
(
const
std
::
string
&
pattern
)
{
{
compile_pattern
(
pattern
);
compile_pattern
(
pattern
);
}
}
inline
void
c11
log
::
pattern_formatter
::
compile_pattern
(
const
std
::
string
&
pattern
)
inline
void
spit
log
::
pattern_formatter
::
compile_pattern
(
const
std
::
string
&
pattern
)
{
{
auto
end
=
pattern
.
end
();
auto
end
=
pattern
.
end
();
std
::
unique_ptr
<
details
::
aggregate_formatter
>
user_chars
;
std
::
unique_ptr
<
details
::
aggregate_formatter
>
user_chars
;
...
@@ -411,7 +411,7 @@ inline void c11log::pattern_formatter::compile_pattern(const std::string& patter
...
@@ -411,7 +411,7 @@ inline void c11log::pattern_formatter::compile_pattern(const std::string& patter
}
}
}
}
inline
void
c11
log
::
pattern_formatter
::
handle_flag
(
char
flag
)
inline
void
spit
log
::
pattern_formatter
::
handle_flag
(
char
flag
)
{
{
switch
(
flag
)
switch
(
flag
)
{
{
...
@@ -523,7 +523,7 @@ inline void c11log::pattern_formatter::handle_flag(char flag)
...
@@ -523,7 +523,7 @@ inline void c11log::pattern_formatter::handle_flag(char flag)
}
}
inline
void
c11
log
::
pattern_formatter
::
format
(
details
::
log_msg
&
msg
)
inline
void
spit
log
::
pattern_formatter
::
format
(
details
::
log_msg
&
msg
)
{
{
for
(
auto
&
f
:
_formatters
)
for
(
auto
&
f
:
_formatters
)
{
{
...
...
include/
c11
log/details/registry.h
→
include/
spit
log/details/registry.h
View file @
cbddc879
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
#include "../logger.h"
#include "../logger.h"
#include "../common.h"
#include "../common.h"
namespace
c11
log
{
namespace
spit
log
{
namespace
details
{
namespace
details
{
class
registry
{
class
registry
{
public
:
public
:
...
...
include/
c11
log/details/stack_buf.h
→
include/
spit
log/details/stack_buf.h
View file @
cbddc879
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
// Fast memory storage on the stack when possible or in std::vector
// Fast memory storage on the stack when possible or in std::vector
namespace
c11
log
namespace
spit
log
{
{
namespace
details
namespace
details
{
{
...
@@ -108,4 +108,4 @@ private:
...
@@ -108,4 +108,4 @@ private:
};
};
}
}
}
//namespace
c11
log { namespace details {
}
//namespace
spit
log { namespace details {
include/
c11
log/formatter.h
→
include/
spit
log/formatter.h
View file @
cbddc879
#pragma once
#pragma once
#include "details/log_msg.h"
#include "details/log_msg.h"
namespace
c11
log
namespace
spit
log
{
{
namespace
details
{
namespace
details
{
class
flag_formatter
;
class
flag_formatter
;
...
...
include/
c11
log/logger.h
→
include/
spit
log/logger.h
View file @
cbddc879
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#include "sinks/base_sink.h"
#include "sinks/base_sink.h"
#include "common.h"
#include "common.h"
namespace
c11
log
namespace
spit
log
{
{
namespace
details
namespace
details
...
@@ -70,14 +70,14 @@ private:
...
@@ -70,14 +70,14 @@ private:
//
//
// Registry functions for easy loggers creation and retrieval
// Registry functions for easy loggers creation and retrieval
// example
// example
// auto console_logger =
c11log::create("my_logger", c11
log::sinks<stdout_sink_mt>);
// auto console_logger =
spitlog::create("my_logger", spit
log::sinks<stdout_sink_mt>);
// auto same_logger =
c11
log::get("my_logger");
// auto same_logger =
spit
log::get("my_logger");
// auto file_logger = c11
// auto file_logger = c11
//
//
std
::
shared_ptr
<
logger
>
get
(
const
std
::
string
&
name
);
std
::
shared_ptr
<
logger
>
get
(
const
std
::
string
&
name
);
std
::
shared_ptr
<
logger
>
create
(
const
std
::
string
&
logger_name
,
sinks_init_list
sinks
);
std
::
shared_ptr
<
logger
>
create
(
const
std
::
string
&
logger_name
,
sinks_init_list
sinks
);
template
<
typename
Sink
,
typename
...
Args
>
template
<
typename
Sink
,
typename
...
Args
>
std
::
shared_ptr
<
c11
log
::
logger
>
create
(
const
std
::
string
&
logger_name
,
const
Args
&
...
args
);
std
::
shared_ptr
<
spit
log
::
logger
>
create
(
const
std
::
string
&
logger_name
,
const
Args
&
...
args
);
template
<
class
It
>
template
<
class
It
>
std
::
shared_ptr
<
logger
>
create
(
const
std
::
string
&
logger_name
,
const
It
&
sinks_begin
,
const
It
&
sinks_end
);
std
::
shared_ptr
<
logger
>
create
(
const
std
::
string
&
logger_name
,
const
It
&
sinks_begin
,
const
It
&
sinks_end
);
...
@@ -89,13 +89,13 @@ void set_format(const std::string& format_string);
...
@@ -89,13 +89,13 @@ void set_format(const std::string& format_string);
// Trace & debug macros
// Trace & debug macros
//
//
#ifdef FFLOG_ENABLE_TRACE
#ifdef FFLOG_ENABLE_TRACE
#define FFLOG_TRACE(logger, ...) logger->log(
c11
log::level::TRACE, __FILE__, " #", __LINE__,": " __VA_ARGS__)
#define FFLOG_TRACE(logger, ...) logger->log(
spit
log::level::TRACE, __FILE__, " #", __LINE__,": " __VA_ARGS__)
#else
#else
#define FFLOG_TRACE(logger, ...) {}
#define FFLOG_TRACE(logger, ...) {}
#endif
#endif
#ifdef FFLOG_ENABLE_DEBUG
#ifdef FFLOG_ENABLE_DEBUG
#define FFLOG_DEBUG(logger, ...) logger->log(
c11
log::level::DEBUG, __VA_ARGS__)
#define FFLOG_DEBUG(logger, ...) logger->log(
spit
log::level::DEBUG, __VA_ARGS__)
#else
#else
#define FFLOG_DEBUG(logger, ...) {}
#define FFLOG_DEBUG(logger, ...) {}
#endif
#endif
...
...
include/
c11
log/sinks/async_sink.h
→
include/
spit
log/sinks/async_sink.h
View file @
cbddc879
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
#include<iostream>
#include<iostream>
namespace
c11
log
namespace
spit
log
{
{
namespace
sinks
namespace
sinks
{
{
...
@@ -53,26 +53,26 @@ private:
...
@@ -53,26 +53,26 @@ private:
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// async_sink class implementation
// async_sink class implementation
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
inline
c11
log
::
sinks
::
async_sink
::
async_sink
(
const
q_type
::
size_type
max_queue_size
)
inline
spit
log
::
sinks
::
async_sink
::
async_sink
(
const
q_type
::
size_type
max_queue_size
)
:
_sinks
(),
:
_sinks
(),
_active
(
true
),
_active
(
true
),
_q
(
max_queue_size
),
_q
(
max_queue_size
),
_back_thread
(
&
async_sink
::
_thread_loop
,
this
)
_back_thread
(
&
async_sink
::
_thread_loop
,
this
)
{}
{}
inline
c11
log
::
sinks
::
async_sink
::~
async_sink
()
inline
spit
log
::
sinks
::
async_sink
::~
async_sink
()
{
{
_shutdown
();
_shutdown
();
}
}
inline
void
c11
log
::
sinks
::
async_sink
::
_sink_it
(
const
details
::
log_msg
&
msg
)
inline
void
spit
log
::
sinks
::
async_sink
::
_sink_it
(
const
details
::
log_msg
&
msg
)
{
{
if
(
!
_active
)
if
(
!
_active
)
return
;
return
;
_q
.
push
(
msg
);
_q
.
push
(
msg
);
}
}
inline
void
c11
log
::
sinks
::
async_sink
::
_thread_loop
()
inline
void
spit
log
::
sinks
::
async_sink
::
_thread_loop
()
{
{
static
std
::
chrono
::
seconds
pop_timeout
{
1
};
static
std
::
chrono
::
seconds
pop_timeout
{
1
};
while
(
_active
)
while
(
_active
)
...
@@ -90,27 +90,27 @@ inline void c11log::sinks::async_sink::_thread_loop()
...
@@ -90,27 +90,27 @@ inline void c11log::sinks::async_sink::_thread_loop()
}
}
}
}
inline
void
c11log
::
sinks
::
async_sink
::
add_sink
(
c11
log
::
sink_ptr
s
)
inline
void
spitlog
::
sinks
::
async_sink
::
add_sink
(
spit
log
::
sink_ptr
s
)
{
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
_mutex
);
std
::
lock_guard
<
std
::
mutex
>
guard
(
_mutex
);
_sinks
.
push_back
(
s
);
_sinks
.
push_back
(
s
);
}
}
inline
void
c11log
::
sinks
::
async_sink
::
remove_sink
(
c11
log
::
sink_ptr
s
)
inline
void
spitlog
::
sinks
::
async_sink
::
remove_sink
(
spit
log
::
sink_ptr
s
)
{
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
_mutex
);
std
::
lock_guard
<
std
::
mutex
>
guard
(
_mutex
);
_sinks
.
erase
(
std
::
remove
(
_sinks
.
begin
(),
_sinks
.
end
(),
s
),
_sinks
.
end
());
_sinks
.
erase
(
std
::
remove
(
_sinks
.
begin
(),
_sinks
.
end
(),
s
),
_sinks
.
end
());
}
}
inline
c11log
::
sinks
::
async_sink
::
q_type
&
c11
log
::
sinks
::
async_sink
::
q
()
inline
spitlog
::
sinks
::
async_sink
::
q_type
&
spit
log
::
sinks
::
async_sink
::
q
()
{
{
return
_q
;
return
_q
;
}
}
inline
void
c11
log
::
sinks
::
async_sink
::
shutdown
(
const
std
::
chrono
::
milliseconds
&
timeout
)
inline
void
spit
log
::
sinks
::
async_sink
::
shutdown
(
const
std
::
chrono
::
milliseconds
&
timeout
)
{
{
if
(
timeout
>
std
::
chrono
::
milliseconds
::
zero
())
if
(
timeout
>
std
::
chrono
::
milliseconds
::
zero
())
{
{
...
@@ -124,7 +124,7 @@ inline void c11log::sinks::async_sink::shutdown(const std::chrono::milliseconds&
...
@@ -124,7 +124,7 @@ inline void c11log::sinks::async_sink::shutdown(const std::chrono::milliseconds&
}
}
inline
void
c11
log
::
sinks
::
async_sink
::
_shutdown
()
inline
void
spit
log
::
sinks
::
async_sink
::
_shutdown
()
{
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
_mutex
);
std
::
lock_guard
<
std
::
mutex
>
guard
(
_mutex
);
if
(
_active
)
if
(
_active
)
...
...
include/
c11
log/sinks/base_sink.h
→
include/
spit
log/sinks/base_sink.h
View file @
cbddc879
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
#include "../details/log_msg.h"
#include "../details/log_msg.h"
namespace
c11
log
namespace
spit
log
{
{
namespace
sinks
namespace
sinks
{
{
...
...
include/
c11
log/sinks/file_sinks.h
→
include/
spit
log/sinks/file_sinks.h
View file @
cbddc879
#pragma once
#pragma once
#include <sstream>
#include <mutex>
#include <mutex>
#include "./base_sink.h"
#include "./base_sink.h"
#include "../details/null_mutex.h"
#include "../details/null_mutex.h"
#include "../details/file_helper.h"
#include "../details/file_helper.h"
#include "../details/fast_oss.h"
namespace
c11
log
namespace
spit
log
{
{
namespace
sinks
namespace
sinks
{
{
...
@@ -56,7 +57,7 @@ public:
...
@@ -56,7 +57,7 @@ public:
_current_size
(
0
),
_current_size
(
0
),
_file_helper
(
flush_inverval
)
_file_helper
(
flush_inverval
)
{
{
_file_helper
.
open
(
_
calc_filename
(
_base_filename
,
0
,
_extension
));
_file_helper
.
open
(
calc_filename
(
_base_filename
,
0
,
_extension
));
}
}
protected
:
protected
:
...
@@ -73,9 +74,9 @@ protected:
...
@@ -73,9 +74,9 @@ protected:
private
:
private
:
static
std
::
string
_
calc_filename
(
const
std
::
string
&
filename
,
std
::
size_t
index
,
const
std
::
string
&
extension
)
static
std
::
string
calc_filename
(
const
std
::
string
&
filename
,
std
::
size_t
index
,
const
std
::
string
&
extension
)
{
{
std
::
ostringstream
oss
;
details
::
fast_oss
oss
;
if
(
index
)
if
(
index
)
oss
<<
filename
<<
"."
<<
index
<<
"."
<<
extension
;
oss
<<
filename
<<
"."
<<
index
<<
"."
<<
extension
;
else
else
...
@@ -96,11 +97,19 @@ private:
...
@@ -96,11 +97,19 @@ private:
_file_helper
.
close
();
_file_helper
.
close
();
for
(
auto
i
=
_max_files
;
i
>
0
;
--
i
)
for
(
auto
i
=
_max_files
;
i
>
0
;
--
i
)
{
{
std
::
string
src
=
_calc_filename
(
_base_filename
,
i
-
1
,
_extension
);
std
::
string
src
=
calc_filename
(
_base_filename
,
i
-
1
,
_extension
);
std
::
string
target
=
_calc_filename
(
_base_filename
,
i
,
_extension
);
std
::
string
target
=
calc_filename
(
_base_filename
,
i
,
_extension
);
std
::
rename
(
src
.
c_str
(),
target
.
c_str
());
if
(
details
::
file_helper
::
file_exists
(
target
))
std
::
remove
(
target
.
c_str
());
if
(
details
::
file_helper
::
file_exists
(
src
)
&&
std
::
rename
(
src
.
c_str
(),
target
.
c_str
()))
{
throw
fflog_exception
(
"rotating_file_sink: failed renaming "
+
src
+
" to "
+
target
);
}
}
}
_file_helper
.
open
(
_calc_filename
(
_base_filename
,
0
,
_extension
));
auto
cur_name
=
_file_helper
.
filename
();
std
::
remove
(
cur_name
.
c_str
());
_file_helper
.
open
(
cur_name
);
}
}
std
::
string
_base_filename
;
std
::
string
_base_filename
;
std
::
string
_extension
;
std
::
string
_extension
;
...
@@ -128,7 +137,7 @@ public:
...
@@ -128,7 +137,7 @@ public:
_midnight_tp
(
_calc_midnight_tp
()
),
_midnight_tp
(
_calc_midnight_tp
()
),
_file_helper
(
flush_inverval
)
_file_helper
(
flush_inverval
)
{
{
_file_helper
.
open
(
_
calc_filename
(
_base_filename
,
_extension
));
_file_helper
.
open
(
calc_filename
(
_base_filename
,
_extension
));
}
}
protected
:
protected
:
...
@@ -137,7 +146,7 @@ protected:
...
@@ -137,7 +146,7 @@ protected:
if
(
std
::
chrono
::
system_clock
::
now
()
>=
_midnight_tp
)
if
(
std
::
chrono
::
system_clock
::
now
()
>=
_midnight_tp
)
{
{
_file_helper
.
close
();
_file_helper
.
close
();
_file_helper
.
open
(
_
calc_filename
(
_base_filename
,
_extension
));
_file_helper
.
open
(
calc_filename
(
_base_filename
,
_extension
));
_midnight_tp
=
_calc_midnight_tp
();
_midnight_tp
=
_calc_midnight_tp
();
}
}
_file_helper
.
write
(
msg
);
_file_helper
.
write
(
msg
);
...
@@ -150,17 +159,17 @@ private:
...
@@ -150,17 +159,17 @@ private:
using
namespace
std
::
chrono
;
using
namespace
std
::
chrono
;
auto
now
=
system_clock
::
now
();
auto
now
=
system_clock
::
now
();
time_t
tnow
=
std
::
chrono
::
system_clock
::
to_time_t
(
now
);
time_t
tnow
=
std
::
chrono
::
system_clock
::
to_time_t
(
now
);
tm
date
=
c11
log
::
details
::
os
::
localtime
(
tnow
);
tm
date
=
spit
log
::
details
::
os
::
localtime
(
tnow
);
date
.
tm_hour
=
date
.
tm_min
=
date
.
tm_sec
=
0
;
date
.
tm_hour
=
date
.
tm_min
=
date
.
tm_sec
=
0
;
auto
midnight
=
std
::
chrono
::
system_clock
::
from_time_t
(
std
::
mktime
(
&
date
));
auto
midnight
=
std
::
chrono
::
system_clock
::
from_time_t
(
std
::
mktime
(
&
date
));
return
system_clock
::
time_point
(
midnight
+
hours
(
24
));
return
system_clock
::
time_point
(
midnight
+
hours
(
24
));
}
}
//Create filename for the form basename.YYYY-MM-DD.extension
//Create filename for the form basename.YYYY-MM-DD.extension
static
std
::
string
_
calc_filename
(
const
std
::
string
&
basename
,
const
std
::
string
&
extension
)
static
std
::
string
calc_filename
(
const
std
::
string
&
basename
,
const
std
::
string
&
extension
)
{
{
std
::
tm
tm
=
c11
log
::
details
::
os
::
localtime
();
std
::
tm
tm
=
spit
log
::
details
::
os
::
localtime
();
std
::
ostringstream
oss
;
fast_oss
oss
;
oss
<<
basename
<<
'.'
;
oss
<<
basename
<<
'.'
;
oss
<<
tm
.
tm_year
+
1900
<<
'-'
<<
std
::
setw
(
2
)
<<
std
::
setfill
(
'0'
)
<<
tm
.
tm_mon
+
1
<<
'-'
<<
tm
.
tm_mday
;
oss
<<
tm
.
tm_year
+
1900
<<
'-'
<<
std
::
setw
(
2
)
<<
std
::
setfill
(
'0'
)
<<
tm
.
tm_mon
+
1
<<
'-'
<<
tm
.
tm_mday
;
oss
<<
'.'
<<
extension
;
oss
<<
'.'
<<
extension
;
...
...
include/
c11
log/sinks/null_sink.h
→
include/
spit
log/sinks/null_sink.h
View file @
cbddc879
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
#include "../details/null_mutex.h"
#include "../details/null_mutex.h"
namespace
c11
log
{
namespace
spit
log
{
namespace
sinks
{
namespace
sinks
{
template
<
class
Mutex
>
template
<
class
Mutex
>
...
...
include/
c11
log/sinks/ostream_sink.h
→
include/
spit
log/sinks/ostream_sink.h
View file @
cbddc879
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#include "../details/null_mutex.h"
#include "../details/null_mutex.h"
#include "./base_sink.h"
#include "./base_sink.h"
namespace
c11
log
namespace
spit
log
{
{
namespace
sinks
namespace
sinks
{
{
...
...
include/
c11
log/sinks/sink.h
→
include/
spit
log/sinks/sink.h
View file @
cbddc879
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#include "../details/log_msg.h"
#include "../details/log_msg.h"
namespace
c11
log
namespace
spit
log
{
{
namespace
sinks
namespace
sinks
{
{
...
...
include/
c11
log/sinks/stdout_sinks.h
→
include/
spit
log/sinks/stdout_sinks.h
View file @
cbddc879
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
#include "./ostream_sink.h"
#include "./ostream_sink.h"
#include "../details/null_mutex.h"
#include "../details/null_mutex.h"
namespace
c11
log
namespace
spit
log
{
{
namespace
sinks
namespace
sinks
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment