Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
ECSS Services
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
AcubeSat-OBC
ECSS Services
Commits
a2ccff1c
Unverified
Commit
a2ccff1c
authored
5 years ago
by
kongr45gpen
Browse files
Options
Downloads
Patches
Plain Diff
Use a constexpr function instead of a #define to check if a log level is loggable
Thanks @xlxs41 for the suggestion!
parent
6fea04c6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inc/Logger.hpp
+10
-9
10 additions, 9 deletions
inc/Logger.hpp
with
10 additions
and
9 deletions
inc/Logger.hpp
+
10
−
9
View file @
a2ccff1c
...
...
@@ -24,14 +24,6 @@
#define LOGLEVEL Logger::disabled // Ignore-MISRA
#endif
/**
* Internal define to check if logging is enabled for a level
* @param level A log level
* @return bool
*/
#define _ac_LOGGER_ENABLED_LEVEL(level)
/* Ignore-MISRA */
\
(( (Logger::LogLevelType) LOGLEVEL) <= ( (Logger::LogLevelType) level))
/**
* Create a stream to log a Message
*
...
...
@@ -79,7 +71,7 @@
* @param level The log level. A value of \ref Logger::LogEntry
*/
#define LOG(level)
/* Ignore-MISRA */
\
if (
_ac_LOGGER_ENABLED_LEVEL
(level)) \
if (
Logger::isLogged
(level)) \
if (Logger::LogEntry entry(level); true) \
entry
...
...
@@ -147,6 +139,15 @@ public:
LogEntry
(
LogEntry
const
&
)
=
delete
;
///< Unimplemented copy constructor
};
/**
* Returns whether a log entry of level \p level is logged, based on the compilation constants
* @param level The level of the log entry
* @return True if the logging is enabled for \p level, false if not
*/
static
constexpr
bool
isLogged
(
LogLevelType
level
)
{
return
static_cast
<
LogLevelType
>
(
LOGLEVEL
)
<=
level
;
}
/**
* Store a new log message
*/
...
...
This diff is collapsed.
Click to expand it.
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