Add support for a warn() marco that will be between dbg() and info() in priority

This commit is contained in:
Gregory Nutt 2016-06-11 12:38:37 -06:00
parent fc3540cffe
commit a3bb764305
3 changed files with 498 additions and 301 deletions

11
Kconfig
View File

@ -413,9 +413,18 @@ if DEBUG
comment "Debug SYSLOG Output Controls" comment "Debug SYSLOG Output Controls"
config CONFIG_DEBUG_INFO config DEBUG_WARNINGS
bool "Enable Warnings Output"
default n
---help---
Enables output from warning statements. Warnings are considered to
be potential errors or errors that will not have serious
consequences.
config DEBUG_INFO
bool "Enable Informational Debug Output" bool "Enable Informational Debug Output"
default n default n
depends on DEBUG_WARNINGS
---help--- ---help---
Enables verbose "informational" debug output. If you enable Enables verbose "informational" debug output. If you enable
CONFIG_DEBUG_INFO, then very chatty (and often annoying) output CONFIG_DEBUG_INFO, then very chatty (and often annoying) output

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* include/debug.h * include/debug.h
* *
* Copyright (C) 2007-2011, 2014 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2011, 2014, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -56,11 +56,16 @@
/* Debug macros to runtime filter the debug messages sent to the console. In /* Debug macros to runtime filter the debug messages sent to the console. In
* general, there are four forms of the debug macros: * general, there are four forms of the debug macros:
* *
* [a-z]dbg() -- Outputs messages to the console similar to printf() except * [a-z]info() -- Outputs messages to the console similar to printf() except
* that the output is not buffered. The first character indicates the * that the output is not buffered. Output is only generated if
* system system (e.g., n=network, f=filesystm, etc.). If the first * CONFIG_DEBUG_INFO is defined. The info macros are intended for
* character is missing (i.e., dbg()), then it is common. The common * verbose "informational" debug output. If you enable CONFIG_DEBUG_INFO,
* dbg() macro is enabled by CONFIG_DEBUG. Subsystem debug requires an * then very chatty (and often annoying) output will be generated.
*
* The first character of the macro name indicates the system system
* (e.g., n=network, f=filesystm, etc.). If the first character is
* missing (i.e., info()), then it is common. The common info() macro
* is enabled simply with CONFIG_DEBUG_INFO. Subsystem debug requires an
* additional configuration setting to enable it (e.g., CONFIG_DEBUG_NET * additional configuration setting to enable it (e.g., CONFIG_DEBUG_NET
* for the network, CONFIG_DEBUG_FS for the file system, etc). * for the network, CONFIG_DEBUG_FS for the file system, etc).
* *
@ -70,41 +75,53 @@
* directed stdout). Therefore [a-z]dbg() should not be used in interrupt * directed stdout). Therefore [a-z]dbg() should not be used in interrupt
* handlers. * handlers.
* *
* [a-z]info() -- Identical to [a-z]dbg() except that it also requires that * [a-z]warn() -- Identical to [a-z]info() except that it also requires that
* CONFIG_DEBUG_INFO be defined. This is intended for general debug * CONFIG_DEBUG_WARN be defined. This is intended for important exception
* output that you would normally want to suppress. * conditions that are potential errors (or perhaps real errors with non-
* fatal consequences).
* *
* [a-z]lldbg() -- Identical to [a-z]dbg() except this is uses special * [a-z]dbg() -- Identical to [a-z]info() except that it also requires that
* CONFIG_DEBUG be defined. This is intended for important error-related
* information that you probably not want to suppress during normal debug
* general debugging.
*
* [a-z]llinfo() -- Identical to [a-z]dbg() except this is uses special
* interfaces provided by architecture-specific logic to talk directly * interfaces provided by architecture-specific logic to talk directly
* to the underlying console hardware. If the architecture provides such * to the underlying console hardware. If the architecture provides such
* logic, it should define CONFIG_ARCH_LOWPUTC. * logic, it should define CONFIG_ARCH_LOWPUTC.
* *
* [a-z]lldbg() should not be used in normal code because the implementation * [a-z]llinfo() should not be used in normal code because the implementation
* probably disables interrupts and does things that are not consistent with * probably disables interrupts and does things that are not consistent with
* good real-time performance. However, [a-z]lldbg() is particularly useful * good real-time performance. However, [a-z]llinfo() is particularly useful
* in low-level code where it is inappropriate to use file descriptors. For * in low-level code where it is inappropriate to use file descriptors. For
* example, only [a-z]lldbg() should be used in interrupt handlers. * example, only [a-z]llinfo() should be used in interrupt handlers.
* *
* [a-z]llinfo() -- Identical to [a-z]lldbg() except that it also requires that * [a-z]llwarn() -- Identical to [a-z]llinfo() except that it also requires that
* CONFIG_DEBUG_INFO be defined. This is intended for general debug * CONFIG_DEBUG_WARN be defined. This is intended for important exception
* output that you would normally want to suppress. * conditions that are potential errors (or perhaps real errors with non-
* fatal consequences).
*
* [a-z]lldbg() -- Identical to [a-z]llinfo() except that it also requires that
* CONFIG_DEBUG be defined. This is intended for important error-related
* information that you probably not want to suppress during normal debug
* general debugging.
*/ */
#ifdef CONFIG_HAVE_FUNCTIONNAME #ifdef CONFIG_HAVE_FUNCTIONNAME
# define EXTRA_FMT "%s: " # define EXTRA_FMT "%s: "
# define EXTRA_ARG ,__FUNCTION__ # define EXTRA_ARG ,__FUNCTION__
#else #else
# define EXTRA_FMT # define EXTRA_FMT
# define EXTRA_ARG # define EXTRA_ARG
#endif #endif
/* The actual logger function may be overridden in arch/debug.h if needed. */ /* The actual logger function may be overridden in arch/debug.h if needed. */
#ifndef __arch_syslog #ifndef __arch_syslog
# define __arch_syslog syslog # define __arch_syslog syslog
#endif #endif
#ifndef __arch_lowsyslog #ifndef __arch_lowsyslog
# define __arch_lowsyslog lowsyslog # define __arch_lowsyslog lowsyslog
#endif #endif
/* Debug macros will differ depending upon if the toolchain supports /* Debug macros will differ depending upon if the toolchain supports
@ -116,8 +133,8 @@
/* C-99 style variadic macros are supported */ /* C-99 style variadic macros are supported */
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
# define dbg(format, ...) \ # define dbg(format, ...) \
__arch_syslog(LOG_ERR, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) __arch_syslog(LOG_ERR, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
# ifdef CONFIG_ARCH_LOWPUTC # ifdef CONFIG_ARCH_LOWPUTC
# define lldbg(format, ...) \ # define lldbg(format, ...) \
@ -125,8 +142,28 @@
# else # else
# define lldbg(x...) # define lldbg(x...)
# endif # endif
#else /* CONFIG_DEBUG */
# ifdef CONFIG_DEBUG_INFO # define dbg(x...)
# define lldbg(x...)
#endif
#ifdef CONFIG_DEBUG_WARN
# define warn(format, ...) \
__arch_syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
# ifdef CONFIG_ARCH_LOWPUTC
# define llwarn(format, ...) \
__arch_lowsyslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
# else
# define llwarn(x...)
# endif
#else /* CONFIG_DEBUG_INFO */
# define warn(x...)
# define llwarn(x...)
#endif /* CONFIG_DEBUG_INFO */
#ifdef CONFIG_DEBUG_INFO
# define info(format, ...) \ # define info(format, ...) \
__arch_syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) __arch_syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
@ -136,201 +173,251 @@
# else # else
# define llinfo(x...) # define llinfo(x...)
# endif # endif
#else /* CONFIG_DEBUG_INFO */
# else /* CONFIG_DEBUG_INFO */
# define info(x...) # define info(x...)
# define llinfo(x...) # define llinfo(x...)
# endif /* CONFIG_DEBUG_INFO */ #endif /* CONFIG_DEBUG_INFO */
#else /* CONFIG_DEBUG */
# define dbg(x...)
# define lldbg(x...)
# define info(x...)
# define llinfo(x...)
#endif /* CONFIG_DEBUG */
/* Subsystem specific debug */ /* Subsystem specific debug */
#ifdef CONFIG_DEBUG_MM #ifdef CONFIG_DEBUG_MM
# define mdbg(format, ...) dbg(format, ##__VA_ARGS__) # define mdbg(format, ...) dbg(format, ##__VA_ARGS__)
# define mlldbg(format, ...) lldbg(format, ##__VA_ARGS__) # define mlldbg(format, ...) lldbg(format, ##__VA_ARGS__)
# define minfo(format, ...) info(format, ##__VA_ARGS__) # define mwarn(format, ...) warn(format, ##__VA_ARGS__)
# define mllinfo(format, ...) llinfo(format, ##__VA_ARGS__) # define mllwarn(format, ...) llwarn(format, ##__VA_ARGS__)
# define minfo(format, ...) info(format, ##__VA_ARGS__)
# define mllinfo(format, ...) llinfo(format, ##__VA_ARGS__)
#else #else
# define mdbg(x...) # define mdbg(x...)
# define mlldbg(x...) # define mlldbg(x...)
# define minfo(x...) # define mwarn(x...)
# define mllinfo(x...) # define mllwarn(x...)
# define minfo(x...)
# define mllinfo(x...)
#endif #endif
#ifdef CONFIG_DEBUG_SCHED #ifdef CONFIG_DEBUG_SCHED
# define sdbg(format, ...) dbg(format, ##__VA_ARGS__) # define sdbg(format, ...) dbg(format, ##__VA_ARGS__)
# define slldbg(format, ...) lldbg(format, ##__VA_ARGS__) # define slldbg(format, ...) lldbg(format, ##__VA_ARGS__)
# define sinfo(format, ...) info(format, ##__VA_ARGS__) # define swarn(format, ...) warn(format, ##__VA_ARGS__)
# define sllinfo(format, ...) llinfo(format, ##__VA_ARGS__) # define sllwarn(format, ...) llwarn(format, ##__VA_ARGS__)
# define sinfo(format, ...) info(format, ##__VA_ARGS__)
# define sllinfo(format, ...) llinfo(format, ##__VA_ARGS__)
#else #else
# define sdbg(x...) # define sdbg(x...)
# define slldbg(x...) # define slldbg(x...)
# define sinfo(x...) # define swarn(x...)
# define sllinfo(x...) # define sllwarn(x...)
# define sinfo(x...)
# define sllinfo(x...)
#endif #endif
#ifdef CONFIG_DEBUG_PAGING #ifdef CONFIG_DEBUG_PAGING
# define pgdbg(format, ...) dbg(format, ##__VA_ARGS__) # define pgdbg(format, ...) dbg(format, ##__VA_ARGS__)
# define pglldbg(format, ...) lldbg(format, ##__VA_ARGS__) # define pglldbg(format, ...) lldbg(format, ##__VA_ARGS__)
# define pginfo(format, ...) info(format, ##__VA_ARGS__) # define pgwarn(format, ...) warn(format, ##__VA_ARGS__)
# define pgllinfo(format, ...) llinfo(format, ##__VA_ARGS__) # define pgllwarn(format, ...) llwarn(format, ##__VA_ARGS__)
# define pginfo(format, ...) info(format, ##__VA_ARGS__)
# define pgllinfo(format, ...) llinfo(format, ##__VA_ARGS__)
#else #else
# define pgdbg(x...) # define pgdbg(x...)
# define pglldbg(x...) # define pglldbg(x...)
# define pginfo(x...) # define pgwarn(x...)
# define pgllinfo(x...) # define pgllwarn(x...)
# define pginfo(x...)
# define pgllinfo(x...)
#endif #endif
#ifdef CONFIG_DEBUG_DMA #ifdef CONFIG_DEBUG_DMA
# define dmadbg(format, ...) dbg(format, ##__VA_ARGS__) # define dmadbg(format, ...) dbg(format, ##__VA_ARGS__)
# define dmalldbg(format, ...) lldbg(format, ##__VA_ARGS__) # define dmalldbg(format, ...) lldbg(format, ##__VA_ARGS__)
# define dmainfo(format, ...) info(format, ##__VA_ARGS__) # define dmawarn(format, ...) warn(format, ##__VA_ARGS__)
# define dmallinfo(format, ...) llinfo(format, ##__VA_ARGS__) # define dmallwarn(format, ...) llwarn(format, ##__VA_ARGS__)
# define dmainfo(format, ...) info(format, ##__VA_ARGS__)
# define dmallinfo(format, ...) llinfo(format, ##__VA_ARGS__)
#else #else
# define dmadbg(x...) # define dmadbg(x...)
# define dmalldbg(x...) # define dmalldbg(x...)
# define dmainfo(x...) # define dmawarn(x...)
# define dmallinfo(x...) # define dmallwarn(x...)
# define dmainfo(x...)
# define dmallinfo(x...)
#endif #endif
#ifdef CONFIG_DEBUG_NET #ifdef CONFIG_DEBUG_NET
# define ndbg(format, ...) dbg(format, ##__VA_ARGS__) # define ndbg(format, ...) dbg(format, ##__VA_ARGS__)
# define nlldbg(format, ...) lldbg(format, ##__VA_ARGS__) # define nlldbg(format, ...) lldbg(format, ##__VA_ARGS__)
# define ninfo(format, ...) info(format, ##__VA_ARGS__) # define nwarn(format, ...) warn(format, ##__VA_ARGS__)
# define nllinfo(format, ...) llinfo(format, ##__VA_ARGS__) # define nllwarn(format, ...) llwarn(format, ##__VA_ARGS__)
# define ninfo(format, ...) info(format, ##__VA_ARGS__)
# define nllinfo(format, ...) llinfo(format, ##__VA_ARGS__)
#else #else
# define ndbg(x...) # define ndbg(x...)
# define nlldbg(x...) # define nlldbg(x...)
# define ninfo(x...) # define nwarn(x...)
# define nllinfo(x...) # define nllwarn(x...)
# define ninfo(x...)
# define nllinfo(x...)
#endif #endif
#ifdef CONFIG_DEBUG_USB #ifdef CONFIG_DEBUG_USB
# define udbg(format, ...) dbg(format, ##__VA_ARGS__) # define udbg(format, ...) dbg(format, ##__VA_ARGS__)
# define ulldbg(format, ...) lldbg(format, ##__VA_ARGS__) # define ulldbg(format, ...) lldbg(format, ##__VA_ARGS__)
# define uinfo(format, ...) info(format, ##__VA_ARGS__) # define uwarn(format, ...) warn(format, ##__VA_ARGS__)
# define ullinfo(format, ...) llinfo(format, ##__VA_ARGS__) # define ullwarn(format, ...) llwarn(format, ##__VA_ARGS__)
# define uinfo(format, ...) info(format, ##__VA_ARGS__)
# define ullinfo(format, ...) llinfo(format, ##__VA_ARGS__)
#else #else
# define udbg(x...) # define udbg(x...)
# define ulldbg(x...) # define ulldbg(x...)
# define uinfo(x...) # define uwarn(x...)
# define ullinfo(x...) # define ullwarn(x...)
# define uinfo(x...)
# define ullinfo(x...)
#endif #endif
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
# define fdbg(format, ...) dbg(format, ##__VA_ARGS__) # define fdbg(format, ...) dbg(format, ##__VA_ARGS__)
# define flldbg(format, ...) lldbg(format, ##__VA_ARGS__) # define flldbg(format, ...) lldbg(format, ##__VA_ARGS__)
# define finfo(format, ...) info(format, ##__VA_ARGS__) # define fwarn(format, ...) warn(format, ##__VA_ARGS__)
# define fllinfo(format, ...) llinfo(format, ##__VA_ARGS__) # define fllwarn(format, ...) llwarn(format, ##__VA_ARGS__)
# define finfo(format, ...) info(format, ##__VA_ARGS__)
# define fllinfo(format, ...) llinfo(format, ##__VA_ARGS__)
#else #else
# define fdbg(x...) # define fdbg(x...)
# define flldbg(x...) # define flldbg(x...)
# define finfo(x...) # define fwarn(x...)
# define fllinfo(x...) # define fllwarn(x...)
# define finfo(x...)
# define fllinfo(x...)
#endif #endif
#ifdef CONFIG_DEBUG_CRYPTO #ifdef CONFIG_DEBUG_CRYPTO
# define cryptdbg(format, ...) dbg(format, ##__VA_ARGS__) # define cryptdbg(format, ...) dbg(format, ##__VA_ARGS__)
# define cryptlldbg(format, ...) lldbg(format, ##__VA_ARGS__) # define cryptlldbg(format, ...) lldbg(format, ##__VA_ARGS__)
# define cryptinfo(format, ...) info(format, ##__VA_ARGS__) # define cryptwarn(format, ...) warn(format, ##__VA_ARGS__)
# define cryptllinfo(format, ...) llinfo(format, ##__VA_ARGS__) # define cryptllwarn(format, ...) llwarn(format, ##__VA_ARGS__)
# define cryptinfo(format, ...) info(format, ##__VA_ARGS__)
# define cryptllinfo(format, ...) llinfo(format, ##__VA_ARGS__)
#else #else
# define cryptdbg(x...) # define cryptdbg(x...)
# define cryptlldbg(x...) # define cryptlldbg(x...)
# define cryptinfo(x...) # define cryptwarn(x...)
# define cryptllinfo(x...) # define cryptllwarn(x...)
# define cryptinfo(x...)
# define cryptllinfo(x...)
#endif #endif
#ifdef CONFIG_DEBUG_INPUT #ifdef CONFIG_DEBUG_INPUT
# define idbg(format, ...) dbg(format, ##__VA_ARGS__) # define idbg(format, ...) dbg(format, ##__VA_ARGS__)
# define illdbg(format, ...) lldbg(format, ##__VA_ARGS__) # define illdbg(format, ...) lldbg(format, ##__VA_ARGS__)
# define iinfo(format, ...) info(format, ##__VA_ARGS__) # define iwarn(format, ...) warn(format, ##__VA_ARGS__)
# define illinfo(format, ...) llinfo(format, ##__VA_ARGS__) # define illwarn(format, ...) llwarn(format, ##__VA_ARGS__)
# define iinfo(format, ...) info(format, ##__VA_ARGS__)
# define illinfo(format, ...) llinfo(format, ##__VA_ARGS__)
#else #else
# define idbg(x...) # define idbg(x...)
# define illdbg(x...) # define illdbg(x...)
# define iinfo(x...) # define iwarn(x...)
# define illinfo(x...) # define illwarn(x...)
# define iinfo(x...)
# define illinfo(x...)
#endif #endif
#ifdef CONFIG_DEBUG_SENSORS #ifdef CONFIG_DEBUG_SENSORS
# define sndbg(format, ...) dbg(format, ##__VA_ARGS__) # define sndbg(format, ...) dbg(format, ##__VA_ARGS__)
# define snlldbg(format, ...) lldbg(format, ##__VA_ARGS__) # define snlldbg(format, ...) lldbg(format, ##__VA_ARGS__)
# define sninfo(format, ...) info(format, ##__VA_ARGS__) # define snwarn(format, ...) warn(format, ##__VA_ARGS__)
# define snllinfo(format, ...) llinfo(format, ##__VA_ARGS__) # define snllwarn(format, ...) llwarn(format, ##__VA_ARGS__)
# define sninfo(format, ...) info(format, ##__VA_ARGS__)
# define snllinfo(format, ...) llinfo(format, ##__VA_ARGS__)
#else #else
# define sndbg(x...) # define sndbg(x...)
# define snlldbg(x...) # define snlldbg(x...)
# define sninfo(x...) # define snwarn(x...)
# define snllinfo(x...) # define snllwarn(x...)
# define sninfo(x...)
# define snllinfo(x...)
#endif #endif
#ifdef CONFIG_DEBUG_ANALOG #ifdef CONFIG_DEBUG_ANALOG
# define adbg(format, ...) dbg(format, ##__VA_ARGS__) # define adbg(format, ...) dbg(format, ##__VA_ARGS__)
# define alldbg(format, ...) lldbg(format, ##__VA_ARGS__) # define alldbg(format, ...) lldbg(format, ##__VA_ARGS__)
# define ainfo(format, ...) info(format, ##__VA_ARGS__) # define awarn(format, ...) warn(format, ##__VA_ARGS__)
# define allinfo(format, ...) llinfo(format, ##__VA_ARGS__) # define allwarn(format, ...) llwarn(format, ##__VA_ARGS__)
# define ainfo(format, ...) info(format, ##__VA_ARGS__)
# define allinfo(format, ...) llinfo(format, ##__VA_ARGS__)
#else #else
# define adbg(x...) # define adbg(x...)
# define alldbg(x...) # define alldbg(x...)
# define ainfo(x...) # define awarn(x...)
# define allinfo(x...) # define allwarn(x...)
# define ainfo(x...)
# define allinfo(x...)
#endif #endif
#ifdef CONFIG_DEBUG_GRAPHICS #ifdef CONFIG_DEBUG_GRAPHICS
# define gdbg(format, ...) dbg(format, ##__VA_ARGS__) # define gdbg(format, ...) dbg(format, ##__VA_ARGS__)
# define glldbg(format, ...) lldbg(format, ##__VA_ARGS__) # define glldbg(format, ...) lldbg(format, ##__VA_ARGS__)
# define ginfo(format, ...) info(format, ##__VA_ARGS__) # define gwarn(format, ...) warn(format, ##__VA_ARGS__)
# define gllinfo(format, ...) llinfo(format, ##__VA_ARGS__) # define gllwarn(format, ...) llwarn(format, ##__VA_ARGS__)
# define ginfo(format, ...) info(format, ##__VA_ARGS__)
# define gllinfo(format, ...) llinfo(format, ##__VA_ARGS__)
#else #else
# define gdbg(x...) # define gdbg(x...)
# define glldbg(x...) # define glldbg(x...)
# define ginfo(x...) # define gwarn(x...)
# define gllinfo(x...) # define gllwarn(x...)
# define ginfo(x...)
# define gllinfo(x...)
#endif #endif
#ifdef CONFIG_DEBUG_BINFMT #ifdef CONFIG_DEBUG_BINFMT
# define bdbg(format, ...) dbg(format, ##__VA_ARGS__) # define bdbg(format, ...) dbg(format, ##__VA_ARGS__)
# define blldbg(format, ...) lldbg(format, ##__VA_ARGS__) # define blldbg(format, ...) lldbg(format, ##__VA_ARGS__)
# define binfo(format, ...) info(format, ##__VA_ARGS__) # define bwarn(format, ...) warn(format, ##__VA_ARGS__)
# define bllinfo(format, ...) llinfo(format, ##__VA_ARGS__) # define bllwarn(format, ...) llwarn(format, ##__VA_ARGS__)
# define binfo(format, ...) info(format, ##__VA_ARGS__)
# define bllinfo(format, ...) llinfo(format, ##__VA_ARGS__)
#else #else
# define bdbg(x...) # define bdbg(x...)
# define blldbg(x...) # define blldbg(x...)
# define binfo(x...) # define bwarn(x...)
# define bllinfo(x...) # define bllwarn(x...)
# define binfo(x...)
# define bllinfo(x...)
#endif #endif
#ifdef CONFIG_DEBUG_LIB #ifdef CONFIG_DEBUG_LIB
# define ldbg(format, ...) dbg(format, ##__VA_ARGS__) # define ldbg(format, ...) dbg(format, ##__VA_ARGS__)
# define llldbg(format, ...) lldbg(format, ##__VA_ARGS__) # define llldbg(format, ...) lldbg(format, ##__VA_ARGS__)
# define linfo(format, ...) info(format, ##__VA_ARGS__) # define lwarn(format, ...) warn(format, ##__VA_ARGS__)
# define lllinfo(format, ...) llinfo(format, ##__VA_ARGS__) # define lllwarn(format, ...) llwarn(format, ##__VA_ARGS__)
# define linfo(format, ...) info(format, ##__VA_ARGS__)
# define lllinfo(format, ...) llinfo(format, ##__VA_ARGS__)
#else #else
# define ldbg(x...) # define ldbg(x...)
# define llldbg(x...) # define llldbg(x...)
# define linfo(x...) # define lwarn(x...)
# define lllinfo(x...) # define lllwarn(x...)
# define linfo(x...)
# define lllinfo(x...)
#endif #endif
#ifdef CONFIG_DEBUG_AUDIO #ifdef CONFIG_DEBUG_AUDIO
# define auddbg(format, ...) dbg(format, ##__VA_ARGS__) # define auddbg(format, ...) dbg(format, ##__VA_ARGS__)
# define audlldbg(format, ...) lldbg(format, ##__VA_ARGS__) # define audlldbg(format, ...) lldbg(format, ##__VA_ARGS__)
# define audinfo(format, ...) info(format, ##__VA_ARGS__) # define audwarn(format, ...) warn(format, ##__VA_ARGS__)
# define audllinfo(format, ...) llinfo(format, ##__VA_ARGS__) # define audllwarn(format, ...) llwarn(format, ##__VA_ARGS__)
# define audinfo(format, ...) info(format, ##__VA_ARGS__)
# define audllinfo(format, ...) llinfo(format, ##__VA_ARGS__)
#else #else
# define auddbg(x...) # define auddbg(x...)
# define audlldbg(x...) # define audlldbg(x...)
# define audinfo(x...) # define audwarn(x...)
# define audllinfo(x...) # define audllwarn(x...)
# define audinfo(x...)
# define audllinfo(x...)
#endif #endif
#else /* CONFIG_CPP_HAVE_VARARGS */ #else /* CONFIG_CPP_HAVE_VARARGS */
@ -338,204 +425,272 @@
/* Variadic macros NOT supported */ /* Variadic macros NOT supported */
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
# ifndef CONFIG_ARCH_LOWPUTC
# define lldbg (void)
# endif
# ifndef CONFIG_DEBUG_INFO
# define info (void)
# define llinfo (void)
# else
# ifndef CONFIG_ARCH_LOWPUTC # ifndef CONFIG_ARCH_LOWPUTC
# define llinfo (void) # define lldbg (void)
# endif # endif
# endif
#else #else
# define dbg (void) # define dbg (void)
# define lldbg (void) # define lldbg (void)
# define info (void) #endif
# define llinfo (void)
#ifdef CONFIG_DEBUG_WARN
# ifndef CONFIG_ARCH_LOWPUTC
# define llwarn (void)
# endif
#else
# define warn (void)
# define llwarn (void)
#endif
#ifdef CONFIG_DEBUG_INFO
# ifndef CONFIG_ARCH_LOWPUTC
# define llinfo (void)
# endif
#else
# define info (void)
# define llinfo (void)
#endif #endif
/* Subsystem specific debug */ /* Subsystem specific debug */
#ifdef CONFIG_DEBUG_MM #ifdef CONFIG_DEBUG_MM
# define mdbg dbg # define mdbg dbg
# define mlldbg lldbg # define mlldbg lldbg
# define minfo info # define mwarn warn
# define mllinfo llinfo # define mllwarn llwarn
# define minfo info
# define mllinfo llinfo
#else #else
# define mdbg (void) # define mdbg (void)
# define mlldbg (void) # define mlldbg (void)
# define minfo (void) # define mwarn (void)
# define mllinfo (void) # define mllwarn (void)
# define minfo (void)
# define mllinfo (void)
#endif #endif
#ifdef CONFIG_DEBUG_SCHED #ifdef CONFIG_DEBUG_SCHED
# define sdbg dbg # define sdbg dbg
# define slldbg lldbg # define slldbg lldbg
# define sinfo info # define swarn warn
# define sllinfo llinfo # define sllwarn llwarn
# define sinfo info
# define sllinfo llinfo
#else #else
# define sdbg (void) # define sdbg (void)
# define slldbg (void) # define slldbg (void)
# define sinfo (void) # define swarn (void)
# define sllinfo (void) # define sllwarn (void)
# define sinfo (void)
# define sllinfo (void)
#endif #endif
#ifdef CONFIG_DEBUG_PAGING #ifdef CONFIG_DEBUG_PAGING
# define pgdbg dbg # define pgdbg dbg
# define pglldbg lldbg # define pglldbg lldbg
# define pginfo info # define pgwarn warn
# define pgllinfo llinfo # define pgllwarn llwarn
# define pginfo info
# define pgllinfo llinfo
#else #else
# define pgdbg (void) # define pgdbg (void)
# define pglldbg (void) # define pglldbg (void)
# define pginfo (void) # define pgwarn (void)
# define pgllinfo (void) # define pgllwarn (void)
# define pginfo (void)
# define pgllinfo (void)
#endif #endif
#ifdef CONFIG_DEBUG_DMA #ifdef CONFIG_DEBUG_DMA
# define dmadbg dbg # define dmadbg dbg
# define dmalldbg lldbg # define dmalldbg lldbg
# define dmainfo info # define dmawarn warn
# define dmallinfo llinfo # define dmallwarn llwarn
# define dmainfo info
# define dmallinfo llinfo
#else #else
# define dmadbg (void) # define dmadbg (void)
# define dmalldbg (void) # define dmalldbg (void)
# define dmainfo (void) # define dmawarn (void)
# define dmallinfo (void) # define dmallwarn (void)
# define dmainfo (void)
# define dmallinfo (void)
#endif #endif
#ifdef CONFIG_DEBUG_NET #ifdef CONFIG_DEBUG_NET
# define ndbg dbg # define ndbg dbg
# define nlldbg lldbg # define nlldbg lldbg
# define ninfo info # define nwarn warn
# define nllinfo llinfo # define nllwarn llwarn
# define ninfo info
# define nllinfo llinfo
#else #else
# define ndbg (void) # define ndbg (void)
# define nlldbg (void) # define nlldbg (void)
# define ninfo (void) # define nwarn (void)
# define nllinfo (void) # define nllwarn (void)
# define ninfo (void)
# define nllinfo (void)
#endif #endif
#ifdef CONFIG_DEBUG_USB #ifdef CONFIG_DEBUG_USB
# define udbg dbg # define udbg dbg
# define ulldbg lldbg # define ulldbg lldbg
# define uinfo info # define uwarn warn
# define ullinfo llinfo # define ullwarn llwarn
# define uinfo info
# define ullinfo llinfo
#else #else
# define udbg (void) # define udbg (void)
# define ulldbg (void) # define ulldbg (void)
# define uinfo (void) # define uwarn (void)
# define ullinfo (void) # define ullwarn (void)
# define uinfo (void)
# define ullinfo (void)
#endif #endif
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
# define fdbg dbg # define fdbg dbg
# define flldbg lldbg # define flldbg lldbg
# define finfo info # define fwarn warn
# define fllinfo llinfo # define fllwarn llwarn
# define finfo info
# define fllinfo llinfo
#else #else
# define fdbg (void) # define fdbg (void)
# define flldbg (void) # define flldbg (void)
# define finfo (void) # define fwarn (void)
# define fllinfo (void) # define fllwarn (void)
# define finfo (void)
# define fllinfo (void)
#endif #endif
#ifdef CONFIG_DEBUG_CRYPTO #ifdef CONFIG_DEBUG_CRYPTO
# define cryptdbg dbg # define cryptdbg dbg
# define cryptlldbg lldbg # define cryptlldbg lldbg
# define cryptinfo info # define cryptwarn warn
# define cryptllinfo llinfo # define cryptllwarn llwarn
# define cryptinfo info
# define cryptllinfo llinfo
#else #else
# define cryptdbg (void) # define cryptdbg (void)
# define cryptlldbg (void) # define cryptlldbg (void)
# define cryptinfo (void) # define cryptwarn (void)
# define cryptllinfo (void) # define cryptllwarn (void)
# define cryptinfo (void)
# define cryptllinfo (void)
#endif #endif
#ifdef CONFIG_DEBUG_INPUT #ifdef CONFIG_DEBUG_INPUT
# define idbg dbg # define idbg dbg
# define illdbg lldbg # define illdbg lldbg
# define iinfo info # define iwarn warn
# define illinfo llinfo # define illwarn llwarn
# define iinfo info
# define illinfo llinfo
#else #else
# define idbg (void) # define idbg (void)
# define illdbg (void) # define illdbg (void)
# define iinfo (void) # define iwarn (void)
# define illinfo (void) # define illwarn (void)
# define iinfo (void)
# define illinfo (void)
#endif #endif
#ifdef CONFIG_DEBUG_SENSORS #ifdef CONFIG_DEBUG_SENSORS
# define sndbg dbg # define sndbg dbg
# define snlldbg lldbg # define snlldbg lldbg
# define sninfo info # define snwarn warn
# define snllinfo llinfo # define snllwarn llwarn
# define sninfo info
# define snllinfo llinfo
#else #else
# define sndbg (void) # define sndbg (void)
# define snlldbg (void) # define snlldbg (void)
# define sninfo (void) # define snwarn (void)
# define snllinfo (void) # define snllwarn (void)
# define sninfo (void)
# define snllinfo (void)
#endif #endif
#ifdef CONFIG_DEBUG_ANALOG #ifdef CONFIG_DEBUG_ANALOG
# define adbg dbg # define adbg dbg
# define alldbg lldbg # define alldbg lldbg
# define ainfo info # define awarn warn
# define allinfo llinfo # define allwarn llwarn
# define ainfo info
# define allinfo llinfo
#else #else
# define adbg (void) # define adbg (void)
# define alldbg (void) # define alldbg (void)
# define ainfo (void) # define awarn (void)
# define allinfo (void) # define allwarn (void)
# define ainfo (void)
# define allinfo (void)
#endif #endif
#ifdef CONFIG_DEBUG_GRAPHICS #ifdef CONFIG_DEBUG_GRAPHICS
# define gdbg dbg # define gdbg dbg
# define glldbg lldbg # define glldbg lldbg
# define ginfo info # define gwarn warn
# define gllinfo llinfo # define gllwarn llwarn
# define ginfo info
# define gllinfo llinfo
#else #else
# define gdbg (void) # define gdbg (void)
# define glldbg (void) # define glldbg (void)
# define ginfo (void) # define gwarn (void)
# define gllinfo (void) # define gllwarn (void)
# define ginfo (void)
# define gllinfo (void)
#endif #endif
#ifdef CONFIG_DEBUG_BINFMT #ifdef CONFIG_DEBUG_BINFMT
# define bdbg dbg # define bdbg dbg
# define blldbg lldbg # define blldbg lldbg
# define binfo info # define bwarn warn
# define bllinfo llinfo # define bllwarn llwarn
# define binfo info
# define bllinfo llinfo
#else #else
# define bdbg (void) # define bdbg (void)
# define blldbg (void) # define blldbg (void)
# define binfo (void) # define bwarn (void)
# define bllinfo (void) # define bllwarn (void)
# define binfo (void)
# define bllinfo (void)
#endif #endif
#ifdef CONFIG_DEBUG_LIB #ifdef CONFIG_DEBUG_LIB
# define ldbg dbg # define ldbg dbg
# define llldbg lldbg # define llldbg lldbg
# define linfo info # define lwarn warn
# define lllinfo llinfo # define lllwarn llwarn
# define linfo info
# define lllinfo llinfo
#else #else
# define ldbg (void) # define ldbg (void)
# define llldbg (void) # define llldbg (void)
# define linfo (void) # define lwarn (void)
# define lllinfo (void) # define lllwarn (void)
# define linfo (void)
# define lllinfo (void)
#endif #endif
#ifdef CONFIG_DEBUG_AUDIO #ifdef CONFIG_DEBUG_AUDIO
# define auddbg dbg # define auddbg dbg
# define audlldbg lldbg # define audlldbg lldbg
# define audinfo info # define audwarn warn
# define audllinfo llinfo # define audllwarn llwarn
# define audinfo info
# define audllinfo llinfo
#else #else
# define auddbg (void) # define auddbg (void)
# define audlldbg (void) # define audlldbg (void)
# define audinfo (void) # define audwarn (void)
# define audllinfo (void) # define audllwarn (void)
# define audinfo (void)
# define audllinfo (void)
#endif #endif
#endif /* CONFIG_CPP_HAVE_VARARGS */ #endif /* CONFIG_CPP_HAVE_VARARGS */
@ -690,15 +845,23 @@ int dbg(const char *format, ...);
# ifdef CONFIG_ARCH_LOWPUTC # ifdef CONFIG_ARCH_LOWPUTC
int lldbg(const char *format, ...); int lldbg(const char *format, ...);
# endif # endif
#endif /* CONFIG_DEBUG */
# ifdef CONFIG_DEBUG_INFO #ifdef CONFIG_DEBUG_WARN
int warn(const char *format, ...);
# ifdef CONFIG_ARCH_LOWPUTC
int llwarn(const char *format, ...);
# endif
#endif /* CONFIG_DEBUG_WARN */
#ifdef CONFIG_DEBUG_INFO
int info(const char *format, ...); int info(const char *format, ...);
# ifdef CONFIG_ARCH_LOWPUTC # ifdef CONFIG_ARCH_LOWPUTC
int llinfo(const char *format, ...); int llinfo(const char *format, ...);
# endif # endif
#endif #endif /* CONFIG_DEBUG_INFO */
#endif /* CONFIG_DEBUG */
#endif /* CONFIG_CPP_HAVE_VARARGS */ #endif /* CONFIG_CPP_HAVE_VARARGS */
#if defined(__cplusplus) #if defined(__cplusplus)

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* libc/misc/lib_dbg.c * libc/misc/lib_dbg.c
* *
* Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 2011-2012, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -46,10 +46,6 @@
#ifndef CONFIG_CPP_HAVE_VARARGS #ifndef CONFIG_CPP_HAVE_VARARGS
/****************************************************************************
* Public Data
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@ -82,13 +78,42 @@ int lldbg(const char *format, ...)
va_list ap; va_list ap;
int ret; int ret;
va_start(ap, format);
ret = lowvsyslog(LOG_ERR, format, ap);
va_end(ap);
return ret;
}
#endif /* CONFIG_ARCH_LOWPUTC */
#endif /* CONFIG_DEBUG */
#ifdef CONFIG_DEBUG_WARN
int warn(const char *format, ...)
{
va_list ap;
int ret;
va_start(ap, format);
ret = vsyslog(LOG_WARNING, format, ap);
va_end(ap);
return ret;
}
#ifdef CONFIG_ARCH_LOWPUTC
int llwarn(const char *format, ...)
{
va_list ap;
int ret;
va_start(ap, format); va_start(ap, format);
ret = lowvsyslog(LOG_DEBUG, format, ap); ret = lowvsyslog(LOG_DEBUG, format, ap);
va_end(ap); va_end(ap);
return ret; return ret;
} }
#endif #endif /* CONFIG_ARCH_LOWPUTC */
#endif /* CONFIG_DEBUG_INFO */
#ifdef CONFIG_DEBUG_INFO #ifdef CONFIG_DEBUG_INFO
int info(const char *format, ...) int info(const char *format, ...)
@ -117,5 +142,5 @@ int llinfo(const char *format, ...)
} }
#endif /* CONFIG_ARCH_LOWPUTC */ #endif /* CONFIG_ARCH_LOWPUTC */
#endif /* CONFIG_DEBUG_INFO */ #endif /* CONFIG_DEBUG_INFO */
#endif /* CONFIG_DEBUG */
#endif /* CONFIG_CPP_HAVE_VARARGS */ #endif /* CONFIG_CPP_HAVE_VARARGS */