# Path: cortex/_lib/log_utils.py
# def set_file_logger(file_path):
#     global logger
#     fh = logging.FileHandler(file_path)
#     fh.setLevel(logging.DEBUG)
#     fh.setFormatter(file_formatter)
#     logger.addHandler(fh)
#     fh.terminator = ''


import logging
import os
import yaml
import torch
from os import path
from shutil import copyfile, rmtree
from .log_utils import set_file_logger
        out_path = global_out_path
        if out_path is None:
            raise ValueError('If `--out_path` (`-o`) argument is not set, you '
                             'must set both the name argument and configure '
                             'the out_path entry in `config.yaml`')

    if name is not None:
        out_path = path.join(out_path, name)

    if not path.isdir(out_path):
        logger.info('Creating out path `{}`'.format(out_path))
        os.mkdir(out_path)

    binary_dir = path.join(out_path, 'binaries')
    image_dir = path.join(out_path, 'images')

    if clean:
        logger.warning('Cleaning directory (cannot be undone)')
        if path.isdir(binary_dir):
            rmtree(binary_dir)
        if path.isdir(image_dir):
            rmtree(image_dir)

    if not path.isdir(binary_dir):
        os.mkdir(binary_dir)
    if not path.isdir(image_dir):
        os.mkdir(image_dir)

    logger.info('Setting out path to `{}`'.format(out_path))
    logger.info('Logging to `{}`'.format(path.join(out_path, 'out.log')))

# Path: cortex/_lib/log_utils.py
# def set_file_logger(file_path):
#     global logger
#     fh = logging.FileHandler(file_path)
#     fh.setLevel(logging.DEBUG)
#     fh.setFormatter(file_formatter)
#     logger.addHandler(fh)
#     fh.terminator = ''


# Path: cortex/_lib/exp.py
import logging
import os
import yaml
import torch
from os import path
from shutil import copyfile, rmtree
from .log_utils import set_file_logger

        out_path = global_out_path
        if out_path is None:
            raise ValueError('If `--out_path` (`-o`) argument is not set, you '
                             'must set both the name argument and configure '
                             'the out_path entry in `config.yaml`')

    if name is not None:
        out_path = path.join(out_path, name)

    if not path.isdir(out_path):
        logger.info('Creating out path `{}`'.format(out_path))
        os.mkdir(out_path)

    binary_dir = path.join(out_path, 'binaries')
    image_dir = path.join(out_path, 'images')

    if clean:
        logger.warning('Cleaning directory (cannot be undone)')
        if path.isdir(binary_dir):
            rmtree(binary_dir)
        if path.isdir(image_dir):
            rmtree(image_dir)

    if not path.isdir(binary_dir):
        os.mkdir(binary_dir)
    if not path.isdir(image_dir):
        os.mkdir(image_dir)

    logger.info('Setting out path to `{}`'.format(out_path))
    logger.info('Logging to `{}`'.format(path.join(out_path, 'out.log')))

    set_file_logger(path.join(out_path, 'out.log'))