allenact.utils.system
#
HUMAN_LOG_LEVELS
#
Available log levels: "debug", "info", "warning", "error", "none"
ColoredFormatter
#
class ColoredFormatter(logging.Formatter)
Format a log string with colors.
This implementation taken (with modifications) from https://stackoverflow.com/a/384125.
get_logger
#
get_logger() -> logging.Logger
Get a logging.Logger
to stderr. It can be called whenever we wish to
log some message. Messages can get mixed-up
(https://docs.python.org/3.6/library/multiprocessing.html#logging), but it
works well in most cases.
Returns
logger
: the logging.Logger
object
init_logging
#
init_logging(human_log_level: str = "info") -> None
Init the logging.Logger
.
It should be called only once in the app (e.g. in main
). It sets
the log_level to one of HUMAN_LOG_LEVELS
. And sets up a handler
for stderr. The logging level is propagated to all subprocesses.
find_free_port
#
find_free_port(address: str = "127.0.0.1") -> int
Finds a free port for distributed training.
Returns
port
: port number that can be used to listen