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
50b81974
Commit
50b81974
authored
Mar 01, 2014
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
static one_hour
parent
ddcf45d6
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
9 deletions
+8
-9
example.cpp
example/example.cpp
+3
-3
makefile
example/makefile
+1
-1
blocking_queue.h
include/c11log/details/blocking_queue.h
+4
-3
formatter.h
include/c11log/formatter.h
+0
-2
No files found.
example/example.cpp
View file @
50b81974
...
@@ -54,10 +54,10 @@ int main(int argc, char* argv[])
...
@@ -54,10 +54,10 @@ int main(int argc, char* argv[])
using
std
::
cout
;
using
std
::
cout
;
using
std
::
endl
;
using
std
::
endl
;
auto
fsink2
=
std
::
make_shared
<
sinks
::
rotating_file_sink
>
(
"log"
,
"txt"
,
1024
*
1024
*
50
,
5
,
seconds
(
1
));
//
auto fsink2 = std::make_shared<sinks::rotating_file_sink>("log", "txt", 1024*1024*50 , 5, seconds(1));
auto
&
logger2
=
c11log
::
get_logger
(
"logger2"
);
auto
&
logger2
=
c11log
::
get_logger
(
"logger2"
);
logger2
.
add_sink
(
fsink2
);
//
logger2.add_sink(fsink2);
//
logger2.add_sink(std::make_shared<sinks::null_sink>());
logger2
.
add_sink
(
std
::
make_shared
<
sinks
::
null_sink
>
());
auto
start
=
system_clock
::
now
();
auto
start
=
system_clock
::
now
();
const
unsigned
int
howmany
=
10000000
;
const
unsigned
int
howmany
=
10000000
;
...
...
example/makefile
View file @
50b81974
CXX
=
ccache
g++
CXX
=
g++
CXXFLAGS
=
-march
=
native
-Wall
-Wextra
-Wshadow
-pedantic
-std
=
c++11
-pthread
-I
../include
CXXFLAGS
=
-march
=
native
-Wall
-Wextra
-Wshadow
-pedantic
-std
=
c++11
-pthread
-I
../include
CXX_RELEASE_FLAGS
=
-O3
-flto
CXX_RELEASE_FLAGS
=
-O3
-flto
CXX_DEBUG_FLAGS
=
-g
CXX_DEBUG_FLAGS
=
-g
...
...
include/c11log/details/blocking_queue.h
View file @
50b81974
...
@@ -58,7 +58,8 @@ public:
...
@@ -58,7 +58,8 @@ public:
// If the queue is full, block the calling thread until there is room.
// If the queue is full, block the calling thread until there is room.
template
<
typename
TT
>
template
<
typename
TT
>
void
push
(
TT
&&
item
)
{
void
push
(
TT
&&
item
)
{
while
(
!
push
(
std
::
forward
<
TT
>
(
item
),
_one_hour
));
static
constexpr
std
::
chrono
::
hours
one_hour
(
1
);
while
(
!
push
(
std
::
forward
<
TT
>
(
item
),
one_hour
));
}
}
// Pop a copy of the front item in the queue into the given item ref.
// Pop a copy of the front item in the queue into the given item ref.
...
@@ -85,7 +86,8 @@ public:
...
@@ -85,7 +86,8 @@ public:
// Pop a copy of the front item in the queue into the given item ref.
// Pop a copy of the front item in the queue into the given item ref.
// If the queue is empty, block the calling thread util there is item to pop.
// If the queue is empty, block the calling thread util there is item to pop.
void
pop
(
T
&
item
)
{
void
pop
(
T
&
item
)
{
while
(
!
pop
(
item
,
_one_hour
));
static
constexpr
std
::
chrono
::
hours
one_hour
(
1
);
while
(
!
pop
(
item
,
one_hour
));
}
}
// Clear the queue
// Clear the queue
...
@@ -103,7 +105,6 @@ private:
...
@@ -103,7 +105,6 @@ private:
std
::
mutex
_mutex
;
std
::
mutex
_mutex
;
std
::
condition_variable
_item_pushed_cond
;
std
::
condition_variable
_item_pushed_cond
;
std
::
condition_variable
_item_popped_cond
;
std
::
condition_variable
_item_popped_cond
;
static
constexpr
auto
_one_hour
=
std
::
chrono
::
hours
(
1
);
};
};
}
}
...
...
include/c11log/formatter.h
View file @
50b81974
...
@@ -43,8 +43,6 @@ private:
...
@@ -43,8 +43,6 @@ private:
inline
void
c11log
::
formatters
::
default_formatter
::
_format_time
(
const
log_clock
::
time_point
&
tp
,
std
::
ostream
&
dest
)
inline
void
c11log
::
formatters
::
default_formatter
::
_format_time
(
const
log_clock
::
time_point
&
tp
,
std
::
ostream
&
dest
)
{
{
using
namespace
std
::
chrono
;
auto
tm
=
details
::
os
::
localtime
(
log_clock
::
to_time_t
(
tp
));
auto
tm
=
details
::
os
::
localtime
(
log_clock
::
to_time_t
(
tp
));
char
buff
[
64
];
char
buff
[
64
];
int
size
=
snprintf
(
buff
,
sizeof
(
buff
),
"[%d-%02d-%02d %02d:%02d:%02d]"
,
int
size
=
snprintf
(
buff
,
sizeof
(
buff
),
"[%d-%02d-%02d %02d:%02d:%02d]"
,
...
...
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