Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spdlog
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
spdlog
Commits
451aadec
Commit
451aadec
authored
Jul 09, 2016
by
Gabi Melman
Committed by
GitHub
Jul 09, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #236 from gabime/no-streams
No streams
parents
34bb86b2
7ddfb2b8
Changes
31
Show whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
547 additions
and
975 deletions
+547
-975
.gitignore
.gitignore
+48
-48
INSTALL
INSTALL
+13
-13
LICENSE
LICENSE
+22
-22
bench/Makefile.mingw
bench/Makefile.mingw
+57
-57
bench/easyl.conf
bench/easyl.conf
+10
-10
bench/logs/.gitignore
bench/logs/.gitignore
+4
-4
bench/run_all.sh
bench/run_all.sh
+0
-76
cmake/Config.cmake.in
cmake/Config.cmake.in
+24
-24
cmake/spdlog.pc.in
cmake/spdlog.pc.in
+6
-6
example/CMakeLists.txt
example/CMakeLists.txt
+46
-46
example/Makefile
example/Makefile
+29
-29
example/Makefile.clang
example/Makefile.clang
+32
-32
example/Makefile.mingw
example/Makefile.mingw
+32
-32
example/example.cpp
example/example.cpp
+3
-4
example/example.sln
example/example.sln
+22
-22
example/example.vcxproj
example/example.vcxproj
+35
-0
example/logs/.gitignore
example/logs/.gitignore
+0
-2
include/spdlog/async_logger.h
include/spdlog/async_logger.h
+1
-1
include/spdlog/common.h
include/spdlog/common.h
+20
-12
include/spdlog/details/async_log_helper.h
include/spdlog/details/async_log_helper.h
+8
-6
include/spdlog/details/async_logger_impl.h
include/spdlog/details/async_logger_impl.h
+1
-1
include/spdlog/details/line_logger_fwd.h
include/spdlog/details/line_logger_fwd.h
+0
-78
include/spdlog/details/line_logger_impl.h
include/spdlog/details/line_logger_impl.h
+0
-185
include/spdlog/details/log_msg.h
include/spdlog/details/log_msg.h
+12
-47
include/spdlog/details/logger_impl.h
include/spdlog/details/logger_impl.h
+58
-139
include/spdlog/details/pattern_formatter_impl.h
include/spdlog/details/pattern_formatter_impl.h
+6
-2
include/spdlog/logger.h
include/spdlog/logger.h
+26
-59
include/spdlog/sinks/ansicolor_sink.h
include/spdlog/sinks/ansicolor_sink.h
+10
-9
include/spdlog/sinks/syslog_sink.h
include/spdlog/sinks/syslog_sink.h
+1
-4
include/spdlog/spdlog.h
include/spdlog/spdlog.h
+3
-2
include/spdlog/tweakme.h
include/spdlog/tweakme.h
+18
-3
No files found.
.gitignore
View file @
451aadec
INSTALL
View file @
451aadec
LICENSE
View file @
451aadec
bench/Makefile.mingw
View file @
451aadec
bench/easyl.conf
View file @
451aadec
bench/logs/.gitignore
View file @
451aadec
bench/run_all.sh
deleted
100755 → 0
View file @
34bb86b2
#~/bin/bash
#execute each bench 3 times and print the timing
exec
2>&1
#execute and time given exe 3 times
bench_exe
()
{
echo
"****************
$1
****************"
for
i
in
{
1..3
}
;
do
time
./
$1
$2
;
rm
-f
logs/
*
sleep
3
done
;
}
#execute given async tests 3 times (timing is already builtin)
bench_async
()
{
echo
"****************
$1
****************"
for
i
in
{
1..3
}
;
do
./
$1
$2
;
echo
rm
-f
logs/
*
sleep
3
done
;
}
echo
"----------------------------------------------------------"
echo
"Single threaded benchmarks.. (1 thread, 1,000,000 lines)"
echo
"----------------------------------------------------------"
for
exe
in
boost-bench glog-bench easylogging-bench zf_log-bench spdlog-bench
;
do
bench_exe
$exe
1
done
;
echo
"----------------------------------------------------------"
echo
"Multi threaded benchmarks.. (10 threads, 1,000,000 lines)"
echo
"----------------------------------------------------------"
for
exe
in
boost-bench-mt glog-bench-mt easylogging-bench-mt zf_log-bench-mt spdlog-bench-mt
;
do
bench_exe
$exe
10
done
;
echo
"----------------------------------------------------------"
echo
"Multi threaded benchmarks.. (100 threads, 1,000,000 lines)"
echo
"----------------------------------------------------------"
for
exe
in
boost-bench-mt glog-bench-mt easylogging-bench-mt zf_log-bench-mt spdlog-bench-mt
;
do
bench_exe
$exe
100
done
;
echo
"---------------------------------------------------------------"
echo
"Async, single threaded benchmark.. (1 thread, 1,000,000 lines)"
echo
"---------------------------------------------------------------"
for
exe
in
spdlog-async g2log-async
do
bench_async
$exe
1
done
;
echo
"---------------------------------------------------------------"
echo
"Async, multi threaded benchmark.. (10 threads, 1,000,000 lines)"
echo
"---------------------------------------------------------------"
for
exe
in
spdlog-async g2log-async
do
bench_async
$exe
10
done
;
echo
"---------------------------------------------------------------"
echo
"Async, multi threaded benchmark.. (100 threads, 1,000,000 lines)"
echo
"---------------------------------------------------------------"
for
exe
in
spdlog-async g2log-async
do
bench_async
$exe
100
done
;
cmake/Config.cmake.in
View file @
451aadec
cmake/spdlog.pc.in
View file @
451aadec
example/CMakeLists.txt
View file @
451aadec
example/Makefile
View file @
451aadec
example/Makefile.clang
View file @
451aadec
example/Makefile.mingw
View file @
451aadec
example/example.cpp
View file @
451aadec
...
...
@@ -22,11 +22,11 @@ int main(int, char*[])
// Multithreaded color console
auto
console
=
spd
::
stdout_logger_mt
(
"console"
,
true
);
console
->
info
(
"Welcome to spdlog!"
);
console
->
info
(
"An info message example {}.."
,
1
);
console
->
error
(
"An info message example {}.."
,
1
);
// Formatting examples
console
->
info
(
"Easy padding in numbers like {:08d}"
,
12
);
console
->
info
(
"Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}"
,
42
);
console
->
warn
(
"Easy padding in numbers like {:08d}"
,
12
);
console
->
critical
(
"Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}"
,
42
);
console
->
info
(
"Support for floats {:03.2f}"
,
1.23456
);
console
->
info
(
"Positional args are {1} {0}.."
,
"too"
,
"supported"
);
...
...
@@ -106,4 +106,3 @@ void syslog_example()
#endif
}
example/example.sln
View file @
451aadec
example/example.vcxproj
View file @
451aadec
...
...
@@ -11,8 +11,43 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"..\include\spdlog\details\format.cc"
>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
true
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
true
</ExcludedFromBuild>
</ClCompile>
<ClCompile
Include=
"example.cpp"
/>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"..\include\spdlog\async_logger.h"
/>
<ClInclude
Include=
"..\include\spdlog\common.h"
/>
<ClInclude
Include=
"..\include\spdlog\details\async_logger_impl.h"
/>
<ClInclude
Include=
"..\include\spdlog\details\async_log_helper.h"
/>
<ClInclude
Include=
"..\include\spdlog\details\file_helper.h"
/>
<ClInclude
Include=
"..\include\spdlog\details\format.h"
/>
<ClInclude
Include=
"..\include\spdlog\details\logger_impl.h"
/>
<ClInclude
Include=
"..\include\spdlog\details\log_msg.h"
/>
<ClInclude
Include=
"..\include\spdlog\details\mpmc_bounded_q.h"
/>
<ClInclude
Include=
"..\include\spdlog\details\null_mutex.h"
/>
<ClInclude
Include=
"..\include\spdlog\details\os.h"
/>
<ClInclude
Include=
"..\include\spdlog\details\pattern_formatter_impl.h"
/>
<ClInclude
Include=
"..\include\spdlog\details\registry.h"
/>
<ClInclude
Include=
"..\include\spdlog\details\spdlog_impl.h"
/>
<ClInclude
Include=
"..\include\spdlog\formatter.h"
/>
<ClInclude
Include=
"..\include\spdlog\logger.h"
/>
<ClInclude
Include=
"..\include\spdlog\sinks\android_sink.h"
/>
<ClInclude
Include=
"..\include\spdlog\sinks\ansicolor_sink.h"
/>
<ClInclude
Include=
"..\include\spdlog\sinks\base_sink.h"
/>
<ClInclude
Include=
"..\include\spdlog\sinks\dist_sink.h"
/>
<ClInclude
Include=
"..\include\spdlog\sinks\file_sinks.h"
/>
<ClInclude
Include=
"..\include\spdlog\sinks\msvc_sink.h"
/>
<ClInclude
Include=
"..\include\spdlog\sinks\null_sink.h"
/>
<ClInclude
Include=
"..\include\spdlog\sinks\ostream_sink.h"
/>
<ClInclude
Include=
"..\include\spdlog\sinks\sink.h"
/>
<ClInclude
Include=
"..\include\spdlog\sinks\stdout_sinks.h"
/>
<ClInclude
Include=
"..\include\spdlog\sinks\syslog_sink.h"
/>
<ClInclude
Include=
"..\include\spdlog\spdlog.h"
/>
<ClInclude
Include=
"..\include\spdlog\tweakme.h"
/>
</ItemGroup>
<PropertyGroup
Label=
"Globals"
>
<ProjectGuid>
{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}
</ProjectGuid>
<Keyword>
Win32Proj
</Keyword>
...
...
example/logs/.gitignore
deleted
100644 → 0
View file @
34bb86b2
*.txt
include/spdlog/async_logger.h
View file @
451aadec
...
...
@@ -63,7 +63,7 @@ public:
void
flush
()
override
;
protected:
void
_
log_msg
(
details
::
log_msg
&
msg
)
override
;
void
_
sink_it
(
details
::
log_msg
&
msg
)
override
;
void
_set_formatter
(
spdlog
::
formatter_ptr
msg_formatter
)
override
;
void
_set_pattern
(
const
std
::
string
&
pattern
)
override
;
...
...
include/spdlog/common.h
View file @
451aadec
...
...
@@ -56,26 +56,32 @@ using level_t = details::null_atomic_int;
using
level_t
=
std
::
atomic_int
;
#endif
#define SPDLOG_LEVEL_TRACE 0
#define SPDLOG_LEVEL_DEBUG 1
#define SPDLOG_LEVEL_INFO 2
#define SPDLOG_LEVEL_WARN 3
#define SPDLOG_LEVEL_ERR 4
#define SPDLOG_LEVEL_CRIT 5
#define SPDLOG_LEVEL_OFF 6
//Log level enum
namespace
level
{
typedef
enum
{
trace
=
0
,
debug
=
1
,
info
=
2
,
notice
=
3
,
warn
=
4
,
err
=
5
,
critical
=
6
,
alert
=
7
,
emerg
=
8
,
off
=
9
trace
=
SPDLOG_LEVEL_TRACE
,
debug
=
SPDLOG_LEVEL_DEBUG
,
info
=
SPDLOG_LEVEL_INFO
,
warn
=
SPDLOG_LEVEL_WARN
,
err
=
SPDLOG_LEVEL_ERR
,
critical
=
SPDLOG_LEVEL_CRIT
,
off
=
SPDLOG_LEVEL_OFF
}
level_enum
;
static
const
char
*
level_names
[]
{
"trace"
,
"debug"
,
"info"
,
"notice"
,
"warning"
,
"error"
,
"critical"
,
"alert"
,
"emerg
"
,
"off"
};
static
const
char
*
level_names
[]
{
"trace"
,
"debug"
,
"info"
,
"warning"
,
"error"
,
"critical
"
,
"off"
};
static
const
char
*
short_level_names
[]
{
"T"
,
"D"
,
"I"
,
"
N"
,
"W"
,
"E"
,
"C"
,
"A"
,
"M
"
,
"O"
};
static
const
char
*
short_level_names
[]
{
"T"
,
"D"
,
"I"
,
"
W"
,
"E"
,
"C
"
,
"O"
};
inline
const
char
*
to_str
(
spdlog
::
level
::
level_enum
l
)
{
...
...
@@ -124,5 +130,7 @@ using filename_t = std::wstring;
using
filename_t
=
std
::
string
;
#endif
#define SDLOG_STR_HELPER(x) #x
#define SPDLOG_STR(x) SDLOG_STR_HELPER(x)
}
//spdlog
include/spdlog/details/async_log_helper.h
View file @
451aadec
...
...
@@ -86,21 +86,22 @@ async_msg(async_msg&& other) SPDLOG_NOEXCEPT:
// construct from log_msg
async_msg
(
const
details
::
log_msg
&
m
)
:
logger_name
(
m
.
logger_name
),
level
(
m
.
level
),
time
(
m
.
time
),
thread_id
(
m
.
thread_id
),
txt
(
m
.
raw
.
data
(),
m
.
raw
.
size
()),
msg_type
(
async_msg_type
::
log
)
{}
{
#ifndef SPDLOG_NO_NAME
logger_name
=
*
m
.
logger_name
;
#endif
}
// copy into log_msg
void
fill_log_msg
(
log_msg
&
msg
)
{
msg
.
clear
();
msg
.
logger_name
=
logger_name
;
msg
.
logger_name
=
&
logger_name
;
msg
.
level
=
level
;
msg
.
time
=
time
;
msg
.
thread_id
=
thread_id
;
...
...
@@ -278,7 +279,7 @@ inline bool spdlog::details::async_log_helper::process_next_msg(log_clock::time_
{
async_msg
incoming_async_msg
;
log_msg
incoming_log_msg
;
if
(
_q
.
dequeue
(
incoming_async_msg
))
{
...
...
@@ -295,6 +296,7 @@ inline bool spdlog::details::async_log_helper::process_next_msg(log_clock::time_
break
;
default:
log_msg
incoming_log_msg
;
incoming_async_msg
.
fill_log_msg
(
incoming_log_msg
);
_formatter
->
format
(
incoming_log_msg
);
for
(
auto
&
s
:
_sinks
)
...
...
include/spdlog/details/async_logger_impl.h
View file @
451aadec
...
...
@@ -71,7 +71,7 @@ inline void spdlog::async_logger::_set_pattern(const std::string& pattern)
}
inline
void
spdlog
::
async_logger
::
_
log_msg
(
details
::
log_msg
&
msg
)
inline
void
spdlog
::
async_logger
::
_
sink_it
(
details
::
log_msg
&
msg
)
{
_async_log_helper
->
log
(
msg
);
}
include/spdlog/details/line_logger_fwd.h
deleted
100644 → 0
View file @
34bb86b2
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
#include <spdlog/common.h>
#include <spdlog/details/log_msg.h>
#include <string>
// Line logger class - aggregates operator<< calls to fast ostream
// and logs upon destruction
namespace
spdlog
{
// Forward declaration
class
logger
;
namespace
details
{
class
line_logger
{
public:
line_logger
(
logger
*
callback_logger
,
level
::
level_enum
msg_level
,
bool
enabled
);
// No copy intended. Only move
line_logger
(
const
line_logger
&
other
)
=
delete
;
line_logger
&
operator
=
(
const
line_logger
&
)
=
delete
;
line_logger
&
operator
=
(
line_logger
&&
)
=
delete
;
line_logger
(
line_logger
&&
other
);
//Log the log message using the callback logger
~
line_logger
();
//
// Support for format string with variadic args
//
void
write
(
const
char
*
what
);
template
<
typename
...
Args
>
void
write
(
const
char
*
fmt
,
const
Args
&
...
args
);
//
// Support for operator<<
//
DEPRECATED
line_logger
&
operator
<<
(
const
char
*
what
);
DEPRECATED
line_logger
&
operator
<<
(
const
std
::
string
&
what
);
DEPRECATED
line_logger
&
operator
<<
(
int
what
);
DEPRECATED
line_logger
&
operator
<<
(
unsigned
int
what
);
DEPRECATED
line_logger
&
operator
<<
(
long
what
);
DEPRECATED
line_logger
&
operator
<<
(
unsigned
long
what
);
DEPRECATED
line_logger
&
operator
<<
(
long
long
what
);
DEPRECATED
line_logger
&
operator
<<
(
unsigned
long
long
what
);
DEPRECATED
line_logger
&
operator
<<
(
double
what
);
DEPRECATED
line_logger
&
operator
<<
(
long
double
what
);
DEPRECATED
line_logger
&
operator
<<
(
float
what
);
DEPRECATED
line_logger
&
operator
<<
(
char
what
);
//Support user types which implements operator<<
template
<
typename
T
>
DEPRECATED
line_logger
&
operator
<<
(
const
T
&
what
);
void
disable
();
bool
is_enabled
()
const
;
private:
logger
*
_callback_logger
;
log_msg
_log_msg
;
bool
_enabled
;
};
}
//Namespace details
}
// Namespace spdlog
include/spdlog/details/line_logger_impl.h
deleted
100644 → 0
View file @
34bb86b2
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
#include <type_traits>
#include <spdlog/details/line_logger_fwd.h>
#include <spdlog/common.h>
#include <spdlog/logger.h>
#include <string>
#include <utility>
// Line logger class - aggregates operator<< calls to fast ostream
// and logs upon destruction
inline
spdlog
::
details
::
line_logger
::
line_logger
(
logger
*
callback_logger
,
level
::
level_enum
msg_level
,
bool
enabled
)
:
_callback_logger
(
callback_logger
),
_log_msg
(
msg_level
),
_enabled
(
enabled
)
{}
inline
spdlog
::
details
::
line_logger
::
line_logger
(
line_logger
&&
other
)
:
_callback_logger
(
other
.
_callback_logger
),
_log_msg
(
std
::
move
(
other
.
_log_msg
)),
_enabled
(
other
.
_enabled
)
{
other
.
disable
();
}
//Log the log message using the callback logger
inline
spdlog
::
details
::
line_logger
::~
line_logger
()
{
if
(
_enabled
)
{
#ifndef SPDLOG_NO_NAME
_log_msg
.
logger_name
=
_callback_logger
->
name
();
#endif
#ifndef SPDLOG_NO_DATETIME
_log_msg
.
time
=
os
::
now
();
#endif
#ifndef SPDLOG_NO_THREAD_ID
_log_msg
.
thread_id
=
os
::
thread_id
();
#endif
_callback_logger
->
_log_msg
(
_log_msg
);
}
}
//
// Support for format string with variadic args
//
inline
void
spdlog
::
details
::
line_logger
::
write
(
const
char
*
what
)
{
if
(
_enabled
)
_log_msg
.
raw
<<
what
;
}
template
<
typename
...
Args
>
inline
void
spdlog
::
details
::
line_logger
::
write
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
if
(
!
_enabled
)
return
;
try
{
_log_msg
.
raw
.
write
(
fmt
,
args
...);
}
catch
(
const
fmt
::
FormatError
&
e
)
{
throw
spdlog_ex
(
fmt
::
format
(
"formatting error while processing format string '{}': {}"
,
fmt
,
e
.
what
()));
}
}
//
// Support for operator<<
//
inline
spdlog
::
details
::
line_logger
&
spdlog
::
details
::
line_logger
::
operator
<<
(
const
char
*
what
)
{
if
(
_enabled
)
_log_msg
.
raw
<<
what
;
return
*
this
;
}
inline
spdlog
::
details
::
line_logger
&
spdlog
::
details
::
line_logger
::
operator
<<
(
const
std
::
string
&
what
)
{
if
(
_enabled
)
_log_msg
.
raw
<<
what
;
return
*
this
;
}
inline
spdlog
::
details
::
line_logger
&
spdlog
::
details
::
line_logger
::
operator
<<
(
int
what
)
{
if
(
_enabled
)
_log_msg
.
raw
<<
what
;
return
*
this
;
}
inline
spdlog
::
details
::
line_logger
&
spdlog
::
details
::
line_logger
::
operator
<<
(
unsigned
int
what
)
{
if
(
_enabled
)
_log_msg
.
raw
<<
what
;
return
*
this
;
}
inline
spdlog
::
details
::
line_logger
&
spdlog
::
details
::
line_logger
::
operator
<<
(
long
what
)
{
if
(
_enabled
)
_log_msg
.
raw
<<
what
;
return
*
this
;
}
inline
spdlog
::
details
::
line_logger
&
spdlog
::
details
::
line_logger
::
operator
<<
(
unsigned
long
what
)
{
if
(
_enabled
)
_log_msg
.
raw
<<
what
;
return
*
this
;
}
inline
spdlog
::
details
::
line_logger
&
spdlog
::
details
::
line_logger
::
operator
<<
(
long
long
what
)
{
if
(
_enabled
)
_log_msg
.
raw
<<
what
;
return
*
this
;
}
inline
spdlog
::
details
::
line_logger
&
spdlog
::
details
::
line_logger
::
operator
<<
(
unsigned
long
long
what
)
{
if
(
_enabled
)
_log_msg
.
raw
<<
what
;
return
*
this
;
}
inline
spdlog
::
details
::
line_logger
&
spdlog
::
details
::
line_logger
::
operator
<<
(
double
what
)
{
if
(
_enabled
)
_log_msg
.
raw
<<
what
;
return
*
this
;
}
inline
spdlog
::
details
::
line_logger
&
spdlog
::
details
::
line_logger
::
operator
<<
(
long
double
what
)
{
if
(
_enabled
)
_log_msg
.
raw
<<
what
;
return
*
this
;
}
inline
spdlog
::
details
::
line_logger
&
spdlog
::
details
::
line_logger
::
operator
<<
(
float
what
)
{
if
(
_enabled
)
_log_msg
.
raw
<<
what
;
return
*
this
;
}
inline
spdlog
::
details
::
line_logger
&
spdlog
::
details
::
line_logger
::
operator
<<
(
char
what
)
{
if
(
_enabled
)
_log_msg
.
raw
<<
what
;
return
*
this
;
}
//Support user types which implements operator<<
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
&
spdlog
::
details
::
line_logger
::
operator
<<
(
const
T
&
what
)
{
if
(
_enabled
)
_log_msg
.
raw
.
write
(
"{}"
,
what
);
return
*
this
;
}
inline
void
spdlog
::
details
::
line_logger
::
disable
()
{
_enabled
=
false
;
}
inline
bool
spdlog
::
details
::
line_logger
::
is_enabled
()
const
{
return
_enabled
;
}
include/spdlog/details/log_msg.h
View file @
451aadec
...
...
@@ -7,6 +7,7 @@
#include <spdlog/common.h>
#include <spdlog/details/format.h>
#include <spdlog/details/os.h>
#include <string>
#include <utility>
...
...
@@ -18,59 +19,23 @@ namespace details
struct
log_msg
{
log_msg
()
=
default
;
log_msg
(
level
::
level_enum
l
)
:
logger_name
(),
level
(
l
),
raw
(),
formatted
()
{}
log_msg
(
const
log_msg
&
other
)
:
logger_name
(
other
.
logger_name
),
level
(
other
.
level
),
time
(
other
.
time
),
thread_id
(
other
.
thread_id
)
log_msg
(
const
std
::
string
*
loggers_name
,
level
::
level_enum
lvl
)
:
logger_name
(
loggers_name
),
level
(
lvl
)
{
if
(
other
.
raw
.
size
())
raw
<<
fmt
::
BasicStringRef
<
char
>
(
other
.
raw
.
data
(),
other
.
raw
.
size
());
if
(
other
.
formatted
.
size
())
formatted
<<
fmt
::
BasicStringRef
<
char
>
(
other
.
formatted
.
data
(),
other
.
formatted
.
size
());
}
#ifndef SPDLOG_NO_DATETIME
time
=
os
::
now
();
#endif
log_msg
(
log_msg
&&
other
)
:
logger_name
(
std
::
move
(
other
.
logger_name
)),
level
(
other
.
level
),
time
(
std
::
move
(
other
.
time
)),
thread_id
(
other
.
thread_id
),
raw
(
std
::
move
(
other
.
raw
)),
formatted
(
std
::
move
(
other
.
formatted
))
{
other
.
clear
();
#ifndef SPDLOG_NO_THREAD_ID
thread_id
=
os
::
thread_id
();
#endif
}
log_msg
&
operator
=
(
log_msg
&&
other
)
{
if
(
this
==
&
other
)
return
*
this
;
log_msg
(
const
log_msg
&
other
)
=
delete
;
log_msg
&
operator
=
(
log_msg
&&
other
)
=
delete
;
log_msg
(
log_msg
&&
other
)
=
delete
;
logger_name
=
std
::
move
(
other
.
logger_name
);
level
=
other
.
level
;
time
=
std
::
move
(
other
.
time
);
thread_id
=
other
.
thread_id
;
raw
=
std
::
move
(
other
.
raw
);
formatted
=
std
::
move
(
other
.
formatted
);
other
.
clear
();
return
*
this
;
}
void
clear
()
{
level
=
level
::
off
;
raw
.
clear
();
formatted
.
clear
();
}
std
::
string
logger_name
;
const
std
::
string
*
logger_name
;
level
::
level_enum
level
;
log_clock
::
time_point
time
;
size_t
thread_id
;
...
...
include/spdlog/details/logger_impl.h
View file @
451aadec
...
...
@@ -31,8 +31,7 @@ inline spdlog::logger::logger(const std::string& logger_name, sinks_init_list si
// ctor with single sink
inline
spdlog
::
logger
::
logger
(
const
std
::
string
&
logger_name
,
spdlog
::
sink_ptr
single_sink
)
:
logger
(
logger_name
,
{
logger
(
logger_name
,
{
single_sink
})
{}
...
...
@@ -50,210 +49,131 @@ inline void spdlog::logger::set_pattern(const std::string& pattern)
_set_pattern
(
pattern
);
}
//
// log only if given level>=logger's log level
//
template
<
typename
...
Args
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
_log_if_enabled
(
level
::
level_enum
lvl
,
const
char
*
fmt
,
const
Args
&
...
args
)
inline
void
spdlog
::
logger
::
log
(
level
::
level_enum
lvl
,
const
char
*
fmt
,
const
Args
&
...
args
)
{
bool
msg_enabled
=
should_log
(
lvl
);
details
::
line_logger
l
(
this
,
lvl
,
msg_enabled
);
l
.
write
(
fmt
,
args
...);
return
l
;
}
if
(
!
should_log
(
lvl
))
return
;
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
_log_if_enabled
(
level
::
level_enum
lvl
)
{
return
details
::
line_logger
(
this
,
lvl
,
should_log
(
lvl
));
}
details
::
log_msg
log_msg
(
&
_name
,
lvl
);
try
{
log_msg
.
raw
.
write
(
fmt
,
args
...);
}
catch
(
fmt
::
FormatError
&
ex
)
{
throw
spdlog
::
spdlog_ex
(
std
::
string
(
"format error in
\"
"
)
+
fmt
+
"
\"
: "
+
ex
.
what
());
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
_log_if_enabled
(
level
::
level_enum
lvl
,
const
T
&
msg
)
{
bool
msg_enabled
=
should_log
(
lvl
);
details
::
line_logger
l
(
this
,
lvl
,
msg_enabled
);
l
.
write
(
"{}"
,
msg
);
return
l
;
}
_formatter
->
format
(
log_msg
);
_sink_it
(
log_msg
);
//
// logger.info(cppformat_string, arg1, arg2, arg3, ...) call style
//
template
<
typename
...
Args
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
trace
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
return
_log_if_enabled
(
level
::
trace
,
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
debug
(
const
char
*
fmt
,
const
Args
&
...
args
)
inline
void
spdlog
::
logger
::
log
(
level
::
level_enum
lvl
,
const
char
*
msg
)
{
return
_log_if_enabled
(
level
::
debug
,
fmt
,
args
...);
if
(
!
should_log
(
lvl
))
return
;
details
::
log_msg
log_msg
(
&
_name
,
lvl
);
log_msg
.
raw
<<
msg
;
_formatter
->
format
(
log_msg
);
_sink_it
(
log_msg
);
}
template
<
typename
...
Args
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
info
(
const
char
*
fmt
,
const
Args
&
...
args
)
template
<
typename
T
>
inline
void
spdlog
::
logger
::
log
(
level
::
level_enum
lvl
,
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
info
,
fmt
,
args
...);
if
(
!
should_log
(
lvl
))
return
;
details
::
log_msg
log_msg
(
&
_name
,
lvl
);
log_msg
.
raw
<<
msg
;
_formatter
->
format
(
log_msg
);
_sink_it
(
log_msg
);
}
template
<
typename
...
Args
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
noti
ce
(
const
char
*
fmt
,
const
Args
&
...
args
)
inline
void
spdlog
::
logger
::
tra
ce
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
return
_log_if_enabled
(
level
::
noti
ce
,
fmt
,
args
...);
log
(
level
::
tra
ce
,
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
warn
(
const
char
*
fmt
,
const
Args
&
...
args
)
inline
void
spdlog
::
logger
::
debug
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
return
_log_if_enabled
(
level
::
warn
,
fmt
,
args
...);
log
(
level
::
debug
,
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
error
(
const
char
*
fmt
,
const
Args
&
...
args
)
inline
void
spdlog
::
logger
::
info
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
return
_log_if_enabled
(
level
::
err
,
fmt
,
args
...);
log
(
level
::
info
,
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
critical
(
const
char
*
fmt
,
const
Args
&
...
args
)
inline
void
spdlog
::
logger
::
warn
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
return
_log_if_enabled
(
level
::
critical
,
fmt
,
args
...);
log
(
level
::
warn
,
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
alert
(
const
char
*
fmt
,
const
Args
&
...
args
)
inline
void
spdlog
::
logger
::
error
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
return
_log_if_enabled
(
level
::
alert
,
fmt
,
args
...);
log
(
level
::
err
,
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
emerg
(
const
char
*
fmt
,
const
Args
&
...
args
)
inline
void
spdlog
::
logger
::
critical
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
return
_log_if_enabled
(
level
::
emerg
,
fmt
,
args
...);
log
(
level
::
critical
,
fmt
,
args
...);
}
//
// logger.info(msg) << ".." call style
//
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
trace
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
trace
,
msg
);
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
debug
(
const
T
&
msg
)
inline
void
spdlog
::
logger
::
trace
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
debug
,
msg
);
log
(
level
::
trace
,
msg
);
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
info
(
const
T
&
msg
)
inline
void
spdlog
::
logger
::
debug
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
info
,
msg
);
log
(
level
::
debug
,
msg
);
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
notice
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
notice
,
msg
);
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
warn
(
const
T
&
msg
)
inline
void
spdlog
::
logger
::
info
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
warn
,
msg
);
log
(
level
::
info
,
msg
);
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
error
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
err
,
msg
);
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
critical
(
const
T
&
msg
)
inline
void
spdlog
::
logger
::
warn
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
critical
,
msg
);
log
(
level
::
warn
,
msg
);
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
alert
(
const
T
&
msg
)
inline
void
spdlog
::
logger
::
error
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
alert
,
msg
);
log
(
level
::
err
,
msg
);
}
template
<
typename
T
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
emerg
(
const
T
&
msg
)
inline
void
spdlog
::
logger
::
critical
(
const
T
&
msg
)
{
return
_log_if_enabled
(
level
::
emerg
,
msg
);
log
(
level
::
critical
,
msg
);
}
//
// logger.info() << ".." call style
//
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
trace
()
{
return
_log_if_enabled
(
level
::
trace
);
}
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
debug
()
{
return
_log_if_enabled
(
level
::
debug
);
}
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
info
()
{
return
_log_if_enabled
(
level
::
info
);
}
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
notice
()
{
return
_log_if_enabled
(
level
::
notice
);
}
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
warn
()
{
return
_log_if_enabled
(
level
::
warn
);
}
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
error
()
{
return
_log_if_enabled
(
level
::
err
);
}
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
critical
()
{
return
_log_if_enabled
(
level
::
critical
);
}
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
alert
()
{
return
_log_if_enabled
(
level
::
alert
);
}
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
emerg
()
{
return
_log_if_enabled
(
level
::
emerg
);
}
// always log, no matter what is the actual logger's log level
template
<
typename
...
Args
>
inline
spdlog
::
details
::
line_logger
spdlog
::
logger
::
force_log
(
level
::
level_enum
lvl
,
const
char
*
fmt
,
const
Args
&
...
args
)
{
details
::
line_logger
l
(
this
,
lvl
,
true
);
l
.
write
(
fmt
,
args
...);
return
l
;
}
//
// name and level
//
...
...
@@ -285,9 +205,8 @@ inline bool spdlog::logger::should_log(spdlog::level::level_enum msg_level) cons
//
// protected virtual called at end of each user log call (if enabled) by the line_logger
//
inline
void
spdlog
::
logger
::
_
log_msg
(
details
::
log_msg
&
msg
)
inline
void
spdlog
::
logger
::
_
sink_it
(
details
::
log_msg
&
msg
)
{
_formatter
->
format
(
msg
);
for
(
auto
&
sink
:
_sinks
)
sink
->
log
(
msg
);
...
...
include/spdlog/details/pattern_formatter_impl.h
View file @
451aadec
...
...
@@ -39,7 +39,7 @@ class name_formatter :public flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
)
override
{
msg
.
formatted
<<
msg
.
logger_name
;
msg
.
formatted
<<
*
msg
.
logger_name
;
}
};
}
...
...
@@ -435,7 +435,7 @@ class full_formatter :public flag_formatter
#endif
#ifndef SPDLOG_NO_NAME
msg
.
formatted
<<
'['
<<
msg
.
logger_name
<<
"] "
;
msg
.
formatted
<<
'['
<<
*
msg
.
logger_name
<<
"] "
;
#endif
msg
.
formatted
<<
'['
<<
level
::
to_str
(
msg
.
level
)
<<
"] "
;
...
...
@@ -613,7 +613,11 @@ inline void spdlog::pattern_formatter::format(details::log_msg& msg)
{
try
{
#ifndef SPDLOG_NO_DATETIME
auto
tm_time
=
details
::
os
::
localtime
(
log_clock
::
to_time_t
(
msg
.
time
));
#else
std
::
tm
tm_time
;
#endif
for
(
auto
&
f
:
_formatters
)
{
f
->
format
(
msg
,
tm_time
);
...
...
include/spdlog/logger.h
View file @
451aadec
...
...
@@ -14,12 +14,12 @@
#include <spdlog/sinks/base_sink.h>
#include <spdlog/common.h>
#include <spdlog/details/line_logger_fwd.h>
#include <vector>
#include <memory>
#include <string>
namespace
spdlog
{
...
...
@@ -35,75 +35,42 @@ public:
logger
(
const
logger
&
)
=
delete
;
logger
&
operator
=
(
const
logger
&
)
=
delete
;
void
set_level
(
level
::
level_enum
);
level
::
level_enum
level
()
const
;
const
std
::
string
&
name
()
const
;
bool
should_log
(
level
::
level_enum
)
const
;
template
<
typename
...
Args
>
void
log
(
level
::
level_enum
lvl
,
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
void
log
(
level
::
level_enum
lvl
,
const
char
*
msg
);
template
<
typename
...
Args
>
void
trace
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
void
debug
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
void
info
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
void
warn
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
void
error
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
void
critical
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
T
>
void
log
(
level
::
level_enum
lvl
,
const
T
&
);
template
<
typename
T
>
void
trace
(
const
T
&
);
template
<
typename
T
>
void
debug
(
const
T
&
);
template
<
typename
T
>
void
info
(
const
T
&
);
template
<
typename
T
>
void
warn
(
const
T
&
);
template
<
typename
T
>
void
error
(
const
T
&
);
template
<
typename
T
>
void
critical
(
const
T
&
);
// automatically call flush() after a message of level log_level or higher is emitted
void
flush_on
(
level
::
level_enum
log_level
);
// logger.info(cppformat_string, arg1, arg2, arg3, ...) call style
template
<
typename
...
Args
>
details
::
line_logger
trace
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
details
::
line_logger
debug
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
details
::
line_logger
info
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
details
::
line_logger
notice
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
details
::
line_logger
warn
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
details
::
line_logger
error
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
details
::
line_logger
critical
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
details
::
line_logger
alert
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
details
::
line_logger
emerg
(
const
char
*
fmt
,
const
Args
&
...
args
);
// logger.info(msg) << ".." call style
template
<
typename
T
>
details
::
line_logger
trace
(
const
T
&
);
template
<
typename
T
>
details
::
line_logger
debug
(
const
T
&
);
template
<
typename
T
>
details
::
line_logger
info
(
const
T
&
);
template
<
typename
T
>
details
::
line_logger
notice
(
const
T
&
);
template
<
typename
T
>
details
::
line_logger
warn
(
const
T
&
);
template
<
typename
T
>
details
::
line_logger
error
(
const
T
&
);
template
<
typename
T
>
details
::
line_logger
critical
(
const
T
&
);
template
<
typename
T
>
details
::
line_logger
alert
(
const
T
&
);
template
<
typename
T
>
details
::
line_logger
emerg
(
const
T
&
);
// logger.info() << ".." call style
details
::
line_logger
trace
();
details
::
line_logger
debug
();
details
::
line_logger
info
();
details
::
line_logger
notice
();
details
::
line_logger
warn
();
details
::
line_logger
error
();
details
::
line_logger
critical
();
details
::
line_logger
alert
();
details
::
line_logger
emerg
();
// Create log message with the given level, no matter what is the actual logger's level
template
<
typename
...
Args
>
details
::
line_logger
force_log
(
level
::
level_enum
lvl
,
const
char
*
fmt
,
const
Args
&
...
args
);
// Set the format of the log messages from this logger
bool
should_log
(
level
::
level_enum
)
const
;
void
set_level
(
level
::
level_enum
);
level
::
level_enum
level
()
const
;
const
std
::
string
&
name
()
const
;
void
set_pattern
(
const
std
::
string
&
);
void
set_formatter
(
formatter_ptr
);
// automatically call flush() if message level >= log_level
void
flush_on
(
level
::
level_enum
log_level
);
virtual
void
flush
();
protected:
virtual
void
_
log_msg
(
details
::
log_msg
&
);
virtual
void
_
sink_it
(
details
::
log_msg
&
);
virtual
void
_set_pattern
(
const
std
::
string
&
);
virtual
void
_set_formatter
(
formatter_ptr
);
details
::
line_logger
_log_if_enabled
(
level
::
level_enum
lvl
);
template
<
typename
...
Args
>
details
::
line_logger
_log_if_enabled
(
level
::
level_enum
lvl
,
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
T
>
inline
details
::
line_logger
_log_if_enabled
(
level
::
level_enum
lvl
,
const
T
&
msg
);
friend
details
::
line_logger
;
std
::
string
_name
;
const
std
::
string
_name
;
std
::
vector
<
sink_ptr
>
_sinks
;
formatter_ptr
_formatter
;
spdlog
::
level_t
_level
;
...
...
@@ -112,5 +79,5 @@ protected:
}
#include <spdlog/details/logger_impl.h>
#include <spdlog/details/line_logger_impl.h>
include/spdlog/sinks/ansicolor_sink.h
View file @
451aadec
...
...
@@ -74,13 +74,10 @@ inline ansicolor_sink::ansicolor_sink(sink_ptr wrapped_sink) : sink_(wrapped_sin
{
colors_
[
level
::
trace
]
=
cyan
;
colors_
[
level
::
debug
]
=
cyan
;
colors_
[
level
::
info
]
=
white
;
colors_
[
level
::
notice
]
=
bold
+
white
;
colors_
[
level
::
warn
]
=
bold
+
yellow
;
colors_
[
level
::
err
]
=
red
;
colors_
[
level
::
critical
]
=
bold
+
red
;
colors_
[
level
::
alert
]
=
bold
+
white
+
on_red
;
colors_
[
level
::
emerg
]
=
bold
+
yellow
+
on_red
;
colors_
[
level
::
info
]
=
bold
;
colors_
[
level
::
warn
]
=
yellow
+
bold
;
colors_
[
level
::
err
]
=
red
+
bold
;
colors_
[
level
::
critical
]
=
bold
+
on_red
;
colors_
[
level
::
off
]
=
reset
;
}
...
...
@@ -91,6 +88,10 @@ inline void ansicolor_sink::log(const details::log_msg& msg)
const
std
::
string
&
s
=
msg
.
formatted
.
str
();
const
std
::
string
&
suffix
=
reset
;
details
::
log_msg
m
;
m
.
level
=
msg
.
level
;
m
.
logger_name
=
msg
.
logger_name
;
m
.
time
=
msg
.
time
;
m
.
thread_id
=
msg
.
thread_id
;
m
.
formatted
<<
prefix
<<
s
<<
suffix
;
sink_
->
log
(
m
);
}
...
...
include/spdlog/sinks/syslog_sink.h
View file @
451aadec
...
...
@@ -35,12 +35,9 @@ public:
_priorities
[
static_cast
<
int
>
(
level
::
trace
)]
=
LOG_DEBUG
;
_priorities
[
static_cast
<
int
>
(
level
::
debug
)]
=
LOG_DEBUG
;
_priorities
[
static_cast
<
int
>
(
level
::
info
)]
=
LOG_INFO
;
_priorities
[
static_cast
<
int
>
(
level
::
notice
)]
=
LOG_NOTICE
;
_priorities
[
static_cast
<
int
>
(
level
::
warn
)]
=
LOG_WARNING
;
_priorities
[
static_cast
<
int
>
(
level
::
err
)]
=
LOG_ERR
;
_priorities
[
static_cast
<
int
>
(
level
::
critical
)]
=
LOG_CRIT
;
_priorities
[
static_cast
<
int
>
(
level
::
alert
)]
=
LOG_ALERT
;
_priorities
[
static_cast
<
int
>
(
level
::
emerg
)]
=
LOG_EMERG
;
_priorities
[
static_cast
<
int
>
(
level
::
off
)]
=
LOG_INFO
;
//set ident to be program name if empty
...
...
@@ -65,7 +62,7 @@ public:
private:
std
::
array
<
int
,
10
>
_priorities
;
std
::
array
<
int
,
7
>
_priorities
;
//must store the ident because the man says openlog might use the pointer as is and not a string copy
const
std
::
string
_ident
;
...
...
include/spdlog/spdlog.h
View file @
451aadec
...
...
@@ -134,14 +134,15 @@ void drop_all();
// SPDLOG_DEBUG(my_logger, "Some debug message {} {}", 1, 3.2);
///////////////////////////////////////////////////////////////////////////////
#ifdef SPDLOG_TRACE_ON
#define SPDLOG_TRACE(logger, ...)
logger->trace(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")"
;
#define SPDLOG_TRACE(logger, ...)
logger->trace(__FILE__ ## " line " ## SPDLOG_STR(__LINE__) ## ": " ## __VA_ARGS__)
;
#else
#define SPDLOG_TRACE(logger, ...)
#endif
#ifdef SPDLOG_DEBUG_ON
#define SPDLOG_DEBUG(logger, ...) logger->debug(__VA_ARGS__)
<< " (" << __FILE__ << " #" << __LINE__ <<")";
#define SPDLOG_DEBUG(logger, ...) logger->debug(__VA_ARGS__)
#else
#define SPDLOG_DEBUG(logger, ...)
#endif
...
...
include/spdlog/tweakme.h
View file @
451aadec
...
...
@@ -5,21 +5,28 @@
#pragma once
///////////////////////////////////////////////////////////////////////////////
//
// Edit this file to squeeze every last drop of performance out of spdlog.
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Under Linux, the much faster CLOCK_REALTIME_COARSE clock can be used.
// This clock is less accurate - can be off by dozens of millis - depending on the kernel HZ.
// Uncomment to use it instead of the regular (but slower) clock.
// Uncomment to use it instead of the regular clock.
//
// #define SPDLOG_CLOCK_COARSE
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment if date/time logging is not needed.
// Uncomment if date/time logging is not needed
and never appear in the log pattern
.
// This will prevent spdlog from quering the clock on each log call.
//
// WARNING: If the log pattern contains any date/time while this flag is on, the result is undefined.
// You must set new pattern(spdlog::set_pattern(..") without any date/time in it
//
// #define SPDLOG_NO_DATETIME
///////////////////////////////////////////////////////////////////////////////
...
...
@@ -27,6 +34,9 @@
///////////////////////////////////////////////////////////////////////////////
// Uncomment if thread id logging is not needed (i.e. no %t in the log pattern).
// This will prevent spdlog from quering the thread id on each log call.
//
// WARNING: If the log pattern contains thread id (i.e, %t) while this flag is on, the result is undefined.
//
// #define SPDLOG_NO_THREAD_ID
///////////////////////////////////////////////////////////////////////////////
...
...
@@ -34,12 +44,14 @@
///////////////////////////////////////////////////////////////////////////////
// Uncomment if logger name logging is not needed.
// This will prevent spdlog from copying the logger name on each log call.
//
// #define SPDLOG_NO_NAME
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to enable the SPDLOG_DEBUG/SPDLOG_TRACE macros.
//
// #define SPDLOG_DEBUG_ON
// #define SPDLOG_TRACE_ON
///////////////////////////////////////////////////////////////////////////////
...
...
@@ -49,18 +61,21 @@
// Uncomment to avoid locking in the registry operations (spdlog::get(), spdlog::drop() spdlog::register()).
// Use only if your code never modifes concurrently the registry.
// Note that upon creating a logger the registry is modified by spdlog..
//
// #define SPDLOG_NO_REGISTRY_MUTEX
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to avoid spdlog's usage of atomic log levels
// Use only if your code never modifies a logger's log levels concurrently.
// Use only if your code never modifies a logger's log levels concurrently by different threads.
//
// #define SPDLOG_NO_ATOMIC_LEVELS
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to enable usage of wchar_t for file names on Windows.
//
// #define SPDLOG_WCHAR_FILENAMES
///////////////////////////////////////////////////////////////////////////////
...
...
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