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
391bd396
Commit
391bd396
authored
Oct 14, 2014
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed gcc bugs and warnings
parent
ef330729
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
28 deletions
+27
-28
bench.cpp
example/bench.cpp
+2
-3
fast_oss.h
include/c11log/details/fast_oss.h
+2
-2
pattern_formatter.h
include/c11log/details/pattern_formatter.h
+3
-4
logger.h
include/c11log/logger.h
+14
-13
async_sink.h
include/c11log/sinks/async_sink.h
+6
-6
No files found.
example/bench.cpp
View file @
391bd396
...
...
@@ -2,7 +2,6 @@
//
#include <mutex>
#include "c11log/logger.h"
#include "c11log/pattern_formatter.h"
#include "c11log/sinks/async_sink.h"
#include "c11log/sinks/file_sinks.h"
#include "c11log/sinks/stdout_sinks.h"
...
...
@@ -21,7 +20,7 @@ int main(int argc, char* argv[])
const
unsigned
int
howmany
=
argc
<=
1
?
500000
:
atoi
(
argv
[
1
]);
std
::
string
pattern
=
"%Y:%m:%d %H:%M:%S.%e [%n:%l] %t"
;
auto
formatter1
=
std
::
unique_ptr
<
formatter
>
(
new
pattern_formatter
(
pattern
));
auto
formatter1
=
std
::
unique_ptr
<
formatter
>
(
new
details
::
pattern_formatter
(
pattern
));
logger
cout_logger
(
"bench"
,
std
::
make_shared
<
sinks
::
stderr_sink_mt
>
()
,
std
::
move
(
formatter1
));
cout_logger
.
info
()
<<
"Hello logger"
;
...
...
@@ -30,7 +29,7 @@ int main(int argc, char* argv[])
auto
rotating
=
std
::
make_shared
<
sinks
::
rotating_file_sink_mt
>
(
"myrotating"
,
"txt"
,
1024
*
1024
*
5
,
5
,
100
);
auto
formatter2
=
std
::
unique_ptr
<
formatter
>
(
new
pattern_formatter
(
pattern
));
auto
formatter2
=
std
::
unique_ptr
<
formatter
>
(
new
details
::
pattern_formatter
(
pattern
));
logger
my_logger
(
"my_logger"
,
rotating
,
std
::
move
(
formatter2
));
auto
start
=
system_clock
::
now
();
...
...
include/c11log/details/fast_oss.h
View file @
391bd396
...
...
@@ -122,9 +122,9 @@ public:
//_dev.sputn(buf, width);
}
void
put_str
(
const
std
::
string
&
s
tr
)
void
put_str
(
const
std
::
string
&
s
)
{
_dev
.
sputn
(
s
tr
.
data
(),
str
.
size
());
_dev
.
sputn
(
s
.
data
(),
s
.
size
());
}
...
...
include/c11log/details/pattern_formatter.h
View file @
391bd396
...
...
@@ -138,7 +138,7 @@ class ch_appender :public pattern_appender
public
:
explicit
ch_appender
(
char
ch
)
:
_ch
(
ch
)
{}
void
append
(
const
details
::
log_msg
&
msg
,
details
::
fast_oss
&
oss
)
override
void
append
(
const
details
::
log_msg
&
,
details
::
fast_oss
&
oss
)
override
{
oss
.
putc
(
_ch
);
}
...
...
@@ -156,7 +156,7 @@ public:
{
_str
+=
ch
;
}
void
append
(
const
details
::
log_msg
&
msg
,
details
::
fast_oss
&
oss
)
override
void
append
(
const
details
::
log_msg
&
,
details
::
fast_oss
&
oss
)
override
{
oss
<<
_str
;
}
...
...
@@ -280,4 +280,4 @@ inline void c11log::details::pattern_formatter::format(details::log_msg& msg)
}
oss
.
write
(
details
::
os
::
eol
(),
details
::
os
::
eol_size
());
msg
.
formatted
=
oss
.
str
();
}
\ No newline at end of file
}
include/c11log/logger.h
View file @
391bd396
...
...
@@ -14,7 +14,8 @@
#include "sinks/base_sink.h"
#include "common.h"
#include "pattern_formatter.h"
#include "formatter.h"
#include "details/pattern_formatter.h"
namespace
c11log
{
...
...
@@ -97,29 +98,29 @@ private:
#include "details/line_logger.h"
inline
c11log
::
logger
::
logger
(
const
std
::
string
&
name
,
sinks_init_list
sinks_list
,
formatter_ptr
f
)
:
_name
(
name
),
inline
c11log
::
logger
::
logger
(
const
std
::
string
&
logger_
name
,
sinks_init_list
sinks_list
,
formatter_ptr
f
)
:
_name
(
logger_
name
),
_formatter
(
std
::
move
(
f
)),
_sinks
(
sinks_list
)
{
//Seems that vs2013 doesn't support std::atomic member initialization yet
_level
=
level
::
INFO
;
if
(
!
_formatter
)
_formatter
=
std
::
make_unique
<
pattern_formatter
>
(
"%t"
);
_formatter
=
formatter_ptr
(
new
details
::
pattern_formatter
(
"%t"
)
);
}
template
<
class
It
>
inline
c11log
::
logger
::
logger
(
const
std
::
string
&
name
,
It
begin
,
It
end
,
formatter_ptr
f
)
:
_name
(
name
),
inline
c11log
::
logger
::
logger
(
const
std
::
string
&
logger_
name
,
It
begin
,
It
end
,
formatter_ptr
f
)
:
_name
(
logger_
name
),
_formatter
(
std
::
move
(
f
)),
_sinks
(
begin
,
end
)
{
}
inline
c11log
::
logger
::
logger
(
const
std
::
string
&
name
,
sink_ptr
sink
,
formatter_ptr
f
)
:
logger
(
name
,
{
sink
},
std
::
move
(
f
))
{}
inline
c11log
::
logger
::
logger
(
const
std
::
string
&
logger_
name
,
sink_ptr
sink
,
formatter_ptr
f
)
:
logger
(
logger_
name
,
{
sink
},
std
::
move
(
f
))
{}
template
<
typename
...
Args
>
...
...
@@ -163,9 +164,9 @@ inline const std::string& c11log::logger::name() const
return
_name
;
}
inline
void
c11log
::
logger
::
level
(
c11log
::
level
::
level_enum
level
)
inline
void
c11log
::
logger
::
level
(
c11log
::
level
::
level_enum
l
og_l
evel
)
{
_level
.
store
(
level
);
_level
.
store
(
l
og_l
evel
);
}
inline
c11log
::
level
::
level_enum
c11log
::
logger
::
level
()
const
...
...
@@ -173,13 +174,13 @@ inline c11log::level::level_enum c11log::logger::level() const
return
static_cast
<
c11log
::
level
::
level_enum
>
(
_level
.
load
());
}
inline
bool
c11log
::
logger
::
should_log
(
c11log
::
level
::
level_enum
level
)
const
inline
bool
c11log
::
logger
::
should_log
(
c11log
::
level
::
level_enum
msg_
level
)
const
{
return
level
>=
_level
.
load
();
return
msg_
level
>=
_level
.
load
();
}
inline
void
c11log
::
logger
::
_variadic_log
(
c11log
::
details
::
line_logger
&
l
)
{}
inline
void
c11log
::
logger
::
_variadic_log
(
c11log
::
details
::
line_logger
&
)
{}
template
<
typename
First
,
typename
...
Rest
>
void
c11log
::
logger
::
_variadic_log
(
c11log
::
details
::
line_logger
&
l
,
const
First
&
first
,
const
Rest
&
...
rest
)
...
...
include/c11log/sinks/async_sink.h
View file @
391bd396
...
...
@@ -80,9 +80,9 @@ inline void c11log::sinks::async_sink::_thread_loop()
q_type
::
item_type
msg
;
if
(
_q
.
pop
(
msg
,
pop_timeout
))
{
for
(
auto
&
s
ink
:
_sinks
)
for
(
auto
&
s
:
_sinks
)
{
s
ink
->
log
(
msg
);
s
->
log
(
msg
);
if
(
!
_active
)
break
;
}
...
...
@@ -90,17 +90,17 @@ inline void c11log::sinks::async_sink::_thread_loop()
}
}
inline
void
c11log
::
sinks
::
async_sink
::
add_sink
(
logger
::
sink_ptr
s
ink
)
inline
void
c11log
::
sinks
::
async_sink
::
add_sink
(
logger
::
sink_ptr
s
)
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
_mutex
);
_sinks
.
push_back
(
s
ink
);
_sinks
.
push_back
(
s
);
}
inline
void
c11log
::
sinks
::
async_sink
::
remove_sink
(
logger
::
sink_ptr
s
ink
)
inline
void
c11log
::
sinks
::
async_sink
::
remove_sink
(
logger
::
sink_ptr
s
)
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
_mutex
);
_sinks
.
erase
(
std
::
remove
(
_sinks
.
begin
(),
_sinks
.
end
(),
s
ink
),
_sinks
.
end
());
_sinks
.
erase
(
std
::
remove
(
_sinks
.
begin
(),
_sinks
.
end
(),
s
),
_sinks
.
end
());
}
...
...
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