[PATCH v2 3/9] utils: gen-debug-controls: Improve log output

Isaac Scott isaac.scott at ideasonboard.com
Thu May 15 15:14:08 CEST 2025


Hi Stefan,

Quoting Stefan Klug (2025-04-11 13:36:31)
> 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>
> Acked-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> 

Reviewed-by: Isaac Scott <isaac.scott at ideasonboard.com>

> ---
> 
> Changes in v2:
> - Collected tag
> ---
>  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
> +    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