A trick to show Debug messages only in the current file

This trick can be used to avoid showing annoying debug message from all drivers and subsystems supported by NuttX:

#include <nuttx/config.h>

/* Trick to get DEBUG messages only in this file */
#define CONFIG_DEBUG 1
#define CONFIG_DEBUG_I2C 1

#include <debug.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <errno.h>

It is very important to put the “defines CONFIG_DEBUG*” only AFTER the include nuttx/config.h and BEFORE the include debug.h.

Thanks Greg Nutt for this nice tip!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s