Skip to content

Commit

Permalink
Merge pull request #2435 from corinnebosley/switch_off_logging
Browse files Browse the repository at this point in the history
Remove Iris' import logging machinery.
  • Loading branch information
pelson authored Oct 27, 2017
2 parents ba91919 + c09ed31 commit 7831684
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 34 deletions.
6 changes: 0 additions & 6 deletions lib/iris/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def callback(cube, field, filename):
import contextlib
import glob
import itertools
import logging
import os.path
import threading

Expand Down Expand Up @@ -131,11 +130,6 @@ def callback(cube, field, filename):
'IrisDeprecation']


# When required, log the usage of Iris.
if iris.config.IMPORT_LOGGER:
logging.getLogger(iris.config.IMPORT_LOGGER).info('iris %s' % __version__)


Constraint = iris._constraints.Constraint
AttributeConstraint = iris._constraints.AttributeConstraint

Expand Down
10 changes: 1 addition & 9 deletions lib/iris/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,9 @@ def get_dir_option(section, option, default=None):
PALETTE_PATH = get_dir_option(_RESOURCE_SECTION, 'palette_path',
os.path.join(CONFIG_PATH, 'palette'))


#################
# Logging options
_LOGGING_SECTION = 'Logging'

IMPORT_LOGGER = get_option(_LOGGING_SECTION, 'import_logger')


#################
# Runtime options


class NetCDF(object):
"""Control Iris NetCDF options."""

Expand Down
2 changes: 0 additions & 2 deletions lib/iris/etc/site.cfg.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ dot_path = /path/to/dot # see iris.fileformats.dot
sample_data_dir = /path/to/iris/resources/sample_data
test_data_dir = /path/to/iris/resources/test_data

[Logging]
import_logger = logger_name
8 changes: 0 additions & 8 deletions lib/iris/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import inspect
import json
import io
import logging
import math
import os
import os.path
Expand Down Expand Up @@ -146,9 +145,6 @@
os.environ['IRIS_TEST_CREATE_MISSING'] = 'true'


# A shared logger for use by unit tests
logger = logging.getLogger('tests')

# Whether to display matplotlib output to the screen.
_DISPLAY_FIGURES = False

Expand Down Expand Up @@ -440,7 +436,6 @@ def assertDataAlmostEqual(self, data, reference_filename, **kwargs):
self.assertArrayAllClose(nstats, data_stats, **kwargs)
else:
self._ensure_folder(reference_path)
logger.warning('Creating result file: %s', reference_path)
stats = collections.OrderedDict([
('std', np.float_(data.std())),
('min', np.float_(data.min())),
Expand All @@ -459,7 +454,6 @@ def assertFilesEqual(self, test_filename, reference_filename):
fmt.format(test_filename, reference_path))
else:
self._ensure_folder(reference_path)
logger.warning('Creating result file: %s', reference_path)
shutil.copy(test_filename, reference_path)

def assertString(self, string, reference_filename=None):
Expand Down Expand Up @@ -502,7 +496,6 @@ def _check_same(self, item, reference_path, type_comparison_name='CML'):
type_comparison_name)
else:
self._ensure_folder(reference_path)
logger.warning('Creating result file: %s', reference_path)
with open(reference_path, 'wb') as reference_fh:
reference_fh.writelines(
part.encode('utf-8')
Expand Down Expand Up @@ -726,7 +719,6 @@ def _check_reference_file(self, reference_path):
def _ensure_folder(self, path):
dir_path = os.path.dirname(path)
if not os.path.exists(dir_path):
logger.warning('Creating folder: %s', dir_path)
os.makedirs(dir_path)

def check_graphic(self):
Expand Down
1 change: 0 additions & 1 deletion lib/iris/tests/pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def cube_save_test(self, reference_txt_path, reference_cubes=None, reference_pp_
"""
# Watch out for a missing reference text file
if not os.path.isfile(reference_txt_path):
tests.logger.warning('Creating result file: %s', reference_txt_path)
if reference_cubes:
temp_pp_path = iris.util.create_temp_filename(".pp")
try:
Expand Down
1 change: 0 additions & 1 deletion lib/iris/tests/test_cdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def check_dot(self, cube, reference_filename):
reference = ''.join(reference_fh.readlines())
self._assert_str_same(reference, test_string, reference_filename, type_comparison_name='DOT files')
else:
tests.logger.warning('Creating result file: %s', reference_path)
with open(reference_path, 'w') as reference_fh:
reference_fh.writelines(test_string)

Expand Down
2 changes: 0 additions & 2 deletions lib/iris/tests/test_coord_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import iris.tests as tests

from xml.dom.minidom import Document
import logging

import cf_units
import numpy as np
Expand All @@ -37,7 +36,6 @@
import iris.tests.stock


logger = logging.getLogger('tests')


@tests.skip_data
Expand Down
4 changes: 1 addition & 3 deletions lib/iris/tests/test_coordsystem.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2010 - 2016, Met Office
# (C) British Crown Copyright 2010 - 2017, Met Office
#
# This file is part of Iris.
#
Expand All @@ -22,7 +22,6 @@
# import iris tests first so that some things can be initialised before importing anything else
import iris.tests as tests

import logging

import cartopy.crs as ccrs
import cf_units
Expand All @@ -34,7 +33,6 @@
from iris.coord_systems import *


logger = logging.getLogger('tests')


def osgb():
Expand Down
1 change: 0 additions & 1 deletion lib/iris/tests/test_image_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import codecs
import itertools
import json
import logging
import os
import requests
import unittest
Expand Down
1 change: 0 additions & 1 deletion lib/iris/tests/test_pp_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def check_pp(self, pp_fields, reference_filename):
reference = ''.join(reference_fh.readlines())
self._assert_str_same(reference+'\n', test_string+'\n', reference_filename, type_comparison_name='PP files')
else:
tests.logger.warning('Creating result file: %s', reference_path)
with open(reference_path, 'w') as reference_fh:
reference_fh.writelines(test_string)

Expand Down

0 comments on commit 7831684

Please sign in to comment.