scripts/kernel-doc.py: output warnings the same way as kerneldoc

Add a formatter to logging to produce outputs in a similar way
to kernel-doc. This should help making it more compatible with
existing scripts.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/559f0ad9e6fecfcbb3cc38b6097463bd38d58629.1744106241.git.mchehab+huawei@kernel.org
This commit is contained in:
Mauro Carvalho Chehab
2025-04-08 18:09:07 +08:00
committed by Jonathan Corbet
parent 094a484578
commit 0a4e24128f

View File

@@ -2715,6 +2715,11 @@ neither here nor at the original Perl script.
"""
class MsgFormatter(logging.Formatter):
def format(self, record):
record.levelname = record.levelname.capitalize()
return logging.Formatter.format(self, record)
def main():
"""Main program"""
@@ -2799,10 +2804,19 @@ def main():
args.wshort_desc = True
args.wcontents_before_sections = True
logger = logging.getLogger()
if not args.debug:
level = logging.INFO
logger.setLevel(logging.INFO)
else:
level = logging.DEBUG
logger.setLevel(logging.DEBUG)
formatter = MsgFormatter('%(levelname)s: %(message)s')
handler = logging.StreamHandler()
handler.setFormatter(formatter)
logger.addHandler(handler)
if args.man:
out_style = ManFormat()
@@ -2811,8 +2825,6 @@ def main():
else:
out_style = RestFormat()
logging.basicConfig(level=level, format="%(levelname)s: %(message)s")
kfiles = KernelFiles(files=args.files, verbose=args.verbose,
out_style=out_style, werror=args.werror,
wreturn=args.wreturn, wshort_desc=args.wshort_desc,