summaryrefslogtreecommitdiff
path: root/src/buildstream/_messenger.py
diff options
context:
space:
mode:
authorTristan van Berkom <tristan@codethink.co.uk>2020-12-21 16:57:35 +0900
committerTristan van Berkom <tristan@codethink.co.uk>2020-12-21 18:09:59 +0900
commitdc49eb8b81dcf891f145b9469c329999cfc30901 (patch)
treebc77d6a72a2e56d8ef5352a7b410c09cff41d803 /src/buildstream/_messenger.py
parenta15c16cb47cd558634025824ef244c4a3e991ded (diff)
downloadbuildstream-dc49eb8b81dcf891f145b9469c329999cfc30901.tar.gz
_messenger.py: Adding convenience methods for issuing info and warn messages
Several parts of the core have replicated codepaths for issuing info and warn messages, remove the need for these functions by providing a convenience layer in the Messenger object.
Diffstat (limited to 'src/buildstream/_messenger.py')
-rw-r--r--src/buildstream/_messenger.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/buildstream/_messenger.py b/src/buildstream/_messenger.py
index 0a420abdd..3bd98cdbf 100644
--- a/src/buildstream/_messenger.py
+++ b/src/buildstream/_messenger.py
@@ -144,6 +144,71 @@ class Messenger:
self._locals.message_handler(message, is_silenced=self._silent_messages())
+ # status():
+ #
+ # A core facing convenience method for issuing STATUS messages
+ #
+ # Args:
+ # brief: The brief status message
+ # detail: An optional detailed message
+ # kwargs: Additional Message constructor keyword arguments
+ #
+ def status(self, brief: str, *, detail: Optional[str] = None, **kwargs) -> None:
+ message = Message(MessageType.STATUS, brief, detail=detail, **kwargs)
+ self.message(message)
+
+ # info():
+ #
+ # A core facing convenience method for issuing INFO messages
+ #
+ # Args:
+ # brief: The brief info message
+ # detail: An optional detailed message
+ # kwargs: Additional Message constructor keyword arguments
+ #
+ def info(self, brief: str, *, detail: Optional[str] = None, **kwargs) -> None:
+ message = Message(MessageType.INFO, brief, detail=detail, **kwargs)
+ self.message(message)
+
+ # warn():
+ #
+ # A core facing convenience method for issuing WARN messages
+ #
+ # Args:
+ # brief: The brief warning message
+ # detail: An optional detailed message
+ # kwargs: Additional Message constructor keyword arguments
+ #
+ def warn(self, brief: str, *, detail: Optional[str] = None, **kwargs) -> None:
+ message = Message(MessageType.WARN, brief, detail=detail, **kwargs)
+ self.message(message)
+
+ # error():
+ #
+ # A core facing convenience method for issuing ERROR messages
+ #
+ # Args:
+ # brief: The brief error message
+ # detail: An optional detailed message
+ # kwargs: Additional Message constructor keyword arguments
+ #
+ def error(self, brief: str, *, detail: Optional[str] = None, **kwargs) -> None:
+ message = Message(MessageType.ERROR, brief, detail=detail, **kwargs)
+ self.message(message)
+
+ # bug():
+ #
+ # A core facing convenience method for issuing BUG messages
+ #
+ # Args:
+ # brief: The brief bug message
+ # detail: An optional detailed message
+ # kwargs: Additional Message constructor keyword arguments
+ #
+ def bug(self, brief: str, *, detail: Optional[str] = None, **kwargs) -> None:
+ message = Message(MessageType.BUG, brief, detail=detail, **kwargs)
+ self.message(message)
+
# silence()
#
# A context manager to silence messages, this behaves in