mirror of
https://github.com/wassname/ray.git
synced 2026-07-16 11:21:10 +08:00
Ray Logging Configuration (#3691)
* fix logging for autoscaler * module logging * try this for logging * yapf * fix * Initial logging setup * momery * ok * remove basicconfig * catch * remove package logging * print * fix * try_fix * fix 1 * revert rllib * logging level * flake8 * fix * fix * Remove vestigal TODO
This commit is contained in:
committed by
Philipp Moritz
parent
5f145041ef
commit
d128636bab
@@ -6,6 +6,7 @@ import binascii
|
||||
import functools
|
||||
import hashlib
|
||||
import inspect
|
||||
import logging
|
||||
import numpy as np
|
||||
import os
|
||||
import subprocess
|
||||
@@ -276,6 +277,33 @@ def resources_from_resource_arguments(default_num_cpus, default_num_gpus,
|
||||
return resources
|
||||
|
||||
|
||||
_default_handler = None
|
||||
|
||||
|
||||
def setup_logger(logging_level, logging_format):
|
||||
"""Setup default logging for ray."""
|
||||
logger = logging.getLogger("ray")
|
||||
if type(logging_level) is str:
|
||||
logging_level = logging.getLevelName(logging_level.upper())
|
||||
logger.setLevel(logging_level)
|
||||
global _default_handler
|
||||
_default_handler = logging.StreamHandler()
|
||||
_default_handler.setFormatter(logging.Formatter(logging_format))
|
||||
logger.addHandler(_default_handler)
|
||||
logger.propagate = False
|
||||
|
||||
|
||||
def try_update_handler(new_stream):
|
||||
global _default_handler
|
||||
logger = logging.getLogger("ray")
|
||||
if _default_handler:
|
||||
new_handler = logging.StreamHandler(stream=new_stream)
|
||||
new_handler.setFormatter(_default_handler.formatter)
|
||||
_default_handler.close()
|
||||
_default_handler = new_handler
|
||||
logger.addHandler(_default_handler)
|
||||
|
||||
|
||||
# This function is copied and modified from
|
||||
# https://github.com/giampaolo/psutil/blob/5bd44f8afcecbfb0db479ce230c790fc2c56569a/psutil/tests/test_linux.py#L132-L138 # noqa: E501
|
||||
def vmstat(stat):
|
||||
|
||||
Reference in New Issue
Block a user