From: bernie Date: Sun, 10 Aug 2008 17:18:44 +0000 (+0000) Subject: log: Retouch documentation; Rearrenge level logic; Rename LOG_VERBOSITY to LOG_FORMAT... X-Git-Tag: 2.0.0~331 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=515886be3106584a6d695d4b5453730121b91f74;p=bertos.git log: Retouch documentation; Rearrenge level logic; Rename LOG_VERBOSITY to LOG_FORMAT for clarity git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1603 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/app/triface/boot/cfg/cfg_kfile.h b/app/triface/boot/cfg/cfg_kfile.h index cec293c8..e4f13b25 100644 --- a/app/triface/boot/cfg/cfg_kfile.h +++ b/app/triface/boot/cfg/cfg_kfile.h @@ -33,32 +33,19 @@ * \brief Configuration file for KFile interface module. * * \version $Id$ - * * \author Daniele Basile */ #ifndef CFG_KFILE_H #define CFG_KFILE_H -/** - * Logging level definition. - * - * Use 0 to log only the error messages - * Use 1 to log the error and warning messages - * Use 2 to log all messages - */ -#define KFILE_LOG_LEVEL 2 +/// Module logging level definition. +#define KFILE_LOG_LEVEL LOG_LVL_INFO -/** - * Set logging verbosity. - * - * If verbosity is zero print short log messages. - */ -#define KFILE_LOG_VERBOSITY 0 +/// Module logging verbosity. +#define KFILE_LOG_FORMAT LOG_FMT_TERSE /// Enable the gets function with echo. #define CONFIG_KFILE_GETS 1 #endif /* CFG_KFILE_H */ - - diff --git a/app/triface/cfg/cfg_kfile.h b/app/triface/cfg/cfg_kfile.h index cec293c8..10bb72db 100644 --- a/app/triface/cfg/cfg_kfile.h +++ b/app/triface/cfg/cfg_kfile.h @@ -27,38 +27,25 @@ * the GNU General Public License. * * Copyright 2008 Develer S.r.l. (http://www.develer.com/) - * All Rights Reserved. + * * --> * * \brief Configuration file for KFile interface module. * * \version $Id$ - * * \author Daniele Basile */ #ifndef CFG_KFILE_H #define CFG_KFILE_H -/** - * Logging level definition. - * - * Use 0 to log only the error messages - * Use 1 to log the error and warning messages - * Use 2 to log all messages - */ -#define KFILE_LOG_LEVEL 2 +/// Module logging level definition. +#define KFILE_LOG_LEVEL LOG_LVL_INFO -/** - * Set logging verbosity. - * - * If verbosity is zero print short log messages. - */ -#define KFILE_LOG_VERBOSITY 0 +/// Module logging format. +#define KFILE_LOG_FORMAT LOG_FMT_TERSE /// Enable the gets function with echo. #define CONFIG_KFILE_GETS 1 #endif /* CFG_KFILE_H */ - - diff --git a/bertos/cfg/cfg_adc.h b/bertos/cfg/cfg_adc.h index 26254a41..84a6da3a 100644 --- a/bertos/cfg/cfg_adc.h +++ b/bertos/cfg/cfg_adc.h @@ -27,35 +27,23 @@ * the GNU General Public License. * * Copyright 2008 Develer S.r.l. (http://www.develer.com/) - * All Rights Reserved. + * * --> * * \brief Configuration file for ADC module. * * \version $Id$ - * * \author Daniele Basile */ #ifndef CFG_ADC_H #define CFG_ADC_H -/** - * Logging level definition. - * - * Use 0 to log only the error messages - * Use 1 to log the error and warning messages - * Use 2 to log all messages - */ -#define ADC_LOG_LEVEL 2 - -/** - * Set logging verbosity. - * - * If verbosity is zero print short log messages. - */ -#define ADC_LOG_VERBOSITY 1 +/// Module logging level. +#define ADC_LOG_LEVEL LOG_LVL_INFO +/// Module logging format. +#define ADC_LOG_FORMAT LOG_FMT_VERBOSE /** * ADC timing setting parameter @@ -78,4 +66,3 @@ #define CONFIG_ADC_STROBE 0 #endif /* CFG_ADC_H */ - diff --git a/bertos/cfg/cfg_dataflash.h b/bertos/cfg/cfg_dataflash.h index d0ff90e4..92171e22 100644 --- a/bertos/cfg/cfg_dataflash.h +++ b/bertos/cfg/cfg_dataflash.h @@ -33,30 +33,16 @@ * \brief Configuration file for data flash memory module. * * \version $Id$ - * * \author Daniele Basile */ #ifndef CFG_DATAFLASH_H #define CFG_DATAFLASH_H -/** - * Logging level definition. - * - * Use 0 to log only the error messages - * Use 1 to log the error and warning messages - * Use 2 to log all messages - */ -#define DATAFLASH_LOG_LEVEL 2 - -/** - * Set logging verbosity. - * - * If verbosity is zero print short log messages. - */ -#define DATAFLASH_LOG_VERBOSITY 0 +/// Module logging level definition. +#define DATAFLASH_LOG_LEVEL LOG_LVL_INFO +/// Module logging format. +#define DATAFLASH_LOG_FORMAT LOG_FMT_TERSE #endif /* CFG_DATAFLASH_H */ - - diff --git a/bertos/cfg/cfg_flash_avr.h b/bertos/cfg/cfg_flash_avr.h index 49c5eaf8..0196c092 100644 --- a/bertos/cfg/cfg_flash_avr.h +++ b/bertos/cfg/cfg_flash_avr.h @@ -27,14 +27,12 @@ * the GNU General Public License. * * Copyright 2008 Develer S.r.l. (http://www.develer.com/) - * All Rights Reserved. * --> * - * \brief Configuration file for flash_avr module. - * * \version $Id$ - * * \author Manuele Fanelli + * + * \brief Configuration file for flash_avr module. */ #ifndef CFG_FLASH_AVR_H @@ -46,6 +44,6 @@ */ #define CONFIG_FLASH_AVR_BOOTSIZE 8192 #define CONFIG_FLASH_AVR_LOG_LEVEL LOG_LVL_ERR -#define CONFIG_FLASH_AVR_LOG_VERBOSITY LOG_SILENT +#define CONFIG_FLASH_AVR_LOG_FORMAT LOG_FMT_SILENT #endif /* CFG_BOOT_H */ diff --git a/bertos/cfg/cfg_kern.h b/bertos/cfg/cfg_kern.h index 368e59d0..a135843d 100644 --- a/bertos/cfg/cfg_kern.h +++ b/bertos/cfg/cfg_kern.h @@ -67,5 +67,6 @@ #define CONFIG_KERN_QUANTUM 50 /**< Time sharing quantum in timer ticks. */ +#define CONFIG_KERN_LOGLEVEL LOG_LVL_ERR #endif /* CFG_KERN_H */ diff --git a/bertos/cfg/cfg_kfile.h b/bertos/cfg/cfg_kfile.h index bc6ff25f..b1489f8e 100644 --- a/bertos/cfg/cfg_kfile.h +++ b/bertos/cfg/cfg_kfile.h @@ -27,38 +27,25 @@ * the GNU General Public License. * * Copyright 2008 Develer S.r.l. (http://www.develer.com/) - * All Rights Reserved. + * * --> * * \brief Configuration file for KFile interface module. * * \version $Id$ - * * \author Daniele Basile */ #ifndef CFG_KFILE_H #define CFG_KFILE_H -/** - * Logging level definition. - * - * Use 0 to log only the error messages - * Use 1 to log the error and warning messages - * Use 2 to log all messages - */ -#define KFILE_LOG_LEVEL 2 +/// Module logging level. +#define KFILE_LOG_LEVEL LOG_LVL_INFO -/** - * Set logging verbosity. - * - * If verbosity is zero print short log messages. - */ -#define KFILE_LOG_VERBOSITY 0 +/// Module logging format. +#define KFILE_LOG_FORMAT LOG_FMT_TERSE /// Enable the gets function with echo. #define CONFIG_KFILE_GETS 0 #endif /* CFG_KFILE_H */ - - diff --git a/bertos/cfg/cfg_pwm.h b/bertos/cfg/cfg_pwm.h index e7ce27c4..072f9b6d 100644 --- a/bertos/cfg/cfg_pwm.h +++ b/bertos/cfg/cfg_pwm.h @@ -27,36 +27,21 @@ * the GNU General Public License. * * Copyright 2008 Develer S.r.l. (http://www.develer.com/) - * All Rights Reserved. * --> * * \brief Configuration file for PWM module. * * \version $Id$ - * * \author Daniele Basile */ #ifndef CFG_PWM_H #define CFG_PWM_H -/** - * Logging level definition. - * - * Use 0 to log only the error messages - * Use 1 to log the error and warning messages - * Use 2 to log all messages - */ -#define PWM_LOG_LEVEL 2 - -/** - * Set logging verbosity. - * - * If verbosity is zero print short log messages. - */ -#define PWM_LOG_VERBOSITY 1 +/// Module logging level. +#define PWM_LOG_LEVEL LOG_LVL_INFO +/// Module logging format. +#define PWM_LOG_FORMAT LOG_FMT_VERBOSE #endif /* CFG_PWM_H */ - - diff --git a/bertos/cfg/cfg_stepper.h b/bertos/cfg/cfg_stepper.h index 1efeef26..590e3c57 100644 --- a/bertos/cfg/cfg_stepper.h +++ b/bertos/cfg/cfg_stepper.h @@ -27,35 +27,23 @@ * the GNU General Public License. * * Copyright 2008 Develer S.r.l. (http://www.develer.com/) - * All Rights Reserved. + * * --> * * \brief Configuration file for stepper motor module. * * \version $Id$ - * * \author Daniele Basile */ #ifndef CFG_STEPPER_H #define CFG_STEPPER_H -/** - * Logging level definition. - * - * Use 0 to log only the error messages - * Use 1 to log the error and warning messages - * Use 2 to log all messages - */ -#define STEPPER_LOG_LEVEL 2 - -/** - * Set logging verbosity. - * - * If verbosity is zero print short log messages. - */ -#define STEPPER_LOG_VERBOSITY 0 +/// Module logging level. +#define STEPPER_LOG_LEVEL LOG_LVL_INFO +/// Module logging format. +#define STEPPER_LOG_FORMAT LOG_FMT_TERSE /// Max number of the stepper motor. #define CONFIG_NUM_STEPPER_MOTORS 6 @@ -64,4 +52,3 @@ #define CONFIG_TC_STEPPER_MAX_NUM 6 #endif /* CFG_STEPPER_H */ - diff --git a/bertos/cfg/log.h b/bertos/cfg/log.h index 91ff066d..2cfa4ef2 100644 --- a/bertos/cfg/log.h +++ b/bertos/cfg/log.h @@ -27,7 +27,7 @@ * the GNU General Public License. * * Copyright 2008 Develer S.r.l. (http://www.develer.com/) - * All Rights Reserved. + * * --> * * \brief Logging system module. @@ -35,9 +35,9 @@ * This module implement a simple interface to use the multi level logging system. * The log message have the priority order, like this: * - * - error message (most hight) + * - error message (highest) * - warning message - * - info message (most low) + * - info message (lowest) * * With this priority system we can log only the message that have egual or major * priority than log level that you has been configurate. Further you can have a @@ -56,37 +56,23 @@ * level and verbosity mode for your specific module: * * \code + * /// Module logging level. + * #define _LOG_LEVEL LOG_LVL_INFO * - * ** - * * Logging level definition. - * * - * * Use 0 to log only the error messages - * * Use 1 to log the error and warning messages - * * Use 2 to log all messages - * * - * #define _LOG_LEVEL 2 - * - * ** - * * Set logging verbosity. - * * - * * If verbose is zero print short log messages. - * * - * #define _LOG_VERBOSE 1 - * + * /// Module logging format. + * #define _LOG_FORMAT LOG_FMT_VERBOSE * \endcode * * - then, in the module that you use a logging macros you should define - * a LOG_LEVEL and LOG_VERBOSE using the previous value that you have define + * a LOG_LEVEL and LOG_FORMAT using the previous value that you have define * in cfg_.h header. After this you should include the cfg/log.h * module: * * \code - * - * // Define logging setting (for cfg/log.h module). - * #define LOG_LEVEL _LOG_LEVEL - * #define LOG_VERBOSE _LOG_VERBOSE + * // Define log settings for cfg/log.h. + * #define LOG_LEVEL _LOG_LEVEL + * #define LOG_FORMAT _LOG_FORMAT * #include - * * \endcode * * if you include a log.h module without define the LOG_LEVEL and LOG_VERBOSE @@ -98,8 +84,8 @@ * otherwise the log module use a default settings. * * \version $Id$ - * * \author Daniele Basile + * */ #ifndef CFG_LOG_H @@ -108,73 +94,71 @@ #include -// Use a default setting if nobody have define a log level +// Use a default setting if nobody defined a log level #ifndef LOG_LEVEL #define LOG_LEVEL LOG_LVL_ERR #endif -// Use a default setting if nobody have define a log verbosity -#ifndef LOG_VERBOSITY -#define LOG_VERBOSITY LOG_SILENT +// Use a default setting if nobody defined a log format +#ifndef LOG_FORMAT +#define LOG_FORMAT LOG_FMT_TERSE #endif /** -* Multi level logging system. -* -* You can use these macro directy or using the cfg/log.h module -* that provide a simple interface for using the logging multilevel system. -* The priority level is order form error messages (hight priority) to info messages -* (low priority), so if you choose a low level log message you can see also all message -* that have a hight priority. -* -* \{ -*/ -/// Logging level definition -#define LOG_LVL_ERR 0 -#define LOG_LVL_WARN 1 -#define LOG_LVL_INFO 2 - -/// Logging verbose mode -#define LOG_VERBOSE 1 -#define LOG_SILENT 0 - - -#if LOG_VERBOSITY == LOG_VERBOSE - #define LOG_PRINT(str_level, str,...) kprintf("%s(%s():%d): "str, str_level, __func__, __LINE__, ## __VA_ARGS__) - -#elif LOG_VERBOSITY == LOG_SILENT - #define LOG_PRINT(str_level, str,...) kprintf("%s: "str, str_level, ## __VA_ARGS__) - -#else - #error No log verbosity defined - -#endif - -/** - * Log message level select. + * \name Logging level definition + * * When you choose a log level messages you choose * also which print function are linked. * If you choose a low level of log you link all log function (error, warning and info), * but if choose a hight level you link only that have the priority egual or hight. * The priority level go from error (most hight) to info (most low) (see cfg/debug.h * for more detail). + * \{ + */ +#define LOG_LVL_NONE 0 +#define LOG_LVL_ERR 1 +#define LOG_LVL_WARN 2 +#define LOG_LVL_INFO 3 +/* \} */ + +/** + * \name Logging format * + * There are two logging format: terse and verbose. The latter prepends + * function names and line number information to each log entry. + * \{ */ -#define LOG_ERR(str,...) LOG_PRINT("ERR", str, ## __VA_ARGS__) +#define LOG_FMT_VERBOSE 1 +#define LOG_FMT_TERSE 0 +/* \} */ -#if (LOG_LEVEL == LOG_LVL_INFO) - #define LOG_WARN(str,...) LOG_PRINT("WARN", str, ## __VA_ARGS__) - #define LOG_INFO(str,...) LOG_PRINT("INFO", str, ## __VA_ARGS__) +#define LOG_SILENT LOG_FMT_TERSE /* OBSOLETE */ +#define LOG_VERBOSE LOG_FMT_VERBOSE /* OBSOLETE */ -#elif (LOG_LEVEL == LOG_LVL_WARN) - #define LOG_WARN(str,...) LOG_PRINT("WARN", str, ## __VA_ARGS__) - #define LOG_INFO(str,...) /* Nothing */ +#if LOG_FORMAT == LOG_FMT_VERBOSE + #define LOG_PRINT(str_level, str,...) kprintf("%s():%d:%s: " str, str_level, __func__, __LINE__, ## __VA_ARGS__) +#elif LOG_FORMAT == LOG_FMT_TERSE + #define LOG_PRINT(str_level, str,...) kprintf("%s: " str, str_level, ## __VA_ARGS__) +#else + #error No LOG_FORMAT defined +#endif + +#if LOG_LEVEL >= LOG_LVL_ERR + #define LOG_ERR(str,...) LOG_PRINT("ERR", str, ## __VA_ARGS__) +#else + #define LOG_ERR(str,...) /* Nothing */ +#endif -#else /* LOG_LEVEL == LOG_LVL_ERR */ +#if LOG_LEVEL >= LOG_LVL_WARN + #define LOG_WARN(str,...) LOG_PRINT("WARN", str, ## __VA_ARGS__) +#else #define LOG_WARN(str,...) /* Nothing */ - #define LOG_INFO(str,...) /* Nothing */ +#endif +#if LOG_LEVEL >= LOG_LVL_INFO + #define LOG_INFO(str,...) LOG_PRINT("INFO", str, ## __VA_ARGS__) +#else + #define LOG_INFO(str,...) /* Nothing */ #endif #endif /* CFG_LOG_H */ - diff --git a/bertos/cpu/arm/drv/pwm_at91.c b/bertos/cpu/arm/drv/pwm_at91.c index 7030dd2a..e0706812 100644 --- a/bertos/cpu/arm/drv/pwm_at91.c +++ b/bertos/cpu/arm/drv/pwm_at91.c @@ -34,7 +34,6 @@ * \brief PWM hardware-specific implementation * * \version $Id$ - * * \author Daniele Basile */ @@ -45,7 +44,7 @@ // Define logging setting (for cfg/log.h module). #define LOG_LEVEL PWM_LOG_LEVEL -#define LOG_VERBOSITY PWM_LOG_VERBOSITY +#define LOG_FORMAT PWM_LOG_FORMAT #include #include diff --git a/bertos/cpu/avr/drv/flash_avr.c b/bertos/cpu/avr/drv/flash_avr.c index 413cac80..daaf4d9b 100644 --- a/bertos/cpu/avr/drv/flash_avr.c +++ b/bertos/cpu/avr/drv/flash_avr.c @@ -50,9 +50,9 @@ #include #include - // Define logging setting (for cfg/log.h module). -#define LOG_LEVEL CONFIG_FLASH_AVR_LOG_LEVEL -#define LOG_VERBOSITY CONFIG_FLASH_AVR_LOG_VERBOSITY +// Define log settings for cfg/log.h +#define LOG_LEVEL CONFIG_FLASH_AVR_LOG_LEVEL +#define LOG_FORMAT CONFIG_FLASH_AVR_LOG_FORMAT #include #include @@ -66,7 +66,6 @@ #include - /** * Definition of type for avr flash module. */ diff --git a/bertos/drv/dataflash.c b/bertos/drv/dataflash.c index 554d15b8..a349895c 100644 --- a/bertos/drv/dataflash.c +++ b/bertos/drv/dataflash.c @@ -30,7 +30,7 @@ * * --> * - * \brief Function library for dataflash AT45DB family (implementation). + * \brief Function library for dataflash AT45DB family (implementation). * * * \version $Id: dataflash.c 21658 2008-06-05 16:42:54Z asterix $ @@ -46,8 +46,8 @@ #include // Define logging setting (for cfg/log.h module). -#define LOG_LEVEL DATAFLASH_LOG_LEVEL -#define LOG_VERBOSITY DATAFLASH_LOG_VERBOSITY +#define LOG_LEVEL DATAFLASH_LOG_LEVEL +#define LOG_FORMAT DATAFLASH_LOG_FORMAT #include #include diff --git a/bertos/drv/dataflash_test.c b/bertos/drv/dataflash_test.c index 90f24ecb..276f9f43 100644 --- a/bertos/drv/dataflash_test.c +++ b/bertos/drv/dataflash_test.c @@ -45,7 +45,6 @@ * * * \version $Id$ - * * \author Daniele Basile */ @@ -58,8 +57,8 @@ #include // Define logging setting (for cfg/log.h module). -#define LOG_LEVEL DATAFLASH_LOG_LEVEL -#define LOG_VERBOSITY DATAFLASH_LOG_VERBOSITY +#define LOG_LEVEL DATAFLASH_LOG_LEVEL +#define LOG_FORMAT DATAFLASH_LOG_FORMAT #include // for logging system #include diff --git a/bertos/drv/pwm_test.c b/bertos/drv/pwm_test.c index 39b18b36..f66fe660 100644 --- a/bertos/drv/pwm_test.c +++ b/bertos/drv/pwm_test.c @@ -55,7 +55,6 @@ * and so the delay is do with a for cycle. * * \version $Id$ - * * \author Daniele Basile */ @@ -66,7 +65,7 @@ // Define logging setting (for cfg/log.h module). #define LOG_LEVEL PWM_LOG_LEVEL -#define LOG_VERBOSITY PWM_LOG_VERBOSITY +#define LOG_FORMAT PWM_LOG_FORMAT #include // for logging system #include diff --git a/bertos/drv/stepper.c b/bertos/drv/stepper.c index 6614623d..7586cf87 100644 --- a/bertos/drv/stepper.c +++ b/bertos/drv/stepper.c @@ -1,14 +1,37 @@ /** * \file * * * \brief Driver to control stepper motor * * \version $Id$ - * * \author Francesco Michelini * \author Giovanni Bajo * \author Bernie Innocenti @@ -25,8 +48,8 @@ #include // Define logging setting (for cfg/log.h module). -#define LOG_LEVEL STEPPER_LOG_LEVEL -#define LOG_VERBOSITY STEPPER_LOG_VERBOSITY +#define LOG_LEVEL STEPPER_LOG_LEVEL +#define LOG_FORMAT STEPPER_LOG_FORMAT #include #include diff --git a/bertos/drv/timer.c b/bertos/drv/timer.c index aa671dc4..94272639 100644 --- a/bertos/drv/timer.c +++ b/bertos/drv/timer.c @@ -341,3 +341,19 @@ void timer_init(void) MOD_INIT(timer); } + + +#if (ARCH & ARCH_EMUL) +/** + * Stop timer (only used by emulator) + */ +void timer_cleanup(void) +{ + MOD_CLEANUP(timer); + + timer_hw_cleanup(); + + // Hmmm... apparently, the demo app does not cleanup properly + //ASSERT(LIST_EMPTY(&timers_queue)); +} +#endif /* ARCH_EMUL */