-
-
Save n37r06u3/29b78998060d1b04a3a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get and install logutils | |
# pip install logutils | |
# === settings.py === | |
class PseudoTTY(object): | |
"""This allows a a fake tty which will allow PyCharm to always say its a tty""" | |
def __init__(self, underlying): | |
"""Define my underlying class""" | |
self.__underlying = underlying | |
def __getattr__(self, name): | |
"""Pass me along to my parent""" | |
return getattr(self.__underlying, name) | |
def isatty(self): | |
"""Force this to always be True""" | |
return True | |
LOGGING = { | |
'version': 1, | |
'disable_existing_loggers': True, | |
'formatters': { | |
'standard': { | |
'format': "[%(asctime)s] %(levelname)s [%(name)s.%(funcName)s:%(lineno)d] %(message)s", | |
'datefmt': "%d/%b/%Y %H:%M:%S" | |
}, | |
}, | |
'handlers': { | |
'console': { | |
'level': 'DEBUG', | |
'class': 'logutils.colorize.ColorizingStreamHandler', | |
'formatter': 'standard', | |
'stream': PseudoTTY(sys.stdout) | |
}, | |
'mail_admins': { | |
'level': 'ERROR', | |
'class': 'django.utils.log.AdminEmailHandler', | |
'include_html': True, | |
}, | |
'logfile': { | |
'level': 'DEBUG', | |
'class': 'logging.handlers.RotatingFileHandler', | |
'filename': "./django.log", | |
'maxBytes': 50000, | |
'backupCount': 2, | |
'formatter': 'standard', | |
}, | |
}, | |
'loggers': { | |
'django': { | |
'handlers': ['console', 'logfile'], | |
'propagate': True, | |
'level': 'ERROR', | |
}, | |
'django.request': { | |
'handlers': ['mail_admins'], | |
'level': 'ERROR', | |
'propagate': False, | |
}, | |
'': { | |
'handlers': ['console', 'logfile'], | |
'level': os.environ.get('AXIS_DEBUG_LEVEL', 'ERROR'), | |
}, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment