Files
Gymnasium/gym/logger.py
Antonin RAFFIN cdd212db4b Fix autodetect dtype warnings (#1234)
* Fix autodetect dtype warnings

* Use warnings module for gym logger

* Fix warning in tests
2018-11-28 17:27:27 -08:00

38 lines
711 B
Python

import warnings
from gym.utils import colorize
DEBUG = 10
INFO = 20
WARN = 30
ERROR = 40
DISABLED = 50
MIN_LEVEL = 30
def set_level(level):
"""
Set logging threshold on current logger.
"""
global MIN_LEVEL
MIN_LEVEL = level
def debug(msg, *args):
if MIN_LEVEL <= DEBUG:
print('%s: %s'%('DEBUG', msg % args))
def info(msg, *args):
if MIN_LEVEL <= INFO:
print('%s: %s'%('INFO', msg % args))
def warn(msg, *args):
if MIN_LEVEL <= WARN:
warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))
def error(msg, *args):
if MIN_LEVEL <= ERROR:
print(colorize('%s: %s'%('ERROR', msg % args), 'red'))
# DEPRECATED:
setLevel = set_level