parent
017d2c5c17
commit
e097f0e8cb
2 changed files with 0 additions and 63 deletions
@ -1,22 +0,0 @@ |
|||||||
# -*- coding: utf-8 -*- |
|
||||||
import logging |
|
||||||
from django.core.management.color import color_style |
|
||||||
|
|
||||||
|
|
||||||
class DjangoColorsFormatter(logging.Formatter): |
|
||||||
def __init__(self, *args, **kwargs): |
|
||||||
super(DjangoColorsFormatter, self).__init__(*args, **kwargs) |
|
||||||
self.style = self.configure_style(color_style()) |
|
||||||
|
|
||||||
def configure_style(self, style): |
|
||||||
style.DEBUG = style.HTTP_NOT_MODIFIED |
|
||||||
style.INFO = style.HTTP_INFO |
|
||||||
style.WARNING = style.HTTP_NOT_FOUND |
|
||||||
style.ERROR = style.ERROR |
|
||||||
style.CRITICAL = style.HTTP_SERVER_ERROR |
|
||||||
return style |
|
||||||
|
|
||||||
def format(self, record): |
|
||||||
message = logging.Formatter.format(self, record) |
|
||||||
colorizer = getattr(self.style, record.levelname, self.style.HTTP_SUCCESS) |
|
||||||
return colorizer(message) |
|
||||||
Loading…
Reference in new issue