On Fri, Oct 17, 2025 at 01:04:36PM +0200, Jonas Rebmann wrote: > Previously, `dmesg -c` would clear the logbuffer except for the last 10 > lines. This comes with a fair amount of surprise given linux `dmesg -c` > clears the whole logbuffer. > > Clear the complete logbuffer given `dmesg -c` but with an optional > argument `dmesg -c [<num>]` to keep <num> lines. > > While at it, move the deleteion of log lines to the log_print function > to prevent a corner case of lost log message if they arrive between the > log_print() and log_clean() in dmesg. > > If loglevels are selected using -l or -p in addition to cleaning being > selected using -c, only clean those messages shown by the loglevel > selection.
I find this behaviour rather surprising. The only useful thing I could think of we can do with this is "Discard unimportant messages", but only by printing them. It would be more useful if we had a -C (uppercase) option to discard messages without printing them. But even with that, there are many things we can do with this behaviour that are not useful and only a few that are actually useful. We could delete for example all "info" messages and keep the more and less important messages, but why would we want to do this? I think you should rather use the filter options -l and -p to limit the output to the messages you are interested in and finally use -c to clear the buffer. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
