<commit_before>#!/usr/bin/env python
# encoding: utf-8
"""
IceLogging.py

Created by Scott on 2013-01-24.
Copyright (c) 2013 <NAME>. All rights reserved.
"""

import sys
import os
import time
import traceback
import settings

import logging
import logging.handlers

class IceLogger():
    ''' initialize our loggers '''
    def __init__(self):
        # steam handler (only print info messages to terminal)
        ch = logging.StreamHandler()
        ch.setLevel(logging.INFO)
        ch.setFormatter(logging.Formatter('%(asctime)s (%(name)s) %(levelname)s: %(message)s'))

        # logfile handler (print all messages to logfile)
        # - max file size of 1mb
        # - log file is stored in root ice folder and is named 'ice.log'
        fh = logging.handlers.RotatingFileHandler(filename='ice.log', maxBytes=1048576, backupCount=5)
        fh.setLevel(logging.INFO)
        fh.setFormatter(logging.Formatter('%(asctime)s (%(name)s) %(levelname)s: %(message)s'))

        # loggers
        self.logger = logging.getLogger('ice')
        self.logger.setLevel(logging.INFO)
        self.logger.addHandler(ch)
        self.logger.addHandler(fh)

        self.log        = self.logger.info
        self.debug      = self.logger.debug
        self.warning    = self.logger.warning
        self.error      = self.logger.error

    def exception(self, message="An exception occurred!"):
        self.logger.exception(message)

    # premade logs
    def log_config_error(self, error):
        self.error("There was a problem with '[%s] %s' in %s" % (error.section, error.key, error.file))
        config = settings.settings_for_file(error.file)
        try:
            self.error("The current value is set to '%s'" % config.get(error.section, error.key))
        except KeyError as e:
            self.error(e.message)
        self.error(error.fix_instructions)<commit_msg>`ice.log` now includes DEBUG logs by default.<commit_after>#!/usr/bin/env python
# encoding: utf-8
"""
IceLogging.py

Created by Scott on 2013-01-24.
Copyright (c) 2013 <NAME>. All rights reserved.
"""

import sys
import os
import time
import traceback
import settings

import logging
import logging.handlers

class IceLogger():
    ''' initialize our loggers '''
    def __init__(self):
        # steam handler (only print info messages to terminal)
        ch = logging.StreamHandler()
        ch.setLevel(logging.INFO)
        ch.setFormatter(logging.Formatter('%(asctime)s (%(name)s) %(levelname)s: %(message)s'))

        # logfile handler (print all messages to logfile)
        # - max file size of 1mb
        # - log file is stored in root ice folder and is named 'ice.log'
        fh = logging.handlers.RotatingFileHandler(filename='ice.log', maxBytes=1048576, backupCount=5)
        fh.setLevel(logging.DEBUG)
        fh.setFormatter(logging.Formatter('%(asctime)s (%(name)s) %(levelname)s: %(message)s'))

        # loggers
        self.logger = logging.getLogger('ice')
        self.logger.setLevel(logging.INFO)
        self.logger.addHandler(ch)
        self.logger.addHandler(fh)

        self.log        = self.logger.info
        self.debug      = self.logger.debug
        self.warning    = self.logger.warning
        self.error      = self.logger.error

    def exception(self, message="An exception occurred!"):
        self.logger.exception(message)

    # premade logs
    def log_config_error(self, error):
        self.error("There was a problem with '[%s] %s' in %s" % (error.section, error.key, error.file))
        config = settings.settings_for_file(error.file)
        try:
            self.error("The current value is set to '%s'" % config.get(error.section, error.key))
        except KeyError as e:
            self.error(e.message)
        self.error(error.fix_instructions)
{'fraction_non_alphanumeric': 0.1215323645970938, 'fraction_numerical': 0.011624834874504624, 'mean_word_length': 2.759682224428997, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7204179', 'n_tokens_mistral': 1183, 'n_tokens_neox': 1124, 'n_words': 287}