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
7ddfb2b8
Commit
7ddfb2b8
authored
Jul 09, 2016
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed macros and other stuff for the no-streams branch
parent
7885aa47
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
44 additions
and
86 deletions
+44
-86
example/example.cpp
example/example.cpp
+3
-3
include/spdlog/common.h
include/spdlog/common.h
+20
-12
include/spdlog/details/log_msg.h
include/spdlog/details/log_msg.h
+2
-2
include/spdlog/details/logger_impl.h
include/spdlog/details/logger_impl.h
+5
-44
include/spdlog/logger.h
include/spdlog/logger.h
+4
-10
include/spdlog/sinks/ansicolor_sink.h
include/spdlog/sinks/ansicolor_sink.h
+6
-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
No files found.
example/example.cpp
View file @
7ddfb2b8
...
...
@@ -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"
);
...
...
include/spdlog/common.h
View file @
7ddfb2b8
...
...
@@ -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/log_msg.h
View file @
7ddfb2b8
...
...
@@ -19,7 +19,7 @@ namespace details
struct
log_msg
{
log_msg
()
=
default
;
log_msg
(
std
::
string
*
loggers_name
,
level
::
level_enum
lvl
)
:
logger_name
(
loggers_name
),
level
(
lvl
)
log_msg
(
const
std
::
string
*
loggers_name
,
level
::
level_enum
lvl
)
:
logger_name
(
loggers_name
),
level
(
lvl
)
{
#ifndef SPDLOG_NO_DATETIME
time
=
os
::
now
();
...
...
@@ -35,7 +35,7 @@ struct log_msg
log_msg
(
log_msg
&&
other
)
=
delete
;
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 @
7ddfb2b8
...
...
@@ -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
})
{}
...
...
@@ -54,8 +53,7 @@ inline void spdlog::logger::set_pattern(const std::string& pattern)
template
<
typename
...
Args
>
inline
void
spdlog
::
logger
::
log
(
level
::
level_enum
lvl
,
const
char
*
fmt
,
const
Args
&
...
args
)
{
if
(
!
should_log
(
lvl
))
return
;
if
(
!
should_log
(
lvl
))
return
;
details
::
log_msg
log_msg
(
&
_name
,
lvl
);
try
...
...
@@ -75,9 +73,7 @@ inline void spdlog::logger::log(level::level_enum lvl, const char* fmt, const Ar
template
<
typename
...
Args
>
inline
void
spdlog
::
logger
::
log
(
level
::
level_enum
lvl
,
const
char
*
msg
)
{
if
(
!
should_log
(
lvl
))
return
;
if
(
!
should_log
(
lvl
))
return
;
details
::
log_msg
log_msg
(
&
_name
,
lvl
);
log_msg
.
raw
<<
msg
;
...
...
@@ -89,10 +85,9 @@ inline void spdlog::logger::log(level::level_enum lvl, const char* msg)
template
<
typename
T
>
inline
void
spdlog
::
logger
::
log
(
level
::
level_enum
lvl
,
const
T
&
msg
)
{
if
(
!
should_log
(
lvl
))
return
;
details
::
log_msg
log_msg
(
&
_name
,
lvl
);
if
(
!
should_log
(
lvl
))
return
;
details
::
log_msg
log_msg
(
&
_name
,
lvl
);
log_msg
.
raw
<<
msg
;
_formatter
->
format
(
log_msg
);
_sink_it
(
log_msg
);
...
...
@@ -118,11 +113,6 @@ inline void spdlog::logger::info(const char* fmt, const Args&... args)
log
(
level
::
info
,
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
void
spdlog
::
logger
::
notice
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
log
(
level
::
notice
,
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
void
spdlog
::
logger
::
warn
(
const
char
*
fmt
,
const
Args
&
...
args
)
...
...
@@ -142,19 +132,6 @@ inline void spdlog::logger::critical(const char* fmt, const Args&... args)
log
(
level
::
critical
,
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
void
spdlog
::
logger
::
alert
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
log
(
level
::
alert
,
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
void
spdlog
::
logger
::
emerg
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
log
(
level
::
emerg
,
fmt
,
args
...);
}
template
<
typename
T
>
inline
void
spdlog
::
logger
::
trace
(
const
T
&
msg
)
...
...
@@ -175,11 +152,6 @@ inline void spdlog::logger::info(const T& msg)
log
(
level
::
info
,
msg
);
}
template
<
typename
T
>
inline
void
spdlog
::
logger
::
notice
(
const
T
&
msg
)
{
log
(
level
::
notice
,
msg
);
}
template
<
typename
T
>
inline
void
spdlog
::
logger
::
warn
(
const
T
&
msg
)
...
...
@@ -199,17 +171,6 @@ inline void spdlog::logger::critical(const T& msg)
log
(
level
::
critical
,
msg
);
}
template
<
typename
T
>
inline
void
spdlog
::
logger
::
alert
(
const
T
&
msg
)
{
log
(
level
::
alert
,
msg
);
}
template
<
typename
T
>
inline
void
spdlog
::
logger
::
emerg
(
const
T
&
msg
)
{
log
(
level
::
emerg
,
msg
);
}
...
...
include/spdlog/logger.h
View file @
7ddfb2b8
...
...
@@ -35,30 +35,24 @@ public:
logger
(
const
logger
&
)
=
delete
;
logger
&
operator
=
(
const
logger
&
)
=
delete
;
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
T
>
void
log
(
level
::
level_enum
lvl
,
const
T
&
);
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
notice
(
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
...
Args
>
void
alert
(
const
char
*
fmt
,
const
Args
&
...
args
);
template
<
typename
...
Args
>
void
emerg
(
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
notice
(
const
T
&
);
template
<
typename
T
>
void
warn
(
const
T
&
);
template
<
typename
T
>
void
error
(
const
T
&
);
template
<
typename
T
>
void
critical
(
const
T
&
);
template
<
typename
T
>
void
alert
(
const
T
&
);
template
<
typename
T
>
void
emerg
(
const
T
&
);
bool
should_log
(
level
::
level_enum
)
const
;
void
set_level
(
level
::
level_enum
);
...
...
@@ -76,7 +70,7 @@ protected:
virtual
void
_set_pattern
(
const
std
::
string
&
);
virtual
void
_set_formatter
(
formatter_ptr
);
std
::
string
_name
;
const
std
::
string
_name
;
std
::
vector
<
sink_ptr
>
_sinks
;
formatter_ptr
_formatter
;
spdlog
::
level_t
_level
;
...
...
include/spdlog/sinks/ansicolor_sink.h
View file @
7ddfb2b8
...
...
@@ -72,15 +72,12 @@ protected:
inline
ansicolor_sink
::
ansicolor_sink
(
sink_ptr
wrapped_sink
)
:
sink_
(
wrapped_sink
)
{
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
::
trace
]
=
cyan
;
colors_
[
level
::
debug
]
=
cyan
;
colors_
[
level
::
info
]
=
bold
;
colors_
[
level
::
warn
]
=
yellow
+
bold
;
colors_
[
level
::
err
]
=
red
+
bold
;
colors_
[
level
::
critical
]
=
bold
+
on_red
;
colors_
[
level
::
off
]
=
reset
;
}
...
...
include/spdlog/sinks/syslog_sink.h
View file @
7ddfb2b8
...
...
@@ -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 @
7ddfb2b8
...
...
@@ -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
...
...
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