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
b093b824
Commit
b093b824
authored
Jan 26, 2014
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gcc support
parent
68504fa3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
29 deletions
+70
-29
Makefile
Makefile
+30
-0
stdafx.h
include/stdafx.h
+27
-16
utils.h
include/utils.h
+0
-0
test.cpp
src/test.cpp
+13
-5
stdafx.cpp
test/stdafx.cpp
+0
-8
No files found.
Makefile
0 → 100644
View file @
b093b824
CC
=
g++
CCFLAGS
=
-std
=
c++11
-pthread
-Iinclude
-O3
-flto
all
:
lib testlog
testlog
:
test.o lib
$(CC)
-o
$testlog
test.o libc11log.a
$(CCFLAGS)
lib
:
factory.o formatters.o line_logger.o os.o
ar rvs libc11log.a
$^
;
test.o
:
src/test.cpp
$(CC)
-c
-o
$@
$^
$(CCFLAGS)
factory.o
:
src/factory.cpp
$(CC)
-c
-o
$@
$^
$(CCFLAGS)
formatters.o
:
src/formatters.cpp
$(CC)
-c
-o
$@
$^
$(CCFLAGS)
line_logger.o
:
src/line_logger.cpp
$(CC)
-c
-o
$@
$^
$(CCFLAGS)
os.o
:
src/os.cpp
$(CC)
-c
-o
$@
$^
$(CCFLAGS)
.PHONY
:
clean
clean
:
rm
*
.o
test
/stdafx.h
→
include
/stdafx.h
View file @
b093b824
// stdafx.h : include file for standard system include files,
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// or project specific include files that are used frequently, but
// are changed infrequently
// are changed infrequently
//
//
#pragma once
#pragma once
#ifdef _MSC_VER
#include <thread>
#include "targetver.h"
#include <iostream>
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <chrono>
#endif
#include "utils.h"
#include <string>
#include "../include/c11log/logger.h"
#include <chrono>
#include "../include/c11log/sinks/async_sink.h"
#include <ctime>
#include "../include/c11log/sinks/stdout_sinks.h"
#include <memory>
#include "../include/c11log/sinks/file_sinks.h"
#include <iostream>
#ifndef _MSC_VER
namespace
std
{
template
<
typename
T
,
typename
...
Args
>
std
::
unique_ptr
<
T
>
make_unique
(
Args
&&
...
args
)
{
return
std
::
unique_ptr
<
T
>
(
new
T
(
std
::
forward
<
Args
>
(
args
)...
)
);
}
}
#endif
test
/utils.h
→
include
/utils.h
View file @
b093b824
File moved
test
/test.cpp
→
src
/test.cpp
View file @
b093b824
...
@@ -2,30 +2,38 @@
...
@@ -2,30 +2,38 @@
//
//
#include "stdafx.h"
#include "stdafx.h"
#include "c11log/logger.h"
#include "c11log/sinks/async_sink.h"
#include "c11log/sinks/file_sinks.h"
#include "c11log/sinks/stdout_sinks.h"
#include "utils.h"
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
int
nthreads
=
argc
>
1
?
atoi
(
argv
[
1
])
:
1
;
auto
null_sink
=
std
::
make_shared
<
c11log
::
sinks
::
null_sink
>
();
auto
null_sink
=
std
::
make_shared
<
c11log
::
sinks
::
null_sink
>
();
auto
stdout_sink
=
std
::
make_shared
<
c11log
::
sinks
::
stdout_sink
>
();
auto
async
=
std
::
make_shared
<
c11log
::
sinks
::
async_sink
>
(
100
);
auto
async
=
std
::
make_shared
<
c11log
::
sinks
::
async_sink
>
(
100
);
auto
fsink
=
std
::
make_shared
<
c11log
::
sinks
::
rotating_file_sink
>
(
"newlog"
,
"txt"
,
1024
*
1024
*
10
,
2
);
auto
fsink
=
std
::
make_shared
<
c11log
::
sinks
::
rotating_file_sink
>
(
"newlog"
,
"txt"
,
1024
*
1024
*
10
,
2
);
async
->
add_sink
(
f
sink
);
async
->
add_sink
(
null_
sink
);
c11log
::
logger
logger
(
"test"
);
c11log
::
logger
logger
(
"test"
);
logger
.
add_sink
(
async
);
logger
.
add_sink
(
async
);
std
::
atomic
<
uint32_t
>
counter
{
0
};
std
::
atomic
<
uint32_t
>
counter
{
0
};
auto
counter_ptr
=
&
counter
;
auto
counter_ptr
=
&
counter
;
for
(
int
i
=
0
;
i
<
4
;
i
++
)
std
::
cout
<<
"Starting "
<<
nthreads
<<
" threads.."
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
nthreads
;
i
++
)
{
{
new
std
::
thread
([
&
logger
,
counter_ptr
]()
{
new
std
::
thread
([
&
logger
,
counter_ptr
]()
{
while
(
true
)
while
(
true
)
{
{
logger
.
info
()
<<
"Hello from thread
"
<<
std
::
this_thread
::
get_i
d
();
logger
.
info
()
<<
"Hello from thread
"
<<
std
::
this_thread
::
get_id
()
<<
"
\t
counter: "
<<
counter_ptr
->
loa
d
();
(
*
counter_ptr
)
++
;
(
*
counter_ptr
)
++
;
}
}
...
...
test/stdafx.cpp
deleted
100644 → 0
View file @
68504fa3
// stdafx.cpp : source file that includes just the standard includes
// test.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
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