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
1d74f1d7
Commit
1d74f1d7
authored
Apr 15, 2016
by
Gabi Melman
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #196 from gorunovanton/stdout_sink_improvement
Performance improvement of stdout sink
parents
083d6c0d
e0f08d6b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
6 deletions
+27
-6
include/spdlog/sinks/stdout_sinks.h
include/spdlog/sinks/stdout_sinks.h
+26
-6
tests/includes.h
tests/includes.h
+1
-0
No files found.
include/spdlog/sinks/stdout_sinks.h
View file @
1d74f1d7
...
@@ -5,10 +5,9 @@
...
@@ -5,10 +5,9 @@
#pragma once
#pragma once
#include <spdlog/sinks/ostream_sink.h>
#include <spdlog/details/null_mutex.h>
#include <spdlog/details/null_mutex.h>
#include <
iostream
>
#include <
cstdio
>
#include <memory>
#include <memory>
#include <mutex>
#include <mutex>
...
@@ -18,16 +17,27 @@ namespace sinks
...
@@ -18,16 +17,27 @@ namespace sinks
{
{
template
<
class
Mutex
>
template
<
class
Mutex
>
class
stdout_sink
:
public
ostream
_sink
<
Mutex
>
class
stdout_sink
:
public
base
_sink
<
Mutex
>
{
{
using
MyType
=
stdout_sink
<
Mutex
>
;
using
MyType
=
stdout_sink
<
Mutex
>
;
public:
public:
stdout_sink
()
:
ostream_sink
<
Mutex
>
(
std
::
cout
,
true
)
{}
stdout_sink
()
{}
static
std
::
shared_ptr
<
MyType
>
instance
()
static
std
::
shared_ptr
<
MyType
>
instance
()
{
{
static
std
::
shared_ptr
<
MyType
>
instance
=
std
::
make_shared
<
MyType
>
();
static
std
::
shared_ptr
<
MyType
>
instance
=
std
::
make_shared
<
MyType
>
();
return
instance
;
return
instance
;
}
}
void
_sink_it
(
const
details
::
log_msg
&
msg
)
override
{
fwrite
(
msg
.
formatted
.
data
(),
sizeof
(
char
),
msg
.
formatted
.
size
(),
stdout
);
flush
();
}
void
flush
()
override
{
fflush
(
stdout
);
}
};
};
typedef
stdout_sink
<
details
::
null_mutex
>
stdout_sink_st
;
typedef
stdout_sink
<
details
::
null_mutex
>
stdout_sink_st
;
...
@@ -35,17 +45,27 @@ typedef stdout_sink<std::mutex> stdout_sink_mt;
...
@@ -35,17 +45,27 @@ typedef stdout_sink<std::mutex> stdout_sink_mt;
template
<
class
Mutex
>
template
<
class
Mutex
>
class
stderr_sink
:
public
ostream
_sink
<
Mutex
>
class
stderr_sink
:
public
base
_sink
<
Mutex
>
{
{
using
MyType
=
stderr_sink
<
Mutex
>
;
using
MyType
=
stderr_sink
<
Mutex
>
;
public:
public:
stderr_sink
()
:
ostream_sink
<
Mutex
>
(
std
::
cerr
,
true
)
{}
stderr_sink
()
{}
static
std
::
shared_ptr
<
MyType
>
instance
()
static
std
::
shared_ptr
<
MyType
>
instance
()
{
{
static
std
::
shared_ptr
<
MyType
>
instance
=
std
::
make_shared
<
MyType
>
();
static
std
::
shared_ptr
<
MyType
>
instance
=
std
::
make_shared
<
MyType
>
();
return
instance
;
return
instance
;
}
}
void
_sink_it
(
const
details
::
log_msg
&
msg
)
override
{
fwrite
(
msg
.
formatted
.
data
(),
sizeof
(
char
),
msg
.
formatted
.
size
(),
stderr
);
flush
();
}
void
flush
()
override
{
fflush
(
stderr
);
}
};
};
typedef
stderr_sink
<
std
::
mutex
>
stderr_sink_mt
;
typedef
stderr_sink
<
std
::
mutex
>
stderr_sink_mt
;
...
...
tests/includes.h
View file @
1d74f1d7
...
@@ -12,4 +12,5 @@
...
@@ -12,4 +12,5 @@
#include "../include/spdlog/spdlog.h"
#include "../include/spdlog/spdlog.h"
#include "../include/spdlog/sinks/null_sink.h"
#include "../include/spdlog/sinks/null_sink.h"
#include "../include/spdlog/sinks/ostream_sink.h"
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