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
f5831d51
Commit
f5831d51
authored
Jul 05, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clang-format
parent
517ccc40
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
41 deletions
+23
-41
stdout_sinks.h
include/spdlog/sinks/stdout_sinks.h
+0
-1
syslog_sink.h
include/spdlog/sinks/syslog_sink.h
+7
-9
systemd_sink.h
include/spdlog/sinks/systemd_sink.h
+14
-25
spdlog.cpp
src/spdlog.cpp
+0
-1
test_pattern_formatter.cpp
tests/test_pattern_formatter.cpp
+2
-5
No files found.
include/spdlog/sinks/stdout_sinks.h
View file @
f5831d51
...
...
@@ -72,4 +72,3 @@ std::shared_ptr<logger> stderr_logger_st(const std::string &logger_name);
}
// namespace spdlog
#include "stdout_sinks-inl.h"
include/spdlog/sinks/syslog_sink.h
View file @
f5831d51
...
...
@@ -22,15 +22,13 @@ class syslog_sink : public base_sink<Mutex>
public
:
syslog_sink
(
std
::
string
ident
,
int
syslog_option
,
int
syslog_facility
,
bool
enable_formatting
)
:
enable_formatting_
{
enable_formatting
}
,
syslog_levels_
{
/* spdlog::level::trace */
LOG_DEBUG
,
/* spdlog::level::debug */
LOG_DEBUG
,
/* spdlog::level::info */
LOG_INFO
,
/* spdlog::level::warn */
LOG_WARNING
,
/* spdlog::level::err */
LOG_ERR
,
/* spdlog::level::critical */
LOG_CRIT
,
/* spdlog::level::off */
LOG_INFO
}
,
syslog_levels_
{
/* spdlog::level::trace */
LOG_DEBUG
,
/* spdlog::level::debug */
LOG_DEBUG
,
/* spdlog::level::info */
LOG_INFO
,
/* spdlog::level::warn */
LOG_WARNING
,
/* spdlog::level::err */
LOG_ERR
,
/* spdlog::level::critical */
LOG_CRIT
,
/* spdlog::level::off */
LOG_INFO
}
,
ident_
{
std
::
move
(
ident
)}
{
// set ident to be program name if empty
...
...
include/spdlog/sinks/systemd_sink.h
View file @
f5831d51
...
...
@@ -12,7 +12,6 @@
namespace
spdlog
{
namespace
sinks
{
/**
* Sink that write to systemd journal using the `sd_journal_send()` library call.
*
...
...
@@ -23,15 +22,14 @@ class systemd_sink : public base_sink<Mutex>
{
public
:
//
systemd_sink
()
:
syslog_levels_
{
/* spdlog::level::trace */
LOG_DEBUG
,
/* spdlog::level::debug */
LOG_DEBUG
,
/* spdlog::level::info */
LOG_INFO
,
/* spdlog::level::warn */
LOG_WARNING
,
/* spdlog::level::err */
LOG_ERR
,
/* spdlog::level::critical */
LOG_CRIT
,
/* spdlog::level::off */
LOG_INFO
}
systemd_sink
()
:
syslog_levels_
{
/* spdlog::level::trace */
LOG_DEBUG
,
/* spdlog::level::debug */
LOG_DEBUG
,
/* spdlog::level::info */
LOG_INFO
,
/* spdlog::level::warn */
LOG_WARNING
,
/* spdlog::level::err */
LOG_ERR
,
/* spdlog::level::critical */
LOG_CRIT
,
/* spdlog::level::off */
LOG_INFO
}
{}
~
systemd_sink
()
override
{}
...
...
@@ -40,7 +38,6 @@ public:
systemd_sink
&
operator
=
(
const
systemd_sink
&
)
=
delete
;
protected
:
std
::
array
<
int
,
7
>
syslog_levels_
;
void
sink_it_
(
const
details
::
log_msg
&
msg
)
override
...
...
@@ -48,33 +45,25 @@ protected:
int
err
;
// Do not send source location if not available
if
(
msg
.
source
.
empty
())
if
(
msg
.
source
.
empty
())
{
// Note: function call inside '()' to avoid macro expansion
err
=
(
sd_journal_send
)(
"MESSAGE=%.*s"
,
static_cast
<
int
>
(
msg
.
payload
.
size
()),
msg
.
payload
.
data
(),
"PRIORITY=%d"
,
syslog_level
(
msg
.
level
),
nullptr
);
"MESSAGE=%.*s"
,
static_cast
<
int
>
(
msg
.
payload
.
size
()),
msg
.
payload
.
data
(),
"PRIORITY=%d"
,
syslog_level
(
msg
.
level
),
nullptr
);
}
else
{
err
=
(
sd_journal_send
)(
"MESSAGE=%.*s"
,
static_cast
<
int
>
(
msg
.
payload
.
size
()),
msg
.
payload
.
data
(),
"PRIORITY=%d"
,
syslog_level
(
msg
.
level
),
"SOURCE_FILE=%s"
,
msg
.
source
.
filename
,
"SOURCE_LINE=%d"
,
msg
.
source
.
line
,
"SOURCE_FUNC=%s"
,
msg
.
source
.
funcname
,
nullptr
);
err
=
(
sd_journal_send
)(
"MESSAGE=%.*s"
,
static_cast
<
int
>
(
msg
.
payload
.
size
()),
msg
.
payload
.
data
(),
"PRIORITY=%d"
,
syslog_level
(
msg
.
level
),
"SOURCE_FILE=%s"
,
msg
.
source
.
filename
,
"SOURCE_LINE=%d"
,
msg
.
source
.
line
,
"SOURCE_FUNC=%s"
,
msg
.
source
.
funcname
,
nullptr
);
}
if
(
err
)
if
(
err
)
{
throw
spdlog_ex
(
"Failed writing to systemd"
,
errno
);
}
}
int
syslog_level
(
level
::
level_enum
l
)
{
return
syslog_levels_
.
at
(
static_cast
<
int
>
(
l
));
...
...
src/spdlog.cpp
View file @
f5831d51
...
...
@@ -80,7 +80,6 @@ template std::shared_ptr<spdlog::logger> spdlog::stdout_color_st<spdlog::async_f
template
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
stderr_color_mt
<
spdlog
::
async_factory
>
(
const
std
::
string
&
logger_name
,
color_mode
mode
);
template
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
stderr_color_st
<
spdlog
::
async_factory
>
(
const
std
::
string
&
logger_name
,
color_mode
mode
);
// Slightly modified version of fmt lib's format.cc source file.
// Copyright (c) 2012 - 2016, Victor Zverovich
// All rights reserved.
...
...
tests/test_pattern_formatter.cpp
View file @
f5831d51
...
...
@@ -181,19 +181,16 @@ TEST_CASE("center_padded_short", "[pattern_formatter]")
TEST_CASE
(
"left_padded_huge"
,
"[pattern_formatter]"
)
{
REQUIRE
(
log_to_str
(
"Some message"
,
"[%-300n] %v"
,
spdlog
::
pattern_time_type
::
local
,
"
\n
"
)
==
REQUIRE
(
log_to_str
(
"Some message"
,
"[%-300n] %v"
,
spdlog
::
pattern_time_type
::
local
,
"
\n
"
)
==
"[pattern_tester ] Some message
\n
"
);
}
TEST_CASE
(
"left_padded_max"
,
"[pattern_formatter]"
)
{
REQUIRE
(
log_to_str
(
"Some message"
,
"[%-64n] %v"
,
spdlog
::
pattern_time_type
::
local
,
"
\n
"
)
==
REQUIRE
(
log_to_str
(
"Some message"
,
"[%-64n] %v"
,
spdlog
::
pattern_time_type
::
local
,
"
\n
"
)
==
"[pattern_tester ] Some message
\n
"
);
}
TEST_CASE
(
"clone-default-formatter"
,
"[pattern_formatter]"
)
{
auto
formatter_1
=
std
::
make_shared
<
spdlog
::
pattern_formatter
>
();
...
...
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