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
ba68a2d0
Commit
ba68a2d0
authored
Apr 14, 2016
by
Anton Goryunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- std::cout replaced with fwrite to stdout in console sink
parent
083d6c0d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
6 deletions
+26
-6
include/spdlog/sinks/stdout_sinks.h
include/spdlog/sinks/stdout_sinks.h
+26
-6
No files found.
include/spdlog/sinks/stdout_sinks.h
View file @
ba68a2d0
...
...
@@ -5,10 +5,9 @@
#pragma once
#include <spdlog/sinks/ostream_sink.h>
#include <spdlog/details/null_mutex.h>
#include <
iostream
>
#include <
cstdio
>
#include <memory>
#include <mutex>
...
...
@@ -18,16 +17,27 @@ namespace sinks
{
template
<
class
Mutex
>
class
stdout_sink
:
public
ostream
_sink
<
Mutex
>
class
stdout_sink
:
public
base
_sink
<
Mutex
>
{
using
MyType
=
stdout_sink
<
Mutex
>
;
public:
stdout_sink
()
:
ostream_sink
<
Mutex
>
(
std
::
cout
,
true
)
{}
stdout_sink
()
{}
static
std
::
shared_ptr
<
MyType
>
instance
()
{
static
std
::
shared_ptr
<
MyType
>
instance
=
std
::
make_shared
<
MyType
>
();
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
;
...
...
@@ -35,17 +45,27 @@ typedef stdout_sink<std::mutex> stdout_sink_mt;
template
<
class
Mutex
>
class
stderr_sink
:
public
ostream
_sink
<
Mutex
>
class
stderr_sink
:
public
base
_sink
<
Mutex
>
{
using
MyType
=
stderr_sink
<
Mutex
>
;
public:
stderr_sink
()
:
ostream_sink
<
Mutex
>
(
std
::
cerr
,
true
)
{}
stderr_sink
()
{}
static
std
::
shared_ptr
<
MyType
>
instance
()
{
static
std
::
shared_ptr
<
MyType
>
instance
=
std
::
make_shared
<
MyType
>
();
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
;
...
...
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