Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
52774e3c
Commit
52774e3c
authored
May 15, 2024
by
Jakob Görgen
Committed by
Jakob Görgen
May 21, 2024
Browse files
lib/utils/log: reformat code
parent
a4de8c62
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
lib/utils/log.h
lib/utils/log.h
+8
-7
No files found.
lib/utils/log.h
View file @
52774e3c
...
...
@@ -22,8 +22,8 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef
SIMBRICK
S_LOG_H_
#define
SIMBRICK
S_LOG_H_
#ifndef
UTIL
S_LOG_H_
#define
UTIL
S_LOG_H_
#include <stdio.h>
...
...
@@ -34,6 +34,7 @@
#include <sstream>
#include <string_view>
#include <unordered_map>
#include <utility>
namespace
sim_log
{
...
...
@@ -59,7 +60,7 @@ class Log {
FILE
*
file_
=
nullptr
;
const
bool
is_file_
=
false
;
Log
(
FILE
*
file
)
:
file_
(
file
),
is_file_
(
false
)
{
explicit
Log
(
FILE
*
file
)
:
file_
(
file
),
is_file_
(
false
)
{
}
Log
(
FILE
*
file
,
bool
is_file
)
:
file_
(
file
),
is_file_
(
is_file
)
{
...
...
@@ -128,14 +129,14 @@ class Logger {
private:
inline
bool
ShouldLog
(
LogLevel
level
)
{
auto
&
registry
=
Logger
::
GetRegistry
();
return
level
>=
registry
.
GetLevel
()
and
return
level
>=
registry
.
GetLevel
()
&&
registry
.
GetLevel
()
!=
LogLevel
::
off
;
}
template
<
typename
...
Args
>
inline
void
log_internal
(
LogLevel
level
,
FILE
*
out
,
const
char
*
format
,
Args
...
args
)
{
if
(
not
ShouldLog
(
level
))
{
if
(
!
ShouldLog
(
level
))
{
return
;
}
fprintf
(
out
,
"%s: "
,
GetRegistry
().
GetRepr
(
level
));
...
...
@@ -144,7 +145,7 @@ class Logger {
}
inline
void
log_internal
(
LogLevel
level
,
FILE
*
out
,
const
char
*
to_print
)
{
if
(
not
ShouldLog
(
level
))
{
if
(
!
ShouldLog
(
level
))
{
return
;
}
fprintf
(
out
,
"%s: "
,
GetRegistry
().
GetRepr
(
level
));
...
...
@@ -308,4 +309,4 @@ inline void LogError(const char *msg) {
}
// namespace sim_log
#endif // SIMBRICKS_LOG_H_
\ No newline at end of file
#endif // UTILS_LOG_H_
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