Skip to content

Commit 54209fc

Browse files
committed
Allow logging configuration for Project tools.
1 parent f206b3f commit 54209fc

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/makeapp/appmaker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def __init__(
8585
:param app_name: Application name
8686
:param templates_to_use: Templates names or paths to use for skeleton creation
8787
:param templates_path: A path where application skeleton templates reside
88-
:param log_level: Logging
88+
:param log_level: Logging level
8989
9090
"""
9191
self.logger = logging.getLogger(self.__class__.__name__)

src/makeapp/apptools.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .helpers.files import FileHelper
99
from .helpers.vcs import VcsHelper
1010
from .helpers.venvs import VenvHelper
11-
from .utils import chdir
11+
from .utils import chdir, configure_logging
1212

1313
LOG = logging.getLogger(__name__)
1414

@@ -348,11 +348,14 @@ def find_packages(cls, where: Path, *, prefer: str) -> list[Path]:
348348

349349
return packages_found
350350

351-
def __init__(self, project_path: Path = None):
351+
def __init__(self, project_path: Path = None, *, log_level: int = None):
352352
"""
353353
:param project_path: Application root (containing pyproject.toml) path.
354+
:param log_level: Logging level
354355
355356
"""
357+
self.configure_logging(log_level)
358+
356359
project_path = project_path or os.getcwd()
357360
self.project_path = Path(project_path)
358361
self.package: PackageData | None = None
@@ -363,6 +366,15 @@ def __init__(self, project_path: Path = None):
363366
with chdir(self.project_path):
364367
self._gather_data()
365368

369+
def configure_logging(self, verbosity_lvl: int = None, format: str = '%(message)s'):
370+
"""Switches on logging at a given level.
371+
372+
:param verbosity_lvl:
373+
:param format:
374+
375+
"""
376+
configure_logging(verbosity_lvl, logger=LOG, format=format)
377+
366378
def _gather_data(self):
367379
"""Gathers data relevant for project related functions."""
368380
project_path = self.project_path

0 commit comments

Comments
 (0)