This commit is contained in:
Ing-Dom 2023-12-29 11:27:06 +01:00
parent 2d40692a9f
commit e147e0e72f
3 changed files with 30 additions and 6 deletions

View File

@ -7,6 +7,7 @@
#include "string.h"
#include "bits.h"
#include <stdio.h>
#include "logger.h"
const SecurityControl ApplicationLayer::noSecurity {.toolAccess=false, .dataSecurity=DataSecurity::None};
@ -97,8 +98,9 @@ void ApplicationLayer::dataGroupConfirm(AckType ack, HopCountType hopType, Prior
_savedAsapWriteRequest = 0;
break;
default:
print("datagroup-confirm: unhandled APDU-Type: ");
println(apdu.type());
KNX_LOG_INFO<KNX_LOG_AL>("datagroup-confirm: unhandled APDU-Type: 0x%04x", apdu.type());
//print("datagroup-confirm: unhandled APDU-Type: 0x%04x", apdu.type());
//println(apdu.type());
}
}

9
src/knx/logger.cpp Normal file
View File

@ -0,0 +1,9 @@
#include "logger.h"
void KnxLogger::log(const char* message, va_list& values)
{
printf(message, values);
}
KnxLogger knxLogger;

View File

@ -12,8 +12,21 @@ Usage:
*/
#pragma once
#include <utility>
#include <string>
#include "platform.h"
class KnxLogger
{
public:
void log(const char* message, va_list& values);
};
extern KnxLogger knxLogger;
constexpr uint64_t KNX_LOG_LVL_ERROR = 1;
@ -46,26 +59,26 @@ template<uint64_t x, typename... Args>
__attribute__((always_inline)) constexpr void KNX_LOG_TRACE(Args&&... args)
{
if constexpr((LOGLEVEL >= KNX_LOG_LVL_TRACE) && (x & LOGAREAS))
printf(std::forward<Args>(args)...);
knxLogger.log(std::forward<Args>(args)...);
}
template<uint64_t x, typename... Args>
__attribute__((always_inline)) constexpr void KNX_LOG_DEBUG(Args&&... args)
{
if constexpr((LOGLEVEL >= KNX_LOG_LVL_DEBUG) && (x & LOGAREAS))
printf(std::forward<Args>(args)...);
knxLogger.log(std::forward<Args>(args)...);
}
template<uint64_t x, typename... Args>
__attribute__((always_inline)) constexpr void KNX_LOG_INFO(Args&&... args)
{
if constexpr((LOGLEVEL >= KNX_LOG_LVL_INFO) && (x & LOGAREAS))
printf(std::forward<Args>(args)...);
knxLogger.log(std::forward<Args>(args)...);
}
template<uint64_t x, typename... Args>
__attribute__((always_inline)) constexpr void KNX_LOG_ERROR(Args&&... args)
{
if constexpr((LOGLEVEL >= KNX_LOG_LVL_ERROR) && (x & LOGAREAS))
printf(std::forward<Args>(args)...);
knxLogger.log(std::forward<Args>(args)...);
}