diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-02-12 23:54:26 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-02-12 23:54:26 +0000 |
commit | c2079e368c183a100c549671925b66d6b993c8c2 (patch) | |
tree | 6e9e40c95947255b743c4a08926a407360d2a19c /nuttx/lib/misc/lib_dbg.c | |
parent | a8d12f6d37d46732011e008ac8252c4a3183e182 (diff) | |
download | px4-nuttx-c2079e368c183a100c549671925b66d6b993c8c2.tar.gz px4-nuttx-c2079e368c183a100c549671925b66d6b993c8c2.tar.bz2 px4-nuttx-c2079e368c183a100c549671925b66d6b993c8c2.zip |
Add interface to enabled/disable debug output
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4386 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/lib/misc/lib_dbg.c')
-rw-r--r-- | nuttx/lib/misc/lib_dbg.c | 79 |
1 files changed, 66 insertions, 13 deletions
diff --git a/nuttx/lib/misc/lib_dbg.c b/nuttx/lib/misc/lib_dbg.c index e4b1071cd..6f326bf4f 100644 --- a/nuttx/lib/misc/lib_dbg.c +++ b/nuttx/lib/misc/lib_dbg.c @@ -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 @@ -45,10 +45,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 * * Description: @@ -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 */ |