Add interface to enabled/disable debug output

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4386 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo
2012-02-12 23:54:26 +00:00
parent 686d0f0daa
commit acf1031af3
15 changed files with 149 additions and 50 deletions
+66 -13
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* lib/misc/lib_dbg.c
*
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -44,10 +44,35 @@
#include "lib_internal.h"
/****************************************************************************
* Global Variables
****************************************************************************/
/* Debug output is initially disabled */
#ifdef CONFIG_DEBUG_ENABLE
bool g_dbgenable;
#endif
/****************************************************************************
* Global Functions
****************************************************************************/
/****************************************************************************
* Name: dbg_enable
*
* Description:
* Enable or disable debug output.
*
****************************************************************************/
#ifdef CONFIG_DEBUG_ENABLE
void dbg_enable(bool enable)
{
g_dbgenable = enable;
}
#endif
/****************************************************************************
* Name: dbg, lldbg, vdbg
*
@@ -64,9 +89,16 @@ int dbg(const char *format, ...)
va_list ap;
int ret;
va_start(ap, format);
ret = lib_rawvprintf(format, ap);
va_end(ap);
#ifdef CONFIG_DEBUG_ENABLE
ret = 0;
if (g_dbgenable)
#endif
{
va_start(ap, format);
ret = lib_rawvprintf(format, ap);
va_end(ap);
}
return ret;
}
@@ -76,9 +108,16 @@ int lldbg(const char *format, ...)
va_list ap;
int ret;
va_start(ap, format);
ret = lib_lowvprintf(format, ap);
va_end(ap);
#ifdef CONFIG_DEBUG_ENABLE
ret = 0;
if (g_dbgenable)
#endif
{
va_start(ap, format);
ret = lib_lowvprintf(format, ap);
va_end(ap);
}
return ret;
}
#endif
@@ -89,9 +128,16 @@ int vdbg(const char *format, ...)
va_list ap;
int ret;
va_start(ap, format);
ret = lib_rawvprintf(format, ap);
va_end(ap);
#ifdef CONFIG_DEBUG_ENABLE
ret = 0;
if (g_dbgenable)
#endif
{
va_start(ap, format);
ret = lib_rawvprintf(format, ap);
va_end(ap);
}
return ret;
}
@@ -101,9 +147,16 @@ int llvdbg(const char *format, ...)
va_list ap;
int ret;
va_start(ap, format);
ret = lib_lowvprintf(format, ap);
va_end(ap);
#ifdef CONFIG_DEBUG_ENABLE
ret = 0;
if (g_dbgenable)
#endif
{
va_start(ap, format);
ret = lib_lowvprintf(format, ap);
va_end(ap);
}
return ret;
}
#endif /* CONFIG_ARCH_LOWPUTC */