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
90029561
Commit
90029561
authored
Mar 28, 2014
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor fixes
parent
1c4be7fb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
41 deletions
+18
-41
example.cpp
example/example.cpp
+6
-35
line_logger.h
include/c11log/details/line_logger.h
+2
-3
base_sink.h
include/c11log/sinks/base_sink.h
+9
-2
console_sinks.h
include/c11log/sinks/console_sinks.h
+1
-1
No files found.
example/example.cpp
View file @
90029561
...
...
@@ -18,16 +18,11 @@ using namespace utils;
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
||
argv
)
{};
const
unsigned
int
howmany
=
argc
<=
1
?
1000
:
atoi
(
argv
[
1
]);
const
unsigned
int
howmany
=
argc
<=
1
?
1000
:
atoi
(
argv
[
1
]);
auto
fsink
=
std
::
make_shared
<
sinks
::
rotating_file_sink
>
(
"log"
,
"txt"
,
1024
*
1024
*
50
,
5
,
0
);
auto
null_sink
=
std
::
make_shared
<
sinks
::
null_sink
>
();
logger
cout_logger
(
"cout"
,
{
sinks
::
stdout_sink
()});
logger
my_logger
(
"my_logger"
,
{
null_sink
});
logger
my_logger
(
"my_logger"
,
{
sinks
::
null_sink
::
get
()});
auto
start
=
system_clock
::
now
();
for
(
unsigned
int
i
=
0
;
i
<
howmany
;
i
++
)
...
...
@@ -36,35 +31,11 @@ int main(int argc, char* argv[])
auto
delta
=
system_clock
::
now
()
-
start
;
auto
delta_d
=
duration_cast
<
duration
<
double
>>
(
delta
).
count
();
cout_logger
.
info
(
"Total "
)
<<
format
(
howmany
);
cout_logger
.
info
(
"
Delta "
)
<<
format
(
delta_d
);
cout_logger
.
info
(
"
Rate: "
)
<<
format
(
howmany
/
delta_d
)
<<
"/sec"
;
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"
;
return
0
;
/*
if(argc !=3) {
std::cerr << "Usage: " << argv[0] << " qsize, threads" << std::endl;
return 0;
}
int qsize = atoi(argv[1]);
int threads = atoi(argv[2]);
auto null_sink = std::make_shared<sinks::null_sink>();
auto stdout_sink = std::make_shared<sinks::stdout_sink>();
auto async = std::make_shared<sinks::async_sink>(qsize);
auto fsink = std::make_shared<sinks::rotating_file_sink>("log", "txt", 1024*1024*50 , 5, std::chrono::milliseconds(1000));
async->add_sink(fsink);
//auto &logger = c11log::get_logger("async");
//logger.add_sink(fsink);
testlog(threads);
*/
}
include/c11log/details/line_logger.h
View file @
90029561
...
...
@@ -19,14 +19,13 @@ class line_logger
public
:
line_logger
(
logger
*
callback_logger
,
level
::
level_enum
msg_level
,
bool
enabled
)
:
_callback_logger
(
callback_logger
),
_log_msg
(),
_log_msg
(
msg_level
),
_oss
(),
_enabled
(
enabled
)
{
if
(
enabled
)
{
_log_msg
.
msg_time
=
log_clock
::
now
();
_log_msg
.
msg_level
=
msg_level
;
_log_msg
.
msg_time
=
log_clock
::
now
();
callback_logger
->
_formatter
->
format_header
(
callback_logger
->
_logger_name
,
_log_msg
.
msg_level
,
_log_msg
.
msg_time
,
...
...
include/c11log/sinks/base_sink.h
View file @
90029561
...
...
@@ -45,10 +45,17 @@ protected:
class
null_sink
:
public
base_sink
{
public
:
static
std
::
shared_ptr
<
null_sink
>&
get
()
{
static
auto
inst
=
std
::
make_shared
<
null_sink
>
();
return
inst
;
}
protected
:
void
_sink_it
(
const
details
::
log_msg
&
)
override
{
}
{}
};
}
}
include/c11log/sinks/console_sinks.h
View file @
90029561
...
...
@@ -18,6 +18,7 @@ public:
console_sink
&
operator
=
(
const
console_sink
&
)
=
delete
;
virtual
~
console_sink
()
=
default
;
protected
:
virtual
void
_sink_it
(
const
details
::
log_msg
&
msg
)
override
{
...
...
@@ -42,6 +43,5 @@ inline std::shared_ptr<console_sink>& stderr_sink ()
return
inst
;
}
}
}
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