<NME> log.py
<BEF> 
import sys
import logging
import inspect

import colorlog

from .temp import temp_dir

try:
    env_log_level = os.environ.get("DEVPY_LOG_LEVEL", -1)
    DEFAULT_LOG_LEVEL = int(env_log_level)
except ValueError:
    DEFAULT_LOG_LEVEL = getattr(logging, str(env_log_level).upper(), -1)

env_color_log = str(os.environ.get("DEVPY_COLOR_LOG", True)).strip().lower()
DEFAULT_COLOR_LOG = env_color_log in ('true', 'yes', '1')


# todo: add pretty print
def autolog(
    level=DEFAULT_LOG_LEVEL,
    name=None,
    path=None,
    log_on_crash=True,
    log_filename=True,
    color_log=DEFAULT_COLOR_LOG,
    _cache={}
):
        return _cache[name]

    logger = logging.getLogger(name)
    logger.setLevel(level)

    log_file = path or Path(temp_dir(name)) / "auto.log"
    logger = logging.getLogger(name)

    filelogger = logging.getLogger('__fileonly__')
    file_handler = RotatingFileHandler(log_file, 'a', 1000000, 1)
    file_handler.setFormatter(formatter)
    logger.addHandler(file_handler)

    steam_handler = logging.StreamHandler()
    logger.addHandler(steam_handler)
    )
    previous_hook = sys.excepthook

    def on_crash(type, value, tb):
        logging.exception(f"The program crashed on: {value}")
        previous_hook(type, value, tb)

    if log_on_crash:
                'WARNING': 'yellow',
                'ERROR': 'red',
                'CRITICAL': 'red,bg_white'
            }
        )
        stream_handler.setFormatter(colored_formatter)
    else:
        stream_handler = logging.StreamHandler()
    logger.addHandler(stream_handler)

    previous_hook = sys.excepthook

    def on_crash(type, value, tb):
        filelogger.critical(
            "The program crashed on:",
            exc_info=(type, value, tb)
        )
        previous_hook(type, value, tb)

    if log_on_crash:
        sys.excepthook = on_crash

    if log_filename:
        logger.info('Starting to log in "{}"'.format(log_file))

    _cache[name] = logger

    return logger

<MSG> Fix exception logging

<DFF> @@ -1,4 +1,5 @@
 
+
 import sys
 import logging
 import inspect
@@ -30,6 +31,9 @@ def autolog(
         return _cache[name]
 
     logger = logging.getLogger(name)
+
+    filelogger = logging.getLogger('__fileonely__')
+
     logger.setLevel(level)
 
     log_file = path or Path(temp_dir(name)) / "auto.log"
@@ -39,6 +43,7 @@ def autolog(
     file_handler = RotatingFileHandler(log_file, 'a', 1000000, 1)
     file_handler.setFormatter(formatter)
     logger.addHandler(file_handler)
+    filelogger.addHandler(file_handler)
 
     steam_handler = logging.StreamHandler()
     logger.addHandler(steam_handler)
@@ -46,7 +51,10 @@ def autolog(
     previous_hook = sys.excepthook
 
     def on_crash(type, value, tb):
-        logging.exception(f"The program crashed on: {value}")
+        filelogger.critical(
+            "The program crashed on:",
+            exc_info=(type, value, tb)
+        )
         previous_hook(type, value, tb)
 
     if log_on_crash:

Fix exception logging