mirror of
https://github.com/clearml/clearml
synced 2025-03-03 10:42:00 +00:00
Removed colorama / coloredlogs, they are now optional packages dynamically loaded
This commit is contained in:
parent
c4c37c5cef
commit
d5a2383b75
@ -3,8 +3,6 @@ attrs>=18.0
|
|||||||
backports.functools-lru-cache>=1.0.2 ; python_version < '3'
|
backports.functools-lru-cache>=1.0.2 ; python_version < '3'
|
||||||
boto3>=1.9
|
boto3>=1.9
|
||||||
botocore>=1.12
|
botocore>=1.12
|
||||||
colorama>=0.4.1
|
|
||||||
coloredlogs>=10.0
|
|
||||||
enum34>=0.9 ; python_version < '3.6'
|
enum34>=0.9 ; python_version < '3.6'
|
||||||
funcsigs>=1.0
|
funcsigs>=1.0
|
||||||
furl>=2.0.0
|
furl>=2.0.0
|
||||||
|
@ -6,9 +6,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
from platform import system
|
from platform import system
|
||||||
|
|
||||||
import colorama
|
|
||||||
from ..config import config, get_log_redirect_level
|
from ..config import config, get_log_redirect_level
|
||||||
from coloredlogs import ColoredFormatter
|
|
||||||
from pathlib2 import Path
|
from pathlib2 import Path
|
||||||
from six import BytesIO
|
from six import BytesIO
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
@ -34,11 +32,22 @@ class LoggerRoot(object):
|
|||||||
def _make_stream_handler(cls, level=None, stream=sys.stdout, colored=False):
|
def _make_stream_handler(cls, level=None, stream=sys.stdout, colored=False):
|
||||||
ch = logging.StreamHandler(stream=stream)
|
ch = logging.StreamHandler(stream=stream)
|
||||||
ch.setLevel(level)
|
ch.setLevel(level)
|
||||||
|
formatter = None
|
||||||
|
|
||||||
|
# if colored, try to import colorama & coloredlogs (by default, not in the requirements)
|
||||||
if colored:
|
if colored:
|
||||||
colorama.init()
|
try:
|
||||||
formatter = ColoredFormatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
import colorama
|
||||||
else:
|
from coloredlogs import ColoredFormatter
|
||||||
|
colorama.init()
|
||||||
|
formatter = ColoredFormatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||||
|
except ImportError:
|
||||||
|
colored = False
|
||||||
|
|
||||||
|
# if we don't need or failed getting colored formatter
|
||||||
|
if not colored or not formatter:
|
||||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||||
|
|
||||||
ch.setFormatter(formatter)
|
ch.setFormatter(formatter)
|
||||||
return ch
|
return ch
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user