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
7f8169f0
Commit
7f8169f0
authored
Feb 10, 2020
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed tcp_sink to accept hostnames
parent
66e86528
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
include/spdlog/sinks/tcp_sink.h
include/spdlog/sinks/tcp_sink.h
+11
-4
No files found.
include/spdlog/sinks/tcp_sink.h
View file @
7f8169f0
...
...
@@ -8,6 +8,7 @@
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <netdb.h>
namespace
spdlog
{
namespace
sinks
{
...
...
@@ -22,12 +23,16 @@ public:
{
SPDLOG_THROW
(
spdlog
::
spdlog_ex
(
"Socket creation error"
,
errno
));
}
serv_addr_
.
sin_family
=
AF_INET
;
serv_addr_
.
sin_port
=
::
htons
(
static_cast
<
uint16_t
>
(
port
));
if
(
inet_pton
(
AF_INET
,
address
.
c_str
(),
&
serv_addr_
.
sin_addr
)
<=
0
)
struct
hostent
*
he
=
gethostbyname
(
address
.
c_str
());
if
(
he
==
nullptr
)
{
SPDLOG_THROW
(
spdlog
::
spdlog_ex
(
"
Invalid address/ Address not support
ed"
,
errno
));
SPDLOG_THROW
(
spdlog
::
spdlog_ex
(
"
gethostbyname fail
ed"
,
errno
));
}
serv_addr_
.
sin_family
=
AF_INET
;
serv_addr_
.
sin_addr
=
*
(
struct
in_addr
*
)(
he
->
h_addr
);
serv_addr_
.
sin_port
=
::
htons
(
static_cast
<
uint16_t
>
(
port
));
if
(
connect
(
sock_
,
(
struct
sockaddr
*
)
&
serv_addr_
,
sizeof
(
serv_addr_
))
<
0
)
{
SPDLOG_THROW
(
spdlog
::
spdlog_ex
(
"Connection Failed"
,
errno
));
...
...
@@ -48,6 +53,8 @@ protected:
void
flush_
()
override
{}
private:
private:
int
sock_
;
struct
sockaddr_in
serv_addr_
;
...
...
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