From b542d67952231d91329729d1b384e83ed104f753 Mon Sep 17 00:00:00 2001 From: Tamara Norman Date: Tue, 16 Jul 2019 07:08:11 -0700 Subject: [PATCH] Add absl logging functions to the output_streams supported by tf.print (v2). This ensures we can print to these streams without needing to use tf.compat.v1 PiperOrigin-RevId: 258360763 --- tensorflow/python/ops/logging_ops.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tensorflow/python/ops/logging_ops.py b/tensorflow/python/ops/logging_ops.py index e9fb6e0ac2d..55e8b56a7fa 100644 --- a/tensorflow/python/ops/logging_ops.py +++ b/tensorflow/python/ops/logging_ops.py @@ -23,6 +23,7 @@ import pprint import random import sys +from absl import logging import six from tensorflow.python import pywrap_tensorflow @@ -221,10 +222,10 @@ def print_v2(*inputs, **kwargs): ways), and printable python objects. output_stream: The output stream, logging level, or file to print to. Defaults to sys.stderr, but sys.stdout, tf.compat.v1.logging.info, - tf.compat.v1.logging.warning, and tf.compat.v1.logging.error are also - supported. To print to - a file, pass a string started with "file://" followed by the file path, - e.g., "file:///tmp/foo.out". + tf.compat.v1.logging.warning, tf.compat.v1.logging.error, + absl.logging.info, absl.logging.warning and absl.loogging,error are also + supported. To print to a file, pass a string started with "file://" + followed by the file path, e.g., "file:///tmp/foo.out". summarize: The first and last `summarize` elements within each dimension are recursively printed per Tensor. If None, then the first 3 and last 3 elements of each dimension are printed for each tensor. If set to -1, it @@ -268,6 +269,15 @@ def print_v2(*inputs, **kwargs): tf_logging.warn: "log(warning)", tf_logging.ERROR: "log(error)", tf_logging.error: "log(error)", + logging.INFO: "log(info)", + logging.info: "log(info)", + logging.INFO: "log(info)", + logging.WARNING: "log(warning)", + logging.WARN: "log(warning)", + logging.warning: "log(warning)", + logging.warn: "log(warning)", + logging.ERROR: "log(error)", + logging.error: "log(error)", } if _is_filepath(output_stream):