Log

Provides the main class for logging, Log, and some helpers.

class Log.Stream(log, lvl)[source]

Simple stream wrapper, which provides write() and flush().

write(self, msg)[source]
Parameters:msg (str) –
flush(self)[source]

Flush, i.e. writes to the log.

class Log.Log[source]

The main logging class.

initialize(self, logs=None, verbosity=None, formatter=None)[source]
Parameters:
  • logs (list[str]) –
  • verbosity (list[int]) –
  • formatter (list[str]) – ‘default’, ‘timed’, ‘raw’ or ‘verbose’
init_by_config(self, config)[source]
Parameters:config (Config.Config) –
class Log.StreamThreadLocal[source]

This will just buffer everything, thread-locally, and not forward it to any stream. The idea is that multiple tasks will run in multiple threads and you want to catch all the logging/stdout of each to not clutter the output, and also you want to keep it separate for each.

write(self, msg)[source]
Parameters:msg (str) –
flush(self)[source]

Ignored.

class Log.StreamDummy[source]

This will just discard any data.

write(self, msg)[source]

Ignored.

Parameters:msg (str) –
flush(self)[source]

Ignored.

Log.wrap_log_streams(alternative_stream, also_sys_stdout=False, tf_log_verbosity=None)[source]
Parameters:
  • alternative_stream (StreamThreadLocal|StreamDummy) –
  • also_sys_stdout (bool) – wrap sys.stdout as well
  • tf_log_verbosity (int|str|None) – e.g. “WARNING”
Returns:

context manager which yields (original info stream v1, alternative_stream)