From 555d17adcddcce6728ac75b0e0cff27d0c70cf63 Mon Sep 17 00:00:00 2001 From: David-Wobrock Date: Thu, 19 Jul 2018 22:03:37 +0200 Subject: [PATCH] Rename log object to logger (to follow the standard) --- django_migration_linter/migration_linter.py | 10 +++++----- django_migration_linter/sql_analyser.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/django_migration_linter/migration_linter.py b/django_migration_linter/migration_linter.py index f37a5bf..c4cd0f0 100644 --- a/django_migration_linter/migration_linter.py +++ b/django_migration_linter/migration_linter.py @@ -21,7 +21,7 @@ import sys from . import utils from .sql_analyser import analyse_sql_statements -log = logging.getLogger(__name__) +logger = logging.getLogger(__name__) class MigrationLinter(object): @@ -134,7 +134,7 @@ class MigrationLinter(object): self.django_path, self.python_exe, app_name, migration_name, self.database) - log.info('Executing {0}'.format(sqlmigrate_command)) + logger.info('Executing {0}'.format(sqlmigrate_command)) sqlmigrate_process = Popen( sqlmigrate_command, shell=True, stdout=PIPE, stderr=PIPE) @@ -148,7 +148,7 @@ class MigrationLinter(object): _, err = sqlmigrate_process.communicate() raise RuntimeError('sqlmigrate command failed {0}'.format( err.decode('utf-8'))) - log.info('Found {0} sql migration lines'.format(len(sql_statements))) + logger.info('Found {0} sql migration lines'.format(len(sql_statements))) return sql_statements def _gather_migrations_git(self, git_commit_id): @@ -158,7 +158,7 @@ class MigrationLinter(object): 'cd {0} && ' 'git diff --name-only --diff-filter=A {1}').format( self.django_path, git_commit_id) - log.info('Executing {0}'.format(git_diff_command)) + logger.info('Executing {0}'.format(git_diff_command)) diff_process = Popen( git_diff_command, shell=True, stdout=PIPE, stderr=PIPE) for line in map( @@ -177,7 +177,7 @@ class MigrationLinter(object): for line in map( utils.clean_bytes_to_str, diff_process.stderr.readlines()): output.append(line) - log.info("Error while git diff command:\n{}".format( + logger.info("Error while git diff command:\n{}".format( "".join(output))) raise Exception('Error while executing git diff command') return migrations diff --git a/django_migration_linter/sql_analyser.py b/django_migration_linter/sql_analyser.py index f1d074f..aa06ec2 100644 --- a/django_migration_linter/sql_analyser.py +++ b/django_migration_linter/sql_analyser.py @@ -15,7 +15,7 @@ import re import logging -log = logging.getLogger(__name__) +logger = logging.getLogger(__name__) def has_default(sql, **kwargs): @@ -24,7 +24,7 @@ def has_default(sql, **kwargs): for err in kwargs['errors'] if err['code'] == 'NOT_NULL') if err: - log.info( + logger.info( ('Found a NOT_NULL error in migration, ' 'but it has a default value added: {}').format(err)) kwargs['errors'].remove(err) @@ -70,7 +70,7 @@ def analyse_sql_statements(sql_statements): for statement in sql_statements: for test in migration_tests: if test['fn'](statement, errors=errors): - log.info('Testing {0} -- ERROR'.format(statement)) + logger.info('Testing {0} -- ERROR'.format(statement)) table_search = re.search( 'TABLE `([^`]*)`', statement, re.IGNORECASE) col_search = re.search( @@ -83,7 +83,7 @@ def analyse_sql_statements(sql_statements): } errors.append(err) else: - log.info('Testing {0} -- PASSED'.format(statement)) + logger.info('Testing {0} -- PASSED'.format(statement)) return { 'errors': errors, }