File tree Expand file tree Collapse file tree 3 files changed +7
-3
lines changed Expand file tree Collapse file tree 3 files changed +7
-3
lines changed Original file line number Diff line number Diff line change 1+ Added logger to ` InfrahubGenerator ` class to allow users use built-in logging (` self.logger ` ) to show logging within Infrahub CI pipeline.
Original file line number Diff line number Diff line change 99from ..ctl import config
1010from ..ctl .client import initialize_client
1111from ..ctl .repository import get_repository_config
12- from ..ctl .utils import execute_graphql_query , parse_cli_vars
12+ from ..ctl .utils import execute_graphql_query , init_logging , parse_cli_vars
1313from ..exceptions import ModuleImportError
1414from ..node import InfrahubNode
1515
2020async def run (
2121 generator_name : str ,
2222 path : str , # noqa: ARG001
23- debug : bool , # noqa: ARG001
23+ debug : bool ,
2424 list_available : bool ,
2525 branch : str | None = None ,
2626 variables : list [str ] | None = None ,
2727) -> None :
28+ init_logging (debug = debug )
2829 repository_config = get_repository_config (Path (config .INFRAHUB_REPO_CONFIG_FILE ))
2930
3031 if list_available or not generator_name :
@@ -34,7 +35,6 @@ async def run(
3435 generator_config = repository_config .get_generator_definition (name = generator_name )
3536
3637 console = Console ()
37-
3838 relative_path = str (generator_config .file_path .parent ) if generator_config .file_path .parent != Path () else None
3939
4040 try :
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ import logging
34import os
45from abc import abstractmethod
56from typing import TYPE_CHECKING
@@ -27,6 +28,7 @@ def __init__(
2728 generator_instance : str = "" ,
2829 params : dict | None = None ,
2930 convert_query_response : bool = False ,
31+ logger : logging .Logger | None = None ,
3032 ) -> None :
3133 self .query = query
3234 self .branch = branch
@@ -41,6 +43,7 @@ def __init__(
4143 self ._related_nodes : list [InfrahubNode ] = []
4244 self .infrahub_node = infrahub_node
4345 self .convert_query_response = convert_query_response
46+ self .logger = logger if logger else logging .getLogger ("infrahub.tasks" )
4447
4548 @property
4649 def store (self ) -> NodeStore :
You can’t perform that action at this time.
0 commit comments