diff --git a/libraries/AP_Logger/AP_Logger_Backend.cpp b/libraries/AP_Logger/AP_Logger_Backend.cpp index 18029145dac80..2f6c160bc70c3 100644 --- a/libraries/AP_Logger/AP_Logger_Backend.cpp +++ b/libraries/AP_Logger/AP_Logger_Backend.cpp @@ -1,3 +1,7 @@ +#include "AP_Logger_config.h" + +#if HAL_LOGGING_ENABLED + #include "AP_Logger_Backend.h" #include "LoggerMessageWriter.h" @@ -752,3 +756,5 @@ bool AP_Logger_RateLimiter::should_log(uint8_t msgid, bool writev_streaming) } return ret; } + +#endif // HAL_LOGGING_ENABLED diff --git a/libraries/AP_Logger/AP_Logger_Backend.h b/libraries/AP_Logger/AP_Logger_Backend.h index 65ed643dcef86..70bcdc9f7b524 100644 --- a/libraries/AP_Logger/AP_Logger_Backend.h +++ b/libraries/AP_Logger/AP_Logger_Backend.h @@ -1,5 +1,9 @@ #pragma once +#include "AP_Logger_config.h" + +#if HAL_LOGGING_ENABLED + #include "AP_Logger.h" #include @@ -259,3 +263,5 @@ class AP_Logger_Backend void Write_AP_Logger_Stats_File(const struct df_stats &_stats); void validate_WritePrioritisedBlock(const void *pBuffer, uint16_t size); }; + +#endif // HAL_LOGGING_ENABLED diff --git a/libraries/AP_Logger/AP_Logger_config.h b/libraries/AP_Logger/AP_Logger_config.h index 1087a9a4e357c..afbbc52e150aa 100644 --- a/libraries/AP_Logger/AP_Logger_config.h +++ b/libraries/AP_Logger/AP_Logger_config.h @@ -7,17 +7,21 @@ #define HAL_LOGGING_ENABLED 1 #endif +#ifndef HAL_LOGGING_BACKEND_DEFAULT_ENABLED +#define HAL_LOGGING_BACKEND_DEFAULT_ENABLED HAL_LOGGING_ENABLED +#endif + // set default for HAL_LOGGING_DATAFLASH_ENABLED #ifndef HAL_LOGGING_DATAFLASH_ENABLED -#define HAL_LOGGING_DATAFLASH_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) +#define HAL_LOGGING_DATAFLASH_ENABLED HAL_LOGGING_BACKEND_DEFAULT_ENABLED && (CONFIG_HAL_BOARD == HAL_BOARD_SITL) #endif #ifndef HAL_LOGGING_MAVLINK_ENABLED - #define HAL_LOGGING_MAVLINK_ENABLED HAL_LOGGING_ENABLED + #define HAL_LOGGING_MAVLINK_ENABLED HAL_LOGGING_BACKEND_DEFAULT_ENABLED #endif #ifndef HAL_LOGGING_FILESYSTEM_ENABLED -#define HAL_LOGGING_FILESYSTEM_ENABLED HAL_LOGGING_ENABLED && AP_FILESYSTEM_FILE_WRITING_ENABLED +#define HAL_LOGGING_FILESYSTEM_ENABLED HAL_LOGGING_BACKEND_DEFAULT_ENABLED && AP_FILESYSTEM_FILE_WRITING_ENABLED #endif #if HAL_LOGGING_DATAFLASH_ENABLED diff --git a/libraries/AP_Logger/LogFile.cpp b/libraries/AP_Logger/LogFile.cpp index d393ebd7d7c38..1f2ac1cb33414 100644 --- a/libraries/AP_Logger/LogFile.cpp +++ b/libraries/AP_Logger/LogFile.cpp @@ -1,3 +1,7 @@ +#include "AP_Logger_config.h" + +#if HAL_LOGGING_ENABLED + #include #include @@ -561,3 +565,5 @@ void AP_Logger::Write_PSCD(float pos_target, float pos, float vel_desired, float { Write_PSCx(LOG_PSCD_MSG, pos_target, pos, vel_desired, vel_target, vel, accel_desired, accel_target, accel); } + +#endif // HAL_LOGGING_ENABLED diff --git a/libraries/AP_Logger/LoggerMessageWriter.cpp b/libraries/AP_Logger/LoggerMessageWriter.cpp index 2de1050aefc0d..6e4f01e0a2144 100644 --- a/libraries/AP_Logger/LoggerMessageWriter.cpp +++ b/libraries/AP_Logger/LoggerMessageWriter.cpp @@ -1,3 +1,7 @@ +#include "AP_Logger_config.h" + +#if HAL_LOGGING_ENABLED + #include "AP_Common/AP_FWVersion.h" #include "LoggerMessageWriter.h" #include @@ -519,3 +523,5 @@ void LoggerMessageWriter_Write_Polyfence::reset() } #endif // !APM_BUILD_TYPE(APM_BUILD_Replay) #endif // AP_FENCE_ENABLED + +#endif // HAL_LOGGING_ENABLED