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
Merge requests
!132
Merge branch 'fastest_logging' into 'master'
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Merge branch 'fastest_logging' into 'master'
cherry-pick-866b9a03
into
master
Overview
3
Commits
2
Pipelines
0
Changes
1
Merged
Jeremie Deray
requested to merge
cherry-pick-866b9a03
into
master
7 years ago
Overview
3
Commits
2
Pipelines
0
Changes
1
Expand
fastest logging
See merge request
!119 (merged)
Fixing
!119 (merged)
that was reverted.
0
0
Merge request reports
Compare
master
version 1
f8abd429
7 years ago
master (base)
and
latest version
latest version
be60b873
2 commits,
7 years ago
version 1
f8abd429
1 commit,
7 years ago
1 file
+
41
−
38
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/logging.h
+
41
−
38
Options
@@ -20,6 +20,32 @@
namespace
wolf
{
namespace
internal
{
static
const
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
)
Loading