seaborn_logger/logger.py
def setup_file_logging(log_filename, log_file_level="DEBUG", str_format=None,
                       date_format=None, log_restart=False, log_history=False,
                       formatter=None, silence_modules=None, log_filter=None):
    """
    This will setup logging for a single file but can be called more than once
    LOG LEVELS are "CRITICAL", "ERROR", "INFO", "DEBUG"
    :param log_filename:    str of the file location
    :param log_file_level   str of the log level to use on this file
    :param str_format:      str of the logging format
    :param date_format:     str of the date format
    :param log_restart:     bool if True the log file will be deleted first
    :param log_history:     bool if True will save another log file in a folder
                            called history with the datetime
    :param formatter:       logging.Format instance to use
    :param log_filter:      logging.filter instance to add to handler
    :param silence_modules  list of str of modules to silence
    :return:                None
    """
    from seaborn_timestamp.timestamp import datetime_to_str
    if os.path.exists(log_filename) and log_restart:
        os.remove(log_filename)

    add_file_handler(log_file_level, log_filename, str_format=str_format,
                     date_format=date_format, formatter=formatter,
                     log_filter=log_filter)

    if log_history:
        base_name = os.path.basename(log_filename).split('.')[0] + \
                    '_%s' % datetime_to_str(str_format='%Y-%m-%d_%H-%M-%S')
        history_log = os.path.join(os.path.dirname(log_filename),
                                   'history', base_name + '.log')
        add_file_handler(log_file_level, history_log, str_format=str_format,
                         date_format=date_format, log_filter=log_filter)

    silence_module_logging(silence_modules)
def setup_file_logging(log_filename, log_file_level="DEBUG", str_format=None,
                       date_format=None, log_restart=False, log_history=False,
                       formatter=None, silence_modules=None, log_filter=None):
    """
    This will setup logging for a single file but can be called more than once
    LOG LEVELS are "CRITICAL", "ERROR", "INFO", "DEBUG"
    :param log_filename:    str of the file location
    :param log_file_level   str of the log level to use on this file
    :param str_format:      str of the logging format
    :param date_format:     str of the date format
    :param log_restart:     bool if True the log file will be deleted first
    :param log_history:     bool if True will save another log file in a folder
                            called history with the datetime
    :param formatter:       logging.Format instance to use
    :param log_filter:      logging.filter instance to add to handler
    :param silence_modules  list of str of modules to silence
    :return:                None
    """
    from seaborn_timestamp.timestamp import datetime_to_str
    if os.path.exists(log_filename) and log_restart:
        os.remove(log_filename)

    add_file_handler(log_file_level, log_filename, str_format=str_format,
                     date_format=date_format, formatter=formatter,
                     log_filter=log_filter)

    if log_history:
        base_name = os.path.basename(log_filename).split('.')[0] + \
                    '_%s' % datetime_to_str(str_format='%Y-%m-%d_%H-%M-%S')
        history_log = os.path.join(os.path.dirname(log_filename),
                                   'history', base_name + '.log')
        add_file_handler(log_file_level, history_log, str_format=str_format,
                         date_format=date_format, log_filter=log_filter)

    silence_module_logging(silence_modules)
def setup_file_logging ( log_filename , log_file_level = "DEBUG" , str_format = None , date_format = None , log_restart = False , log_history = False , formatter = None , silence_modules = None , log_filter = None ) : from seaborn_timestamp . timestamp import datetime_to_str if os . path . exists ( log_filename ) and log_restart : os . remove ( log_filename ) add_file_handler ( log_file_level , log_filename , str_format = str_format , date_format = date_format , formatter = formatter , log_filter = log_filter ) if log_history : base_name = os . path . basename ( log_filename ) . split ( '.' ) [ 0 ] + '_%s' % datetime_to_str ( str_format = '%Y-%m-%d_%H-%M-%S' ) history_log = os . path . join ( os . path . dirname ( log_filename ) , 'history' , base_name + '.log' ) add_file_handler ( log_file_level , history_log , str_format = str_format , date_format = date_format , log_filter = log_filter ) silence_module_logging ( silence_modules )
This will setup logging for a single file but can be called more than once
    LOG LEVELS are "CRITICAL", "ERROR", "INFO", "DEBUG"
    :param log_filename:    str of the file location
    :param log_file_level   str of the log level to use on this file
    :param str_format:      str of the logging format
    :param date_format:     str of the date format
    :param log_restart:     bool if True the log file will be deleted first
    :param log_history:     bool if True will save another log file in a folder
                            called history with the datetime
    :param formatter:       logging.Format instance to use
    :param log_filter:      logging.filter instance to add to handler
    :param silence_modules  list of str of modules to silence
    :return:                None
This will setup logging for a single file but can be called more than once LOG LEVELS are CRITICAL ERROR INFO DEBUG : param log_filename : str of the file location : param log_file_level str of the log level to use on this file : param str_format : str of the logging format : param date_format : str of the date format : param log_restart : bool if True the log file will be deleted first : param log_history : bool if True will save another log file in a folder called history with the datetime : param formatter : logging . Format instance to use : param log_filter : logging . filter instance to add to handler : param silence_modules list of str of modules to silence : return : None