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
5556967e
Commit
5556967e
authored
Mar 28, 2014
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logger ctor cleanup
parent
90029561
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
13 deletions
+10
-13
example.cpp
example/example.cpp
+2
-2
logger.h
include/c11log/logger.h
+8
-11
No files found.
example/example.cpp
View file @
5556967e
...
...
@@ -22,7 +22,7 @@ int main(int argc, char* argv[])
auto
fsink
=
std
::
make_shared
<
sinks
::
rotating_file_sink
>
(
"log"
,
"txt"
,
1024
*
1024
*
50
,
5
,
0
);
logger
my_logger
(
"my_logger"
,
{
sinks
::
null_sink
::
get
()}
);
logger
my_logger
(
"my_logger"
,
sinks
::
null_sink
::
get
()
);
auto
start
=
system_clock
::
now
();
for
(
unsigned
int
i
=
0
;
i
<
howmany
;
i
++
)
...
...
@@ -31,7 +31,7 @@ int main(int argc, char* argv[])
auto
delta
=
system_clock
::
now
()
-
start
;
auto
delta_d
=
duration_cast
<
duration
<
double
>>
(
delta
).
count
();
logger
cout_logger
(
{
sinks
::
stdout_sink
()}
);
logger
cout_logger
(
""
,
sinks
::
stdout_sink
()
);
cout_logger
.
info
(
"Total:"
)
<<
format
(
howmany
);
cout_logger
.
info
(
"Delta:"
)
<<
format
(
delta_d
);
cout_logger
.
info
(
"Rate:"
)
<<
format
(
howmany
/
delta_d
)
<<
"/sec"
;
...
...
include/c11log/logger.h
View file @
5556967e
...
...
@@ -34,10 +34,8 @@ public:
using
sinks_vector_t
=
std
::
vector
<
sink_ptr
>
;
using
sinks_init_list
=
std
::
initializer_list
<
sink_ptr
>
;
logger
(
const
std
::
string
&
name
,
formatter_ptr
,
sinks_init_list
);
logger
(
const
std
::
string
&
name
,
sinks_init_list
);
logger
(
sinks_init_list
sinks_list
);
logger
(
const
std
::
string
&
name
,
sinks_init_list
,
formatter_ptr
=
nullptr
);
logger
(
const
std
::
string
&
name
,
sink_ptr
,
formatter_ptr
=
nullptr
);
~
logger
()
=
default
;
...
...
@@ -65,7 +63,7 @@ public:
private
:
friend
details
::
line_logger
;
std
::
string
_logger_name
=
""
;
std
::
string
_logger_name
;
formatter_ptr
_formatter
;
sinks_vector_t
_sinks
;
std
::
atomic_int
_logger_level
;
...
...
@@ -84,21 +82,20 @@ logger& get_logger(const std::string& name);
#include "details/line_logger.h"
inline
c11log
::
logger
::
logger
(
const
std
::
string
&
name
,
formatter_ptr
f
,
sinks_init_list
sinks_list
)
:
inline
c11log
::
logger
::
logger
(
const
std
::
string
&
name
,
sinks_init_list
sinks_list
,
formatter_ptr
f
)
:
_logger_name
(
name
),
_formatter
(
f
),
_sinks
(
sinks_list
)
{
//Seems that vs2013 doesnt support std::atomic member initialization, so its done here
_logger_level
=
level
::
INFO
;
if
(
!
_formatter
)
_formatter
=
std
::
make_shared
<
formatters
::
default_formatter
>
();
}
inline
c11log
::
logger
::
logger
(
const
std
::
string
&
name
,
sinks_init_list
sinks_list
)
:
logger
(
name
,
std
::
make_shared
<
formatters
::
default_formatter
>
(),
sinks_list
)
{}
inline
c11log
::
logger
::
logger
(
sinks_init_list
sinks_list
)
:
logger
(
""
,
std
::
make_shared
<
formatters
::
default_formatter
>
(),
sinks_list
)
{}
inline
c11log
::
logger
::
logger
(
const
std
::
string
&
name
,
sink_ptr
sink
,
formatter_ptr
f
)
:
logger
(
name
,
{
sink
},
f
)
{}
inline
c11log
::
details
::
line_logger
c11log
::
logger
::
log
(
c11log
::
level
::
level_enum
msg_level
)
{
...
...
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