Printing messages to stderr (#2312)

Move core python code onto logging module.

Addressing #1884.
This commit is contained in:
Richard Liaw
2018-07-02 16:10:57 -07:00
committed by GitHub
parent bb1d7eaece
commit 178346fa16
4 changed files with 72 additions and 54 deletions
+7 -5
View File
@@ -9,6 +9,7 @@ import time
from ray.services import get_ip_address
from ray.services import get_port
from ray.services import logger
class LogMonitor(object):
@@ -43,7 +44,7 @@ class LogMonitor(object):
"LOG_FILENAMES:{}".format(self.node_ip_address),
num_current_log_files, -1)
for log_filename in new_log_filenames:
print("Beginning to track file {}".format(log_filename))
logger.info("Beginning to track file {}".format(log_filename))
assert log_filename not in self.log_files
self.log_files[log_filename] = []
@@ -83,11 +84,12 @@ class LogMonitor(object):
log_filename, "r")
except IOError as e:
if e.errno == os.errno.EMFILE:
print("Warning: Ignoring {} because there are too "
"many open files.".format(log_filename))
logger.warning(
"Warning: Ignoring {} because there are too "
"many open files.".format(log_filename))
elif e.errno == os.errno.ENOENT:
print("Warning: The file {} was not "
"found.".format(log_filename))
logger.warning("Warning: The file {} was not "
"found.".format(log_filename))
else:
raise e