summaryrefslogtreecommitdiff
path: root/src/buildstream/_message.py
diff options
context:
space:
mode:
authorChandan Singh <csingh43@bloomberg.net>2019-04-24 22:53:19 +0100
committerChandan Singh <csingh43@bloomberg.net>2019-05-21 12:41:18 +0100
commit070d053e5cc47e572e9f9e647315082bd7a15c63 (patch)
tree7fb0fdff52f9b5f8a18ec8fe9c75b661f9e0839e /src/buildstream/_message.py
parent6c59e7901a52be961c2a1b671cf2b30f90bc4d0a (diff)
downloadbuildstream-070d053e5cc47e572e9f9e647315082bd7a15c63.tar.gz
Move source from 'buildstream' to 'src/buildstream'
This was discussed in #1008. Fixes #1009.
Diffstat (limited to 'src/buildstream/_message.py')
-rw-r--r--src/buildstream/_message.py80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/buildstream/_message.py b/src/buildstream/_message.py
new file mode 100644
index 000000000..c2cdb8277
--- /dev/null
+++ b/src/buildstream/_message.py
@@ -0,0 +1,80 @@
+#
+# Copyright (C) 2017 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see <http://www.gnu.org/licenses/>.
+#
+# Authors:
+# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
+
+import datetime
+import os
+
+
+# Types of status messages.
+#
+class MessageType():
+ DEBUG = "debug" # Debugging message
+ STATUS = "status" # Status message, verbose details
+ INFO = "info" # Informative messages
+ WARN = "warning" # Warning messages
+ ERROR = "error" # Error messages
+ BUG = "bug" # An unhandled exception was raised in a plugin
+ LOG = "log" # Messages for log files _only_, never in the frontend
+
+ # Timed Messages: SUCCESS and FAIL have duration timestamps
+ START = "start" # Status start message
+ SUCCESS = "success" # Successful status complete message
+ FAIL = "failure" # Failing status complete message
+ SKIPPED = "skipped"
+
+
+# Messages which should be reported regardless of whether
+# they are currently silenced or not
+unconditional_messages = [
+ MessageType.INFO,
+ MessageType.WARN,
+ MessageType.FAIL,
+ MessageType.ERROR,
+ MessageType.BUG
+]
+
+
+# Message object
+#
+class Message():
+
+ def __init__(self, unique_id, message_type, message,
+ task_id=None,
+ detail=None,
+ action_name=None,
+ elapsed=None,
+ depth=None,
+ logfile=None,
+ sandbox=None,
+ scheduler=False):
+ self.message_type = message_type # Message type
+ self.message = message # The message string
+ self.detail = detail # An additional detail string
+ self.action_name = action_name # Name of the task queue (fetch, refresh, build, etc)
+ self.elapsed = elapsed # The elapsed time, in timed messages
+ self.depth = depth # The depth of a timed message
+ self.logfile = logfile # The log file path where commands took place
+ self.sandbox = sandbox # The error that caused this message used a sandbox
+ self.pid = os.getpid() # The process pid
+ self.unique_id = unique_id # The plugin object ID issueing the message
+ self.task_id = task_id # The plugin object ID of the task
+ self.scheduler = scheduler # Whether this is a scheduler level message
+ self.creation_time = datetime.datetime.now()
+ if message_type in (MessageType.SUCCESS, MessageType.FAIL):
+ assert elapsed is not None