# Path: src/main.py
# def on_shutdown():


import sys
import traceback
import logging, logging.handlers
from logging import Formatter
from .main import app
        return s


def makefunc(level):
    ''' A convenience function for adding to a Logger. '''
    if level == logging.EXCEPT:
        # if an exception and debug level, emit the traceback
        def tb_func(msg, *args, **kwargs):
            log._log(level, msg, args, **kwargs)
            if log.isEnabledFor(logging.DEBUG):
                log.debug(traceback.format_exc())
        return tb_func

    def thefunc(msg, *args, **kwargs):
        if log.isEnabledFor(level):
            log._log(level, msg, args, **kwargs)

    return thefunc


# set up logging, custom levels
logging.addLevelName(logging.NOTE, 'NOTE')          # new levels
logging.addLevelName(logging.EXCEPT, 'EXCEPT')
logging.addLevelName(logging.CRITICAL, 'FATAL')     # copy critical to fatal

# add convenience funcs
log.note    = makefunc(logging.NOTE)
log.exc     = makefunc(logging.EXCEPT)

console_log = logging.StreamHandler(sys.stdout)

# Path: src/main.py
# def on_shutdown():


# Path: src/logcfg.py
import sys
import traceback
import logging, logging.handlers
from logging import Formatter
from .main import app

        return s


def makefunc(level):
    ''' A convenience function for adding to a Logger. '''
    if level == logging.EXCEPT:
        # if an exception and debug level, emit the traceback
        def tb_func(msg, *args, **kwargs):
            log._log(level, msg, args, **kwargs)
            if log.isEnabledFor(logging.DEBUG):
                log.debug(traceback.format_exc())
        return tb_func

    def thefunc(msg, *args, **kwargs):
        if log.isEnabledFor(level):
            log._log(level, msg, args, **kwargs)

    return thefunc


# set up logging, custom levels
logging.addLevelName(logging.NOTE, 'NOTE')          # new levels
logging.addLevelName(logging.EXCEPT, 'EXCEPT')
logging.addLevelName(logging.CRITICAL, 'FATAL')     # copy critical to fatal

# add convenience funcs
log.note    = makefunc(logging.NOTE)
log.exc     = makefunc(logging.EXCEPT)

console_log = logging.StreamHandler(sys.stdout)

if app.debug: