No, way too complicated. I want to keep it simple so people will
actually use it.
Moshe
On Wed, 20 Nov 2002, Muli Ben-Yehuda wrote:
> On Wed, Nov 20, 2002 at 12:30:05AM +0200, Moshe Bar wrote:
>
> > We will work with structures like this in the kernel code
> > whenever possible:
> >
> > #ifdef CONFIG_oM_LOGGING
> > printk ("Received a process from remote node with %d pages
> > \n", m->pages_i_bring);
> > #endif /* CONFIG_oM_LOGGING */
>
> Yeech.
>
> Please consider using something like this:
>
> in a header file:
>
> #ifdef SCT_MODULE_DEBUG
>
> #define SCTDBG(level, msg, args...) do { \
> if ((debug_level & level)) \
> printk(KERN_DEBUG "[%s] " msg , __FUNCTION__ , ##args ); \
> } while (0)
>
> #else /* !defined(SCT_MODULE_DEBUG) */
>
> #define SCTDBG(level, msg, args...) do { } while (0)
>
> #endif /* SCT_MODULE_DEBUG */
>
> and in the source files, you use
>
> SCTDBG(DBG_FOO, "%s - %d", some_message, some_int), which is far
> cleaner (no ifdefs anywhere except for one header file) *and* will be
> optimized out if SCT_MODULE_DEBUG is not defined.
>
> As for debug_level and level, you keep a bitmask of which areas you
> want debug (or log, same concept) messages for, and only messages
> which are relevant get printed. For example, if you have
>
> #define LOG_FOO 0x1
> #define LOG_BAR 0x2
>
> and your 'debug_level' is 0x1, this message will get printed
>
> SCTDBG(LOG_FOO, "gargargar");
>
> but this won't be
>
> SCTDBG(LOG_BAR, "fofofofof");
>
> Adding a /proc file to control in run time which areas should be
> logged and which shouldn't is trivial, and I'll be happy to send a
> patch if you want it.
>
> > This should be applied whenever an important event happened either
> > successfully or when an error will lead to the user noticing it. Also we
> > should from time to time print some log information about the health of
> > the node and the load balancing status.
>
> This is exactly what the old MOSIX debug and diags code which you
> removed did.
>
--
|