Python tensorflow.python.platform.tf_logging.log() Examples

The following are 30 code examples of tensorflow.python.platform.tf_logging.log(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tensorflow.python.platform.tf_logging , or try the search function .
Example #1
Source File: tensorboard_logging_test.py    From deep_image_model with Apache License 2.0 6 votes vote down vote up
def setUp(self):
    self._work_dir = tempfile.mkdtemp(dir=self.get_temp_dir())
    self._sw = tf.train.SummaryWriter(self._work_dir)
    tensorboard_logging.set_summary_writer(self._sw)
    self.addCleanup(shutil.rmtree, self._work_dir)

    # Stop the clock to avoid test flakiness.
    now = time.time()
    time._real_time = time.time
    time.time = lambda: now

    # Mock out logging calls so we can verify that the right number of messages
    # get logged.
    self.logged_message_count = 0
    self._actual_log = logging.log

    def mockLog(*args, **kwargs):
      self.logged_message_count += 1
      self._actual_log(*args, **kwargs)

    logging.log = mockLog 
Example #2
Source File: tensorboard_logging.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 5 votes vote down vote up
def error(message, *args):
  log(ERROR, message, *args) 
Example #3
Source File: tensorboard_logging.py    From deep_image_model with Apache License 2.0 5 votes vote down vote up
def fatal(message, *args):
  log(FATAL, message, *args) 
Example #4
Source File: tensorboard_logging_test.py    From deep_image_model with Apache License 2.0 5 votes vote down vote up
def tearDown(self):
    time.time = time._real_time
    logging.log = self._actual_log 
Example #5
Source File: tensorboard_logging_test.py    From deep_image_model with Apache License 2.0 5 votes vote down vote up
def testBadVerbosity(self):
    with self.assertRaises(ValueError):
      tensorboard_logging.set_verbosity("failure")

    with self.assertRaises(ValueError):
      tensorboard_logging.log("bad", "dead") 
Example #6
Source File: tensorboard_logging.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 5 votes vote down vote up
def set_summary_writer(summary_writer):
  """Sets the summary writer that events will be logged to.

  Calling any logging methods inside this module without calling this method
  will fail. If you don't want to log, call `set_summary_writer(None)`.

  Args:
    summary_writer: Either a SummaryWriter or None. None will cause messages not
    to be logged to any SummaryWriter, but they will still be passed to the
    platform logging module.
  """
  global _summary_writer
  _summary_writer = summary_writer 
Example #7
Source File: tensorboard_logging.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 5 votes vote down vote up
def _clear_summary_writer():
  """Makes all subsequent log invocations error.

  This is only used for testing. If you want to disable TensorBoard logging,
  call `set_summary_writer(None)` instead.
  """
  global _summary_writer
  _summary_writer = _sentinel_summary_writer 
Example #8
Source File: tensorboard_logging.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 5 votes vote down vote up
def log(level, message, *args):
  """Conditionally logs `message % args` at the level `level`.

  Note that tensorboard_logging verbosity and logging verbosity are separate;
  the message will always be passed through to the logging module regardless of
  whether it passes the tensorboard_logging verbosity check.

  Args:
    level: The verbosity level to use. Must be one of
      tensorboard_logging.{DEBUG, INFO, WARN, ERROR, FATAL}.
    message: The message template to use.
    *args: Arguments to interpolate to the message template, if any.

  Raises:
    ValueError: If `level` is not a valid logging level.
    RuntimeError: If the `SummaryWriter` to use has not been set.
  """
  if _summary_writer is _sentinel_summary_writer:
    raise RuntimeError('Must call set_summary_writer before doing any '
                       'logging from tensorboard_logging')
  _check_verbosity(level)
  proto_level = _LEVEL_PROTO_MAP[level]
  if proto_level >= _LEVEL_PROTO_MAP[_verbosity]:
    log_message = event_pb2.LogMessage(level=proto_level,
                                       message=message % args)
    event = event_pb2.Event(wall_time=time.time(), log_message=log_message)

    if _summary_writer:
      _summary_writer.add_event(event)

  logging.log(_PLATFORM_LOGGING_LEVEL_MAP[level], message, *args) 
Example #9
Source File: tensorboard_logging.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 5 votes vote down vote up
def debug(message, *args):
  log(DEBUG, message, *args) 
Example #10
Source File: tensorboard_logging.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 5 votes vote down vote up
def info(message, *args):
  log(INFO, message, *args) 
Example #11
Source File: tensorboard_logging.py    From deep_image_model with Apache License 2.0 5 votes vote down vote up
def error(message, *args):
  log(ERROR, message, *args) 
Example #12
Source File: tensorboard_logging.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 5 votes vote down vote up
def fatal(message, *args):
  log(FATAL, message, *args) 
Example #13
Source File: tensorboard_logging.py    From keras-lambda with MIT License 5 votes vote down vote up
def set_summary_writer(summary_writer):
  """Sets the summary writer that events will be logged to.

  Calling any logging methods inside this module without calling this method
  will fail. If you don't want to log, call `set_summary_writer(None)`.

  Args:
    summary_writer: Either a SummaryWriter or None. None will cause messages not
    to be logged to any SummaryWriter, but they will still be passed to the
    platform logging module.
  """
  global _summary_writer
  _summary_writer = summary_writer 
Example #14
Source File: tensorboard_logging.py    From keras-lambda with MIT License 5 votes vote down vote up
def _clear_summary_writer():
  """Makes all subsequent log invocations error.

  This is only used for testing. If you want to disable TensorBoard logging,
  call `set_summary_writer(None)` instead.
  """
  global _summary_writer
  _summary_writer = _sentinel_summary_writer 
Example #15
Source File: tensorboard_logging.py    From keras-lambda with MIT License 5 votes vote down vote up
def log(level, message, *args):
  """Conditionally logs `message % args` at the level `level`.

  Note that tensorboard_logging verbosity and logging verbosity are separate;
  the message will always be passed through to the logging module regardless of
  whether it passes the tensorboard_logging verbosity check.

  Args:
    level: The verbosity level to use. Must be one of
      tensorboard_logging.{DEBUG, INFO, WARN, ERROR, FATAL}.
    message: The message template to use.
    *args: Arguments to interpolate to the message template, if any.

  Raises:
    ValueError: If `level` is not a valid logging level.
    RuntimeError: If the `SummaryWriter` to use has not been set.
  """
  if _summary_writer is _sentinel_summary_writer:
    raise RuntimeError('Must call set_summary_writer before doing any '
                       'logging from tensorboard_logging')
  _check_verbosity(level)
  proto_level = _LEVEL_PROTO_MAP[level]
  if proto_level >= _LEVEL_PROTO_MAP[_verbosity]:
    log_message = event_pb2.LogMessage(level=proto_level,
                                       message=message % args)
    event = event_pb2.Event(wall_time=time.time(), log_message=log_message)

    if _summary_writer:
      _summary_writer.add_event(event)

  logging.log(_PLATFORM_LOGGING_LEVEL_MAP[level], message, *args) 
Example #16
Source File: tensorboard_logging.py    From keras-lambda with MIT License 5 votes vote down vote up
def debug(message, *args):
  log(DEBUG, message, *args) 
Example #17
Source File: tensorboard_logging.py    From keras-lambda with MIT License 5 votes vote down vote up
def info(message, *args):
  log(INFO, message, *args) 
Example #18
Source File: tensorboard_logging.py    From keras-lambda with MIT License 5 votes vote down vote up
def error(message, *args):
  log(ERROR, message, *args) 
Example #19
Source File: tensorboard_logging.py    From keras-lambda with MIT License 5 votes vote down vote up
def fatal(message, *args):
  log(FATAL, message, *args) 
Example #20
Source File: tensorboard_logging.py    From auto-alt-text-lambda-api with MIT License 5 votes vote down vote up
def debug(message, *args):
  log(DEBUG, message, *args) 
Example #21
Source File: tensorboard_logging.py    From lambda-packs with MIT License 5 votes vote down vote up
def _clear_summary_writer():
  """Makes all subsequent log invocations error.

  This is only used for testing. If you want to disable TensorBoard logging,
  call `set_summary_writer(None)` instead.
  """
  global _summary_writer
  _summary_writer = _sentinel_summary_writer 
Example #22
Source File: tensorboard_logging.py    From lambda-packs with MIT License 5 votes vote down vote up
def log(level, message, *args):
  """Conditionally logs `message % args` at the level `level`.

  Note that tensorboard_logging verbosity and logging verbosity are separate;
  the message will always be passed through to the logging module regardless of
  whether it passes the tensorboard_logging verbosity check.

  Args:
    level: The verbosity level to use. Must be one of
      tensorboard_logging.{DEBUG, INFO, WARN, ERROR, FATAL}.
    message: The message template to use.
    *args: Arguments to interpolate to the message template, if any.

  Raises:
    ValueError: If `level` is not a valid logging level.
    RuntimeError: If the `SummaryWriter` to use has not been set.
  """
  if _summary_writer is _sentinel_summary_writer:
    raise RuntimeError('Must call set_summary_writer before doing any '
                       'logging from tensorboard_logging')
  _check_verbosity(level)
  proto_level = _LEVEL_PROTO_MAP[level]
  if proto_level >= _LEVEL_PROTO_MAP[_verbosity]:
    log_message = event_pb2.LogMessage(level=proto_level,
                                       message=message % args)
    event = event_pb2.Event(wall_time=time.time(), log_message=log_message)

    if _summary_writer:
      _summary_writer.add_event(event)

  logging.log(_PLATFORM_LOGGING_LEVEL_MAP[level], message, *args) 
Example #23
Source File: tensorboard_logging.py    From lambda-packs with MIT License 5 votes vote down vote up
def debug(message, *args):
  log(DEBUG, message, *args) 
Example #24
Source File: tensorboard_logging.py    From lambda-packs with MIT License 5 votes vote down vote up
def info(message, *args):
  log(INFO, message, *args) 
Example #25
Source File: tensorboard_logging.py    From lambda-packs with MIT License 5 votes vote down vote up
def error(message, *args):
  log(ERROR, message, *args) 
Example #26
Source File: tensorboard_logging.py    From lambda-packs with MIT License 5 votes vote down vote up
def fatal(message, *args):
  log(FATAL, message, *args) 
Example #27
Source File: tensorboard_logging.py    From auto-alt-text-lambda-api with MIT License 5 votes vote down vote up
def set_summary_writer(summary_writer):
  """Sets the summary writer that events will be logged to.

  Calling any logging methods inside this module without calling this method
  will fail. If you don't want to log, call `set_summary_writer(None)`.

  Args:
    summary_writer: Either a SummaryWriter or None. None will cause messages not
    to be logged to any SummaryWriter, but they will still be passed to the
    platform logging module.
  """
  global _summary_writer
  _summary_writer = summary_writer 
Example #28
Source File: tensorboard_logging.py    From auto-alt-text-lambda-api with MIT License 5 votes vote down vote up
def _clear_summary_writer():
  """Makes all subsequent log invocations error.

  This is only used for testing. If you want to disable TensorBoard logging,
  call `set_summary_writer(None)` instead.
  """
  global _summary_writer
  _summary_writer = _sentinel_summary_writer 
Example #29
Source File: tensorboard_logging.py    From auto-alt-text-lambda-api with MIT License 5 votes vote down vote up
def log(level, message, *args):
  """Conditionally logs `message % args` at the level `level`.

  Note that tensorboard_logging verbosity and logging verbosity are separate;
  the message will always be passed through to the logging module regardless of
  whether it passes the tensorboard_logging verbosity check.

  Args:
    level: The verbosity level to use. Must be one of
      tensorboard_logging.{DEBUG, INFO, WARN, ERROR, FATAL}.
    message: The message template to use.
    *args: Arguments to interpolate to the message template, if any.

  Raises:
    ValueError: If `level` is not a valid logging level.
    RuntimeError: If the `SummaryWriter` to use has not been set.
  """
  if _summary_writer is _sentinel_summary_writer:
    raise RuntimeError('Must call set_summary_writer before doing any '
                       'logging from tensorboard_logging')
  _check_verbosity(level)
  proto_level = _LEVEL_PROTO_MAP[level]
  if proto_level >= _LEVEL_PROTO_MAP[_verbosity]:
    log_message = event_pb2.LogMessage(level=proto_level,
                                       message=message % args)
    event = event_pb2.Event(wall_time=time.time(), log_message=log_message)

    if _summary_writer:
      _summary_writer.add_event(event)

  logging.log(_PLATFORM_LOGGING_LEVEL_MAP[level], message, *args) 
Example #30
Source File: tensorboard_logging.py    From lambda-packs with MIT License 5 votes vote down vote up
def set_summary_writer(summary_writer):
  """Sets the summary writer that events will be logged to.

  Calling any logging methods inside this module without calling this method
  will fail. If you don't want to log, call `set_summary_writer(None)`.

  Args:
    summary_writer: Either a SummaryWriter or None. None will cause messages not
    to be logged to any SummaryWriter, but they will still be passed to the
    platform logging module.
  """
  global _summary_writer
  _summary_writer = summary_writer