Commit b9c8bcb5 authored by Michael Zehrer's avatar Michael Zehrer
Browse files

fix conditional logging interface

parent d38e73b9
/**
* Copyright (c) 2019, Michael Zehrer
* Copyright (c) 2019-2020, ARCTOS
* All rights reserved.
*
* @licence BSD
......@@ -12,6 +12,14 @@
#include <stdint.h>
#include <stddef.h>
#define ARCTOS_LOG_LEVEL_DEBUG 6
#define ARCTOS_LOG_LEVEL_INFO 5
#define ARCTOS_LOG_LEVEL_WARNING 4
#define ARCTOS_LOG_LEVEL_SYSTEM 3
#define ARCTOS_LOG_LEVEL_ERROR 2
#define ARCTOS_LOG_LEVEL_CRITICAL 1
#define ARCTOS_LOG_LEVEL_NONE 0
#include <arctos/params.h>
namespace arctos {
......@@ -19,57 +27,45 @@ namespace log {
namespace level {
enum Level {
kDebug,
kInfo,
kWarning,
kSystem,
kError,
kCritical,
kNone
kDebug = ARCTOS_LOG_LEVEL_DEBUG,
kInfo = ARCTOS_LOG_LEVEL_INFO,
kWarning = ARCTOS_LOG_LEVEL_WARNING,
kSystem = ARCTOS_LOG_LEVEL_SYSTEM,
kError = ARCTOS_LOG_LEVEL_ERROR,
kCritical = ARCTOS_LOG_LEVEL_CRITICAL,
kNone = ARCTOS_LOG_LEVEL_NONE
};
}
#if ARCTOS_LOG_LEVEL == kDebug
#if ARCTOS_LOG_LEVEL >= ARCTOS_LOG_LEVEL_DEBUG
#define ARCTOS_LOG_DEBUG_AVAILABLE
__attribute__((__format__(__printf__, 1, 2))) size_t debug(const char *fmt, ...);
#else
inline size_t debug(...) { return 0; }
#endif
#if ARCTOS_LOG_LEVEL == kDebug || \
ARCTOS_LOG_LEVEL == kInfo
#if ARCTOS_LOG_LEVEL >= ARCTOS_LOG_LEVEL_INFO
#define ARCTOS_LOG_INFO_AVAILABLE
__attribute__((__format__(__printf__, 1, 2))) size_t info(const char *fmt, ...);
#else
inline size_t info(...) { return 0; }
#endif
#if ARCTOS_LOG_LEVEL == kDebug || \
ARCTOS_LOG_LEVEL == kInfo || \
ARCTOS_LOG_LEVEL == kWarning
#if ARCTOS_LOG_LEVEL >= ARCTOS_LOG_LEVEL_WARNING
#define ARCTOS_LOG_WARNING_AVAILABLE
__attribute__((__format__(__printf__, 1, 2))) size_t warning(const char *fmt, ...);
#else
inline size_t warning(...) { return 0; }
#endif
#if ARCTOS_LOG_LEVEL == kDebug || \
ARCTOS_LOG_LEVEL == kInfo || \
ARCTOS_LOG_LEVEL == kWarning || \
ARCTOS_LOG_LEVEL == kSystem || \
ARCTOS_LOG_LEVEL == kError
#if ARCTOS_LOG_LEVEL >= ARCTOS_LOG_LEVEL_ERROR
#define ARCTOS_LOG_ERROR_AVAILABLE
__attribute__((__format__(__printf__, 1, 2))) size_t error(const char *fmt, ...);
#else
inline size_t error(...) { return 0; }
#endif
#if ARCTOS_LOG_LEVEL == kDebug || \
ARCTOS_LOG_LEVEL == kInfo || \
ARCTOS_LOG_LEVEL == kWarning || \
ARCTOS_LOG_LEVEL == kSystem || \
ARCTOS_LOG_LEVEL == kError || \
ARCTOS_LOG_LEVEL == kCritical
#if ARCTOS_LOG_LEVEL >= ARCTOS_LOG_LEVEL_CRITICAL
#define ARCTOS_LOG_CRITICAL_AVAILABLE
__attribute__((__format__(__printf__, 1, 2))) size_t critical(const char *fmt, ...);
#else
......
/**
* Copyright (c) 2019, Michael Zehrer
* Copyright (c) 2019-2020, ARCTOS
* All rights reserved.
*
* @licence BSD
......@@ -18,10 +18,7 @@
namespace arctos {
namespace log {
#if ARCTOS_LOG_LEVEL == kDebug || \
ARCTOS_LOG_LEVEL == kInfo || \
ARCTOS_LOG_LEVEL == kWarning || \
ARCTOS_LOG_LEVEL == kSystem
#if ARCTOS_LOG_LEVEL >= ARCTOS_LOG_LEVEL_SYSTEM
#define ARCTOS_LOG_SYSTEM_AVAILABLE
__attribute__((__format__(__printf__, 1, 2))) size_t system(const char *fmt, ...);
#else
......
......@@ -2,13 +2,13 @@
<segment name="independent">
<types>
<type name="log_level">
<item id="kDebug" readable="Debug" />
<item id="kInfo" readable="Info" />
<item id="kWarning" readable="Warning" />
<item id="kSystem" readable="System" />
<item id="kError" readable="Error" />
<item id="kCritical" readable="Critical" />
<item id="kNone" readable="None" />
<item id="ARCTOS_LOG_LEVEL_DEBUG" readable="Debug" />
<item id="ARCTOS_LOG_LEVEL_INFO" readable="Info" />
<item id="ARCTOS_LOG_LEVEL_WARNING" readable="Warning" />
<item id="ARCTOS_LOG_LEVEL_SYSTEM" readable="System" />
<item id="ARCTOS_LOG_LEVEL_ERROR" readable="Error" />
<item id="ARCTOS_LOG_LEVEL_CRITICAL" readable="Critical" />
<item id="ARCTOS_LOG_LEVEL_NONE" readable="None" />
</type>
</types>
<configuration>
......@@ -34,7 +34,7 @@
<option.description>
Defines the verbosity level of the build-in logging interface
</option.description>
<option.value>kDebug</option.value>
<option.value>ARCTOS_LOG_LEVEL_DEBUG</option.value>
</option>
<option definition="ARCTOS_LOG_ENABLE_COLOR" readable="Enable colored output" type="bool">
<option.description>
......
/**
* Copyright (c) 2019, Michael Zehrer
* Copyright (c) 2019-2020, ARCTOS
* All rights reserved.
*
* @licence BSD
......
......@@ -128,7 +128,7 @@ void hwInit(void) {
_branchPredictor_enable();
#endif
#if ARCTOS_LOG_LEVEL != kNone
#if ARCTOS_LOG_LEVEL != ARCTOS_LOG_LEVEL_NONE
modules::serial::Serial *s = modules::serial::get(RPI_LOG_DESTINATION);
s->begin();
arctos::log::Logger::instance()->setDestination(s);
......
/**
* Generated on 2019-12-19 21:18
* Generated on 2020-01-10 12:05
* DO NOT EDIT
*
* @brief automatically generated params header
......@@ -9,7 +9,7 @@
#define ARCTOS_DEFAULT_TASK_PRIORITY 10
#define ARCTOS_DEFAULT_STACKSIZE 1024
#define ARCTOS_LOG_LEVEL kDebug
#define ARCTOS_LOG_LEVEL ARCTOS_LOG_LEVEL_DEBUG
#define ARCTOS_LOG_ENABLE_COLOR
#define ARCTOS_SCHEDULER_TIME_SLOT_SIZE 100000
#define RPI_ENABLE_FPU
......
/**
* Generated on 2019-12-19 21:18
* Generated on 2020-01-10 12:05
* DO NOT EDIT
*
* @brief automatically generated params header
......
......@@ -2,7 +2,7 @@
# This script is automatically generated
# DO NOT EDIT
#
# Generated on 2019-12-19 21:18
# Generated on 2020-01-10 12:05
#
set(ARCTOS_TARGET "raspberry")
......@@ -18,7 +18,7 @@ target_link_libraries(${UNIT} ${ARCTOS_INTERFACE})
############ BEGIN-TARGET: raspberry #############
set(ARCTOS_DEFAULT_TASK_PRIORITY "10")
set(ARCTOS_DEFAULT_STACKSIZE "1024")
set(ARCTOS_LOG_LEVEL "kDebug")
set(ARCTOS_LOG_LEVEL "ARCTOS_LOG_LEVEL_DEBUG")
set(ARCTOS_LOG_ENABLE_COLOR on)
set(ARCTOS_SCHEDULER_TIME_SLOT_SIZE "100000")
set(RPI_ENABLE_FPU on)
......
/**
* Generated on 2019-12-19 21:18
* Generated on 2020-01-10 12:05
* DO NOT EDIT
*
* @brief automatically generated params header
......@@ -9,7 +9,7 @@
#define ARCTOS_DEFAULT_TASK_PRIORITY 10
#define ARCTOS_DEFAULT_STACKSIZE 1024
#define ARCTOS_LOG_LEVEL kDebug
#define ARCTOS_LOG_LEVEL ARCTOS_LOG_LEVEL_DEBUG
#define ARCTOS_LOG_ENABLE_COLOR
#define ARCTOS_SCHEDULER_TIME_SLOT_SIZE 100000
#define RPI_ENABLE_FPU
......
/**
* Generated on 2019-12-19 21:18
* Generated on 2020-01-10 12:05
* DO NOT EDIT
*
* @brief automatically generated params header
......
......@@ -2,7 +2,7 @@
# This script is automatically generated
# DO NOT EDIT
#
# Generated on 2019-12-19 21:18
# Generated on 2020-01-10 12:05
#
set(ARCTOS_TARGET "raspberry")
......@@ -18,7 +18,7 @@ target_link_libraries(${UNIT} ${ARCTOS_INTERFACE})
############ BEGIN-TARGET: raspberry #############
set(ARCTOS_DEFAULT_TASK_PRIORITY "10")
set(ARCTOS_DEFAULT_STACKSIZE "1024")
set(ARCTOS_LOG_LEVEL "kDebug")
set(ARCTOS_LOG_LEVEL "ARCTOS_LOG_LEVEL_DEBUG")
set(ARCTOS_LOG_ENABLE_COLOR on)
set(ARCTOS_SCHEDULER_TIME_SLOT_SIZE "100000")
set(RPI_ENABLE_FPU on)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment