Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wolf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile_robotics
wolf_projects
wolf_lib
wolf
Commits
866b9a03
Commit
866b9a03
authored
7 years ago
by
Joan Solà Ortega
Browse files
Options
Downloads
Plain Diff
Merge branch 'fastest_logging' into 'master'
fastest logging See merge request
!119
parents
7b684957
a5f0ba55
No related branches found
No related tags found
1 merge request
!119
fastest logging
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/logging.h
+41
-38
41 additions, 38 deletions
src/logging.h
with
41 additions
and
38 deletions
src/logging.h
+
41
−
38
View file @
866b9a03
...
...
@@ -20,6 +20,32 @@
namespace
wolf
{
namespace
internal
{
constexpr
auto
repeated_brace
=
std
::
make_tuple
(
"{}"
,
"{}{}"
,
"{}{}{}"
,
"{}{}{}{}"
,
"{}{}{}{}{}"
,
"{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}"
,
"{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}"
);
// up to 25 args.
class
Logger
:
public
Singleton
<
Logger
>
{
friend
class
Singleton
<
Logger
>
;
...
...
@@ -37,19 +63,19 @@ public:
void
operator
=
(
Logger
&
)
=
delete
;
template
<
typename
...
Args
>
void
info
(
const
Args
&
...
args
);
void
info
(
Args
&
&
...
args
);
template
<
typename
...
Args
>
void
warn
(
const
Args
&
...
args
);
void
warn
(
Args
&
&
...
args
);
template
<
typename
...
Args
>
void
error
(
const
Args
&
...
args
);
void
error
(
Args
&
&
...
args
);
template
<
typename
...
Args
>
void
debug
(
const
Args
&
...
args
);
void
debug
(
Args
&
&
...
args
);
template
<
typename
...
Args
>
void
trace
(
const
Args
&
...
args
);
void
trace
(
Args
&
&
...
args
);
bool
set_async_queue
(
const
std
::
size_t
q_size
);
...
...
@@ -58,29 +84,6 @@ protected:
const
std
::
string
log_name_
=
"wolf_main_console"
;
std
::
shared_ptr
<
spdlog
::
logger
>
console_
;
std
::
string
repeat_string
(
const
std
::
string
&
str
,
std
::
size_t
n
)
{
if
(
n
==
0
)
return
{};
if
(
n
==
1
||
str
.
empty
())
return
str
;
const
auto
n_char
=
str
.
size
();
if
(
n_char
==
1
)
return
std
::
string
(
n
,
str
[
0
]);
std
::
string
res
(
str
);
res
.
reserve
(
n_char
*
n
);
std
::
size_t
m
=
2
;
for
(;
m
<=
n
;
m
*=
2
)
res
+=
res
;
n
-=
m
*
.5
;
res
.
append
(
res
.
c_str
(),
n
*
n_char
);
return
res
;
}
};
inline
Logger
::
Logger
()
...
...
@@ -107,33 +110,33 @@ inline Logger::~Logger()
}
template
<
typename
...
Args
>
void
Logger
::
info
(
const
Args
&
...
args
)
void
Logger
::
info
(
Args
&
&
...
args
)
{
console_
->
info
(
repeat_string
(
"{}"
,
sizeof
...(
args
)).
c_str
(),
args
...);
console_
->
info
(
std
::
get
<
sizeof
...(
args
)
-
1
>
(
repeated_brace
),
std
::
forward
<
Args
>
(
args
)
...);
}
template
<
typename
...
Args
>
void
Logger
::
warn
(
const
Args
&
...
args
)
void
Logger
::
warn
(
Args
&
&
...
args
)
{
console_
->
warn
(
repeat_string
(
"{}"
,
sizeof
...(
args
)).
c_str
(),
args
...);
console_
->
warn
(
std
::
get
<
sizeof
...(
args
)
-
1
>
(
repeated_brace
),
std
::
forward
<
Args
>
(
args
)
...);
}
template
<
typename
...
Args
>
void
Logger
::
error
(
const
Args
&
...
args
)
void
Logger
::
error
(
Args
&
&
...
args
)
{
console_
->
error
(
repeat_string
(
"{}"
,
sizeof
...(
args
)).
c_str
(),
args
...);
console_
->
error
(
std
::
get
<
sizeof
...(
args
)
-
1
>
(
repeated_brace
),
std
::
forward
<
Args
>
(
args
)
...);
}
template
<
typename
...
Args
>
void
Logger
::
debug
(
const
Args
&
...
args
)
void
Logger
::
debug
(
Args
&
&
...
args
)
{
console_
->
debug
(
repeat_string
(
"{}"
,
sizeof
...(
args
)).
c_str
(),
args
...);
console_
->
debug
(
std
::
get
<
sizeof
...(
args
)
-
1
>
(
repeated_brace
),
std
::
forward
<
Args
>
(
args
)
...);
}
template
<
typename
...
Args
>
void
Logger
::
trace
(
const
Args
&
...
args
)
void
Logger
::
trace
(
Args
&
&
...
args
)
{
console_
->
trace
(
repeat_string
(
"{}"
,
sizeof
...(
args
)).
c_str
(),
args
...);
console_
->
trace
(
std
::
get
<
sizeof
...(
args
)
-
1
>
(
repeated_brace
),
std
::
forward
<
Args
>
(
args
)
...);
}
inline
bool
Logger
::
set_async_queue
(
const
std
::
size_t
q_size
)
...
...
This diff is collapsed.
Click to expand it.
Joan Solà Ortega
@jsola
mentioned in commit
90ea23e1
·
7 years ago
mentioned in commit
90ea23e1
mentioned in commit 90ea23e1c78d6b064806e04a69245da68dc16a47
Toggle commit list
Joan Solà Ortega
@jsola
mentioned in commit
77815423
·
7 years ago
mentioned in commit
77815423
mentioned in commit 778154236c87dda1120c33cc1f5f1d1e212832dd
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment