<commit_before>import json
import logging


class Config(object):
    def __init__(self, path):
        self.path = path
        self.load()

    def get(self, key, default=None):
        return self._data.get(key, default)

    def set(self, key, value):
        self._data[key] = value

    def load(self):
        try:
            self._data = json.load(open(self.path, 'r'))
        except Exception:
            logging.warning('Unable to load configuration at {0}'.format(self.path))
            self._data = {}

    def write(self):
        json.dump(self._data, open(self.path, 'w'), sort_keys = True, indent = 4)<commit_msg>Add logging when an error occurs with config<commit_after>import json
import logging


class Config(object):
    def __init__(self, path):
        self.path = path
        self.load()

    def get(self, key, default=None):
        return self._data.get(key, default)

    def set(self, key, value):
        self._data[key] = value

    def load(self):
        try:
            self._data = json.load(open(self.path, 'r'))
        except IOError:
            logging.info('No configuration file found at {0}'.format(self.path))
            self._data = {}
        except Exception:
            logging.warning('Unable to load configuration at {0}'.format(self.path))
            self._data = {}

    def write(self):
        json.dump(self._data, open(self.path, 'w'), sort_keys = True, indent = 4)
        logging.debug('Saved configuration at {0}'.format(self.path))
{'fraction_non_alphanumeric': 0.13, 'fraction_numerical': 0.004, 'mean_word_length': 2.3654708520179373, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5783697', 'n_tokens_mistral': 452, 'n_tokens_neox': 438, 'n_words': 117}