[PATCH 3/9] utils: gen-debug-controls: Improve log output
Kieran Bingham
kieran.bingham at ideasonboard.com
Mon Mar 31 18:36:29 CEST 2025
Quoting Stefan Klug (2025-03-31 15:43:42)
> Add log statements for found controls and the file written. This makes
> it easier to understand what happens under the hood.
>
> While at it, create nice colored log out put using coloredlogs if
> available.
>
> Signed-off-by: Stefan Klug <stefan.klug at ideasonboard.com>
> ---
> utils/gen-debug-controls.py | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/utils/gen-debug-controls.py b/utils/gen-debug-controls.py
> index ff22b986475e..a1c69bbd8294 100755
> --- a/utils/gen-debug-controls.py
> +++ b/utils/gen-debug-controls.py
> @@ -17,8 +17,13 @@ import sys
> from dataclasses import dataclass
> from pathlib import Path
>
> -logger = logging.getLogger(__name__)
> -logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s')
> +fmt = '%(levelname)s: %(message)s'
> +try:
> + import coloredlogs
I see this is optional, I guess we don't need to document it as
something to install as a developer dependency?
Anyway, as you're currently the main user and developer of this file ...
Acked-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> + coloredlogs.install(level=logging.INFO, fmt=fmt)
> +except ImportError:
> + logging.basicConfig(level=logging.INFO, format=fmt)
> +
>
> try:
> import ruamel.yaml as ruyaml
> @@ -27,6 +32,8 @@ except:
> f'Failed to import ruamel.yaml. Please install the ruamel.yaml package.')
> sys.exit(1)
>
> +logger = logging.getLogger(__name__)
> +
> @dataclass
> class FoundMatch:
> file: os.PathLike
> @@ -106,6 +113,7 @@ def main(argv):
> continue
>
> p = m.file.relative_to(root_dir)
> + logger.info(f"Found control {m.name} in {p}")
> desc = {'type': m.type,
> 'direction': 'out',
> 'description': f'Debug control {m.name} found in {p}'}
> @@ -165,6 +173,9 @@ def main(argv):
> "#\n"))
> yaml.dump(doc, f)
>
> + p = ctrl_file.relative_to(Path.cwd(), walk_up=True)
> + logger.info(f"Sucessfully updated {p}")
> +
> return 0
>
>
> --
> 2.43.0
>
More information about the libcamera-devel
mailing list