#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This modules defines pyfraclogger function which
implements a flexible event logging system.
"""

import logging
import logging.handlers
import os
import inspect

def pyfraclogger(loggername=None, every="midnight", tofile=True):
        """
    This function will return a logger that will write the
    debug level logs to a file and print info level 
    logs on the screen

    Parameters
    ----------
    every : str, optional {'S', 'M', 'H', 'D', 'midnight'}
        Backup of logs `every` (the default is `midnight`)
    tofile: bool, Write logs to file or not  

    Returns
    -------
    logger
        logger object with filehandler for debug level logs  and streamhandler for info level
    """
            BASE_DIR = '/var/log/pyfrac/'
                loggername=str(inspect.getouterframes(inspect.currentframe())[1][1]).split('/')[-1][:-3]
                    LOG_FNAME = os.path.join(BASE_DIR, loggername)
                        logger = logging.getLogger(loggername)

                            logger.setLevel(logging.DEBUG)
                                formatter = logging.Formatter(
