|View source on GitHub|
Base Class for transformer logging infrastructure. Defaults to text-based logging.
cirq.TransformerLogger() -> None
Used in the notebooks
|Used in the tutorials|
The logger implementation should be stateful, s.t.:
- Each call to `register_initial` registers a new transformer stage and initial circuit. - Each subsequent call to `log` should store additional logs corresponding to the stage. - Each call to `register_final` should register the end of the currently active stage.
The logger assumes that
- Transformers are run sequentially. - Nested transformers are allowed, in which case the behavior would be similar to a doing a depth first search on the graph of transformers -- i.e. the top level transformer would end (i.e. receive a `register_final` call) once all nested transformers (i.e. all `register_initial` calls received while the top level transformer was active) have finished (i.e. corresponding `register_final` calls have also been received). - This behavior can be simulated by maintaining a stack of currently active stages and adding data from `log` calls to the stage at the top of the stack.
LogLevels can be used to control the input processing and output resolution of the logs.
log( *args, level: LogLevel = LogLevel.INFO ) -> None
Log additional metadata corresponding to the currently active transformer stage.
||The additional metadata to log.|
||Logging level to control the amount of metadata that gets put into the context.|
||If there's no active transformer on the stack.|
register_final( circuit: 'cirq.AbstractCircuit', transformer_name: str ) -> None
Register the end of the currently active transformer stage.
||Final transformed output circuit from the transformer stage.|
||Name of the (currently active) transformer stage which ends.|
register_initial( circuit: 'cirq.AbstractCircuit', transformer_name: str ) -> None
Register the beginning of a new transformer stage.
||Input circuit to the new transformer stage.|
||Name of the new transformer stage.|
show( level: LogLevel = LogLevel.INFO ) -> None
Show the stored logs >= level in the desired format.
The logging level to filter the logs with. The method shows all logs with a