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
d1819f5f
Commit
d1819f5f
authored
Mar 15, 2020
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clang-format
parent
19c7e638
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
36 deletions
+35
-36
include/spdlog/common.h
include/spdlog/common.h
+10
-10
include/spdlog/details/registry-inl.h
include/spdlog/details/registry-inl.h
+1
-1
include/spdlog/details/tcp_client-windows.h
include/spdlog/details/tcp_client-windows.h
+8
-11
include/spdlog/sinks/tcp_sink.h
include/spdlog/sinks/tcp_sink.h
+4
-4
src/color_sinks.cpp
src/color_sinks.cpp
+8
-4
tests/test_misc.cpp
tests/test_misc.cpp
+4
-6
No files found.
include/spdlog/common.h
View file @
d1819f5f
...
...
@@ -17,16 +17,16 @@
#ifdef SPDLOG_COMPILED_LIB
#undef SPDLOG_HEADER_ONLY
#
if defined(_WIN32) && defined(SPDLOG_SHARED_LIB)
#
ifdef spdlog_EXPORTS
#
define SPDLOG_API __declspec(dllexport)
#
else
#
define SPDLOG_API __declspec(dllimport)
#
endif
#
else
#
define SPDLOG_API
#
endif
#
define SPDLOG_INLINE
#if defined(_WIN32) && defined(SPDLOG_SHARED_LIB)
#ifdef spdlog_EXPORTS
#define SPDLOG_API __declspec(dllexport)
#else
#define SPDLOG_API __declspec(dllimport)
#endif
#else
#define SPDLOG_API
#endif
#define SPDLOG_INLINE
#else
#define SPDLOG_API
#define SPDLOG_HEADER_ONLY
...
...
include/spdlog/details/registry-inl.h
View file @
d1819f5f
...
...
@@ -187,7 +187,7 @@ SPDLOG_INLINE void registry::flush_on(level::level_enum log_level)
SPDLOG_INLINE
void
registry
::
flush_every
(
std
::
chrono
::
seconds
interval
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
flusher_mutex_
);
auto
clbk
=
[
this
]()
{
this
->
flush_all
();
};
auto
clbk
=
[
this
]()
{
this
->
flush_all
();
};
periodic_flusher_
=
details
::
make_unique
<
periodic_worker
>
(
clbk
,
interval
);
}
...
...
include/spdlog/details/tcp_client-windows.h
View file @
d1819f5f
...
...
@@ -49,14 +49,11 @@ class tcp_client
}
}
static
void
throw_winsock_error_
(
const
std
::
string
&
msg
,
int
last_error
)
static
void
throw_winsock_error_
(
const
std
::
string
&
msg
,
int
last_error
)
{
char
buf
[
512
];
::
FormatMessage
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
NULL
,
last_error
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
buf
,
(
sizeof
(
buf
)
/
sizeof
(
char
)),
NULL
);
::
FormatMessage
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
NULL
,
last_error
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
buf
,
(
sizeof
(
buf
)
/
sizeof
(
char
)),
NULL
);
SPDLOG_THROW
(
spdlog_ex
(
fmt
::
format
(
"tcp_sink - {}: {}"
,
msg
,
buf
)));
}
...
...
@@ -111,20 +108,20 @@ public:
auto
rv
=
::
getaddrinfo
(
host
.
c_str
(),
port_str
.
c_str
(),
&
hints
,
&
addrinfo_result
);
int
last_error
=
0
;
if
(
rv
!=
0
)
{
{
last_error
=
::
WSAGetLastError
();
WSACleanup
();
throw_winsock_error_
(
"getaddrinfo failed"
,
last_error
);
}
// Try each address until we successfully connect(2).
for
(
auto
*
rp
=
addrinfo_result
;
rp
!=
nullptr
;
rp
=
rp
->
ai_next
)
{
socket_
=
socket
(
rp
->
ai_family
,
rp
->
ai_socktype
,
rp
->
ai_protocol
);
if
(
socket_
==
INVALID_SOCKET
)
{
last_error
=
::
WSAGetLastError
();
last_error
=
::
WSAGetLastError
();
WSACleanup
();
continue
;
}
...
...
@@ -141,7 +138,7 @@ public:
::
freeaddrinfo
(
addrinfo_result
);
if
(
socket_
==
INVALID_SOCKET
)
{
WSACleanup
();
WSACleanup
();
throw_winsock_error_
(
"connect failed"
,
last_error
);
}
...
...
@@ -160,7 +157,7 @@ public:
const
int
send_flags
=
0
;
auto
write_result
=
::
send
(
socket_
,
data
+
bytes_sent
,
(
int
)(
n_bytes
-
bytes_sent
),
send_flags
);
if
(
write_result
==
SOCKET_ERROR
)
{
{
int
last_error
=
::
WSAGetLastError
();
close
();
throw_winsock_error_
(
"send failed"
,
last_error
);
...
...
include/spdlog/sinks/tcp_sink.h
View file @
d1819f5f
...
...
@@ -31,7 +31,7 @@ struct tcp_sink_config
{
std
::
string
server_host
;
int
server_port
;
bool
lazy_connect
=
false
;
// if true connect on first log call instead of on construction
bool
lazy_connect
=
false
;
// if true connect on first log call instead of on construction
tcp_sink_config
(
std
::
string
host
,
int
port
)
:
server_host
{
std
::
move
(
host
)}
...
...
@@ -46,14 +46,14 @@ public:
// connect to tcp host/port or throw if failed
// host can be hostname or ip address
explicit
tcp_sink
(
tcp_sink_config
sink_config
)
:
config_
{
std
::
move
(
sink_config
)}
explicit
tcp_sink
(
tcp_sink_config
sink_config
)
:
config_
{
std
::
move
(
sink_config
)}
{
if
(
!
config_
.
lazy_connect
)
{
this
->
client_
.
connect
(
config_
.
server_host
,
config_
.
server_port
);
}
}
}
~
tcp_sink
()
override
=
default
;
...
...
src/color_sinks.cpp
View file @
d1819f5f
...
...
@@ -41,7 +41,11 @@ template SPDLOG_API std::shared_ptr<spdlog::logger> spdlog::stderr_color_mt<spdl
template
SPDLOG_API
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
stderr_color_st
<
spdlog
::
synchronous_factory
>
(
const
std
::
string
&
logger_name
,
color_mode
mode
);
template
SPDLOG_API
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
stdout_color_mt
<
spdlog
::
async_factory
>
(
const
std
::
string
&
logger_name
,
color_mode
mode
);
template
SPDLOG_API
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
stdout_color_st
<
spdlog
::
async_factory
>
(
const
std
::
string
&
logger_name
,
color_mode
mode
);
template
SPDLOG_API
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
stderr_color_mt
<
spdlog
::
async_factory
>
(
const
std
::
string
&
logger_name
,
color_mode
mode
);
template
SPDLOG_API
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
stderr_color_st
<
spdlog
::
async_factory
>
(
const
std
::
string
&
logger_name
,
color_mode
mode
);
template
SPDLOG_API
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
stdout_color_mt
<
spdlog
::
async_factory
>
(
const
std
::
string
&
logger_name
,
color_mode
mode
);
template
SPDLOG_API
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
stdout_color_st
<
spdlog
::
async_factory
>
(
const
std
::
string
&
logger_name
,
color_mode
mode
);
template
SPDLOG_API
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
stderr_color_mt
<
spdlog
::
async_factory
>
(
const
std
::
string
&
logger_name
,
color_mode
mode
);
template
SPDLOG_API
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
stderr_color_st
<
spdlog
::
async_factory
>
(
const
std
::
string
&
logger_name
,
color_mode
mode
);
tests/test_misc.cpp
View file @
d1819f5f
...
...
@@ -209,14 +209,12 @@ TEST_CASE("to_hex_different_size_per_line", "[to_hex]")
REQUIRE
(
ends_with
(
oss
.
str
(),
"0000: 090A0B410C4BFFFF"
+
std
::
string
(
spdlog
::
details
::
os
::
default_eol
)));
oss_logger
.
info
(
"{:Xsa}"
,
spdlog
::
to_hex
(
v
,
6
));
REQUIRE
(
ends_with
(
oss
.
str
(),
"0000: 090A0B410C4B ...A.K"
+
std
::
string
(
spdlog
::
details
::
os
::
default_eol
)
+
"0006: FFFF .."
+
std
::
string
(
spdlog
::
details
::
os
::
default_eol
)));
REQUIRE
(
ends_with
(
oss
.
str
(),
"0000: 090A0B410C4B ...A.K"
+
std
::
string
(
spdlog
::
details
::
os
::
default_eol
)
+
"0006: FFFF .."
+
std
::
string
(
spdlog
::
details
::
os
::
default_eol
)));
oss_logger
.
info
(
"{:Xs}"
,
spdlog
::
to_hex
(
v
,
6
));
REQUIRE
(
ends_with
(
oss
.
str
(),
"0000: 090A0B410C4B"
+
std
::
string
(
spdlog
::
details
::
os
::
default_eol
)
+
"0006: FFFF"
+
std
::
string
(
spdlog
::
details
::
os
::
default_eol
)));
REQUIRE
(
ends_with
(
oss
.
str
(),
"0000: 090A0B410C4B"
+
std
::
string
(
spdlog
::
details
::
os
::
default_eol
)
+
"0006: FFFF"
+
std
::
string
(
spdlog
::
details
::
os
::
default_eol
)));
}
TEST_CASE
(
"to_hex_no_ascii"
,
"[to_hex]"
)
...
...
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