Deprecate the `log.colour` attribute
This is really global state, so doesn't belong on the log instances - nor does setting it actually have any effect on whether colored output is used.
Lastly, this doesn't match the spelling of the other color function!
Removing this takes us a step closer to resolving
@@ -60,10 +60,8 @@ class SimBaseLog(logging.getLoggerClass()):
if want_color_output():
hdlr.setFormatter(SimColourLogFormatter())
- self.colour = True
else:
hdlr.setFormatter(SimLogFormatter())
- self.colour = False
self.propagate = False
self.addHandler(hdlr)
@@ -91,9 +89,17 @@ class SimBaseLog(logging.getLoggerClass()):
warnings.warn(
"the .logger attribute should not be used now that `SimLog` "
"returns a native logger instance directly.",
- DeprecationWarning)
+ DeprecationWarning, stacklevel=2)
return self
+ @property
+ def colour(self):
+ warnings.warn(
+ "the .colour attribute may be removed in future, use the "
+ "equivalent `cocotb.utils.want_color_output()` instead",
+ DeprecationWarning, stacklevel=2)
+ return want_color_output()
+
# this used to be a class, hence the unusual capitalization
def SimLog(name, ident=None):
