-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor logging: use a general abstract logger for both cyphal and d…
…ronecan: - update dronecan submodule from v0.5.0 to v0.5.1 - cyphal does not support logging yet, so do nothing
- Loading branch information
1 parent
57c3890
commit 313f744
Showing
10 changed files
with
90 additions
and
9 deletions.
There are no files selected for viewing
Submodule Dronecan
updated
7 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* This program is free software under the GNU General Public License v3. | ||
* See <https://www.gnu.org/licenses/> for details. | ||
* Author: Dmitry Ponomarev <[email protected]> | ||
* Author: Anastasiia Stepanova <[email protected]> | ||
*/ | ||
|
||
#include "common/logging.hpp" | ||
#include "common/module.hpp" | ||
|
||
#ifndef CONFIG_USE_DRONECAN | ||
#define CONFIG_USE_DRONECAN 0 | ||
#elif defined(CONFIG_USE_DRONECAN) && CONFIG_USE_DRONECAN == 1 | ||
#include "logger.hpp" | ||
#endif | ||
|
||
#ifndef CONFIG_USE_CYPHAL | ||
#define CONFIG_USE_CYPHAL 0 | ||
#elif defined(CONFIG_USE_CYPHAL) && CONFIG_USE_CYPHAL == 1 | ||
#endif | ||
|
||
|
||
Logging::Logging(const char* source_) : source(source_) { | ||
} | ||
|
||
void Logging::log([[maybe_unused]] uint8_t severity, [[maybe_unused]] const char* text) const { | ||
#if CONFIG_USE_DRONECAN == 1 | ||
if (ModuleManager::get_active_protocol() == Module::Protocol::DRONECAN) { | ||
DronecanLogger::log_global(severity, source, text); | ||
} | ||
#endif | ||
|
||
#if CONFIG_USE_CYPHAL == 1 | ||
if (ModuleManager::get_active_protocol() == Module::Protocol::CYPHAL) { | ||
// CyphalLogger::log_global(severity, source, text); | ||
} | ||
#endif | ||
} | ||
|
||
void Logging::log_debug(const char* text) const { | ||
log(0, text); | ||
} | ||
|
||
void Logging::log_info(const char* text) const { | ||
log(1, text); | ||
} | ||
|
||
void Logging::log_warn(const char* text) const { | ||
log(2, text); | ||
} | ||
|
||
void Logging::log_error(const char* text) const { | ||
log(3, text); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* This program is free software under the GNU General Public License v3. | ||
* See <https://www.gnu.org/licenses/> for details. | ||
* Author: Dmitry Ponomarev <[email protected]> | ||
* Author: Anastasiia Stepanova <[email protected]> | ||
*/ | ||
|
||
#ifndef SRC_COMMON_LOGGING_HPP_ | ||
#define SRC_COMMON_LOGGING_HPP_ | ||
|
||
#include <stdint.h> | ||
|
||
class Logging { | ||
public: | ||
explicit Logging(const char* source_); | ||
|
||
void log_debug(const char* text) const; | ||
void log_info(const char* text) const; | ||
void log_warn(const char* text) const; | ||
void log_error(const char* text) const; | ||
|
||
void log(uint8_t severity, const char* text) const; | ||
private: | ||
const char* source{nullptr}; | ||
}; | ||
|
||
#endif // SRC_COMMON_LOGGING_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters