NEKO icon indicating copy to clipboard operation
NEKO copied to clipboard

Add debug logging?

Open eihli opened this issue 1 year ago • 4 comments

Aside from the print statements and wandb output, it might be nice for development and debugging to have the option to turn on verbose debug logs.

I've used something like below in the past. Put that in a root level __init__.py file and then in every other file you just import logging; logger = logging.getLogger(__name__); logger.debug(f'foobar')

import logging
import logging.config

LOG_FORMAT = "%(asctime)s %(pathname)s %(lineno)s {}".format(logging.BASIC_FORMAT)

log_level = getattr(logging, os.environ.get('PY_LOG_LVL', 'WARNING').upper())
logging_config = {
    'version': 1,
    'formatters': {
        'standard': {
            'format': LOG_FORMAT,
        },
    },
    'handlers': {
        'default': {
            'level': log_level,
            'formatter': 'standard',
            'class': 'logging.StreamHandler',
        },
    },
    'loggers': {
        '': {
            'handlers': ['default'],
            'level': log_level,
            'propagate': True,
        },
    },
}

logging.config.dictConfig(logging_config)

eihli avatar Jan 21 '24 17:01 eihli