exo_bespin/logging/logging_tools.py
def configure_logging(log_filename, log_dir=os.path.join(os.path.expanduser("~"), 'exo_bespin_logs/')):
    """Configure the log file with a standard logging format.

    By default, the log file will be written to a ``exo_bespin_logs/``
    subdirectory in the user's ``$HOME`` directory.  However, the user
    may supply a ``log_dir`` parameter to write this file somewhere
    else.

    Parameters
    ----------
    log_filename : str
        The name that will be used to create the log file (e.g.
        ``my_log_<timestamp>.log``)

    Returns
    -------
    full_filename : str
        The full path to the created log file
    """

    # Make sure log_dir exists
    if not os.path.exists(log_dir):
        os.makedirs(log_dir)

    # Build complete log filename
    timestamp = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M')
    full_filename = os.path.join(log_dir, '{0}_{1}.log'.format(log_filename, timestamp))

    # Make sure no other root lhandlers exist before configuring the logger
    for handler in logging.root.handlers[:]:
        logging.root.removeHandler(handler)

    # Create the log file and set the permissions
    logging.basicConfig(filename=full_filename,
                        format='%(asctime)s %(levelname)s: %(message)s',
                        datefmt='%m/%d/%Y %H:%M:%S %p',
                        level=logging.INFO)

    print('Log file initialized to {}'.format(full_filename))

    # Log system information
    _log_environment_info()

    return full_filename
Configure the log file with a standard logging format.

    By default, the log file will be written to a ``exo_bespin_logs/``
    subdirectory in the user's ``$HOME`` directory.  However, the user
    may supply a ``log_dir`` parameter to write this file somewhere
    else.

    Parameters
    ----------
    log_filename : str
        The name that will be used to create the log file (e.g.
        ``my_log_<timestamp>.log``)

    Returns
    -------
    full_filename : str
        The full path to the created log file
    
Configure the log file with a standard logging format.

Parameters

log_filename : str
The name that will be used to create the log file

Returns

full_filename : str
The full path to the created log file
Configure the log file with a standard logging format . Parameters log_filename : str The name that will be used to create the log file Returns full_filename : str The full path to the created log file
def configure_logging(log_filename, log_dir=os.path.join(os.path.expanduser("~"), 'exo_bespin_logs/')):
    if not os.path.exists(log_dir):
        os.makedirs(log_dir)
    timestamp = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M')
    full_filename = os.path.join(log_dir, '{0}_{1}.log'.format(log_filename, timestamp))
    for handler in logging.root.handlers[:]:
        logging.root.removeHandler(handler)
    logging.basicConfig(filename=full_filename,
                        format='%(asctime)s %(levelname)s: %(message)s',
                        datefmt='%m/%d/%Y %H:%M:%S %p',
                        level=logging.INFO)
    print('Log file initialized to {}'.format(full_filename))
    _log_environment_info()
    return full_filename
def configure_logging ( log_filename , log_dir = os . path . join ( os . path . expanduser ( "~" ) , 'exo_bespin_logs/' ) ) : if not os . path . exists ( log_dir ) : os . makedirs ( log_dir ) timestamp = datetime . datetime . now ( ) . strftime ( '%Y-%m-%d-%H-%M' ) full_filename = os . path . join ( log_dir , '{0}_{1}.log' . format ( log_filename , timestamp ) ) for handler in logging . root . handlers [ : ] : logging . root . removeHandler ( handler ) logging . basicConfig ( filename = full_filename , format = '%(asctime)s %(levelname)s: %(message)s' , datefmt = '%m/%d/%Y %H:%M:%S %p' , level = logging . INFO ) print ( 'Log file initialized to {}' . format ( full_filename ) ) _log_environment_info ( ) return full_filename
Configure the log file with a standard logging format.
Configure the log file with a standard logging format .
"""Configure the log file with a standard logging format.

    By default, the log file will be written to a ``exo_bespin_logs/``
    subdirectory in the user's ``$HOME`` directory.  However, the user
    may supply a ``log_dir`` parameter to write this file somewhere
    else.

    Parameters
    ----------
    log_filename : str
        The name that will be used to create the log file (e.g.
        ``my_log_<timestamp>.log``)

    Returns
    -------
    full_filename : str
        The full path to the created log file
    """ # Make sure log_dir exists # Build complete log filename # Make sure no other root lhandlers exist before configuring the logger # Create the log file and set the permissions # Log system information
log_filename
log_dir