Refactor logging configuration to both Django management commands lintmigrations and makemigrations
This commit is contained in:
1 parent
26a8aaa993
commit
5f11f9417f
3 files changed
+18
-11
No files matched your search
@@ -1,6 +1,5 @@
|
||||
import configparser
|
||||
import itertools
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from importlib import import_module
|
||||
@@ -12,7 +11,7 @@ from django.core.management.base import BaseCommand
|
||||
from ...constants import __version__
|
||||
from ...migration_linter import MessageType, MigrationLinter
|
||||
from ...sql_analyser.analyser import ANALYSER_STRING_MAPPING
|
||||
from ..utils import register_linting_configuration_options
|
||||
from ..utils import configure_logging, register_linting_configuration_options
|
||||
|
||||
CONFIG_NAME = "django_migration_linter"
|
||||
PYPROJECT_TOML = "pyproject.toml"
|
||||
@@ -22,8 +21,6 @@ DEFAULT_CONFIG_FILES = (
|
||||
"tox.ini",
|
||||
)
|
||||
|
||||
logger = logging.getLogger("django_migration_linter")
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Lint your migrations"
|
||||
@@ -145,12 +142,7 @@ class Command(BaseCommand):
|
||||
import_module(os.getenv("DJANGO_SETTINGS_MODULE")).__file__
|
||||
)
|
||||
|
||||
if options["verbosity"] > 1:
|
||||
logging.basicConfig(format="%(message)s", level=logging.DEBUG)
|
||||
elif options["verbosity"] == 0:
|
||||
logger.disabled = True
|
||||
else:
|
||||
logging.basicConfig(format="%(message)s")
|
||||
configure_logging(options["verbosity"])
|
||||
|
||||
django_settings_options = self.read_django_settings(options)
|
||||
config_options = self.read_config_file(options)
|
||||
|
||||
Reference in new issue
Block a user