Re: [Announce] Linux-tiny project revival

Indan Zupancic
2007-09-27T16:36:44Z

On Thu, September 27, 2007 09:00, Arnd Bergmann wrote:
> Assuming that we want to go down that road, I think you can do better with
> more evil macro magic, by using something along the lines of
>
> #define KERN_NOTICE "<5>",
>
> #define PRINTK_CONTINUED "",
>
> #define printk(level, str, ...) \
> do { \
> if (sizeof(level) == 1) /* continued printk */\
> actual_printk(str, __VA_ARGS__); \
> else if ((level[1] - '0') < CONFIG_PRINTK_DOICARE) \
> actual_printk(level str, __VA_ARGS__); \
> } while(0);
>
> Then you don't have to change every single printk in the kernel, but
> only those that don't currently come with a log level. More importantly,
> you can do the conversion without a flag day, by spreading (an empty)
> PRINTK_CONTINUED in places that do need a printk without a log level.

The problem is, how do you know whether to print a continued printk or not?
It depends on the loglevel of the first printk.

So besides compile-time parsing of the source code, replacing printk with
loglevel specific alternatives (one way or the other) seems the only option.

Greetings,

Indan