# Path: util/logger.py
# class _MyFormatter(logging.Formatter):
#     def format(self, record):
# def set_file_handler(path=None, prefix='', time_str=''):
# _LOGGING_METHOD = ['info', 'warning', 'error', 'critical',
#                    'warn', 'exception', 'debug']


import init_path
import tensorflow as tf
import os
from util import logger
            Tell the handler where to record all the information.
            Normally, we want to record the prediction of value loss, and the
            average reward (maybe learning rate)
    '''

    def __init__(self, sess, summary_name, enable=True, summary_dir=None):
        # the interface we need
        self.summary = None
        self.sess = sess
        self.enable = enable
        if not self.enable:  # the summary handler is disabled
            return
        if summary_dir is None:
            self.path = os.path.join(
                init_path.get_base_dir(), 'summary'
            )
        else:
            self.path = os.path.join(summary_dir, 'summary')
        self.path = os.path.abspath(self.path)

        if not os.path.exists(self.path):
            os.makedirs(self.path)
        self.path = os.path.join(self.path, summary_name)

        self.train_writer = tf.summary.FileWriter(self.path, self.sess.graph)

        logger.info(
            'summary write initialized, writing to {}'.format(self.path))

    def get_tf_summary(self):

# Path: util/logger.py
# class _MyFormatter(logging.Formatter):
#     def format(self, record):
# def set_file_handler(path=None, prefix='', time_str=''):
# _LOGGING_METHOD = ['info', 'warning', 'error', 'critical',
#                    'warn', 'exception', 'debug']


# Path: util/summary_handler.py
import init_path
import tensorflow as tf
import os
from util import logger

            Tell the handler where to record all the information.
            Normally, we want to record the prediction of value loss, and the
            average reward (maybe learning rate)
    '''

    def __init__(self, sess, summary_name, enable=True, summary_dir=None):
        # the interface we need
        self.summary = None
        self.sess = sess
        self.enable = enable
        if not self.enable:  # the summary handler is disabled
            return
        if summary_dir is None:
            self.path = os.path.join(
                init_path.get_base_dir(), 'summary'
            )
        else:
            self.path = os.path.join(summary_dir, 'summary')
        self.path = os.path.abspath(self.path)

        if not os.path.exists(self.path):
            os.makedirs(self.path)
        self.path = os.path.join(self.path, summary_name)

        self.train_writer = tf.summary.FileWriter(self.path, self.sess.graph)

        logger.info(
            'summary write initialized, writing to {}'.format(self.path))

    def get_tf_summary(self):

        assert self.summary is not None, logger.error(