Skip to content

Commit

Permalink
Upgrade colorlog dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtibbles committed May 13, 2024
1 parent 996e896 commit 297d930
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
23 changes: 1 addition & 22 deletions kolibri/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
import os
from logging.handlers import TimedRotatingFileHandler

from colorlog import ColoredFormatter
from colorlog import TTYColoredFormatter as BaseTTYColoredFormatter


GET_FILES_TO_DELETE = "getFilesToDelete"
DO_ROLLOVER = "doRollover"
Expand Down Expand Up @@ -168,24 +165,6 @@ def filter(self, record):
return record.levelno < logging.ERROR


class TTYColoredFormatter(BaseTTYColoredFormatter):
"""
A logging formatter that can be used to colorize output to a TTY.
Subclassed from the base TTY formatter to allow slightly more more permissive
color formatting when we are running using the NPM concurrently package,
which does not register as a TTY context.
"""

def color(self, log_colors, level_name):
"""
Only returns colors if STDOUT is a TTY, or if we are running in a
NPM concurrently context.
"""
if not self.stream.isatty() and "FORCE_COLOR" not in os.environ:
log_colors = {}
return ColoredFormatter.color(self, log_colors, level_name)


def get_default_logging_config(LOG_ROOT, debug=False, debug_database=False):
"""
A minimal logging config for just kolibri without any Django
Expand Down Expand Up @@ -255,7 +234,7 @@ def get_default_logging_config(LOG_ROOT, debug=False, debug_database=False):
},
"simple_date": {"format": "%(levelname)s %(asctime)s %(name)s %(message)s"},
"color": {
"()": "kolibri.utils.logger.TTYColoredFormatter",
"()": "colorlog.ColoredFormatter",
"format": "%(log_color)s%(levelname)-8s %(asctime)s %(message)s",
"log_colors": LOG_COLORS,
},
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ django-filter==21.1
django-js-reverse==0.10.2
djangorestframework==3.14.0
django==3.2.25
colorlog==3.2.0 # pyup: <4.0.0
colorlog==6.8.2
configobj==5.0.6
django-mptt==0.14.0
requests==2.27.1
Expand Down

0 comments on commit 297d930

Please sign in to comment.