summaryrefslogtreecommitdiff
path: root/buildstream/plugin.py
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-07-18 18:15:07 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-07-18 18:59:03 +0900
commitd835c37f2514767b64f6fa5eee0821ec1943a7fd (patch)
tree22d11a25ac1bd6374fa62545395b836c5a9bfd80 /buildstream/plugin.py
parenta950a985e0fa05cf4f7b1b1bbc1de6db338e821c (diff)
downloadbuildstream-d835c37f2514767b64f6fa5eee0821ec1943a7fd.tar.gz
Refactor: Use new logging mechanism from Contexttristan/local-cache-expiry
o element.py / plugin.py: Removed supporting logging code, and derive the log handle from Context. o _scheduler/scheduler.py, _scheduler/queues/queue.py: Adapt to new Job initializer API for the logfile o _scheduler/jobs/job.py: Run job activities within the new context manager which turns on logging for a job. Also removed a lot of custom logging abstract methods which are unneeded. o _scheduler/jobs: Job implementations need not implement so much custom logging.
Diffstat (limited to 'buildstream/plugin.py')
-rw-r--r--buildstream/plugin.py17
1 files changed, 4 insertions, 13 deletions
diff --git a/buildstream/plugin.py b/buildstream/plugin.py
index 29fe2cb11..3e1d89052 100644
--- a/buildstream/plugin.py
+++ b/buildstream/plugin.py
@@ -162,7 +162,6 @@ class Plugin():
self.__provenance = provenance # The Provenance information
self.__type_tag = type_tag # The type of plugin (element or source)
self.__unique_id = _plugin_register(self) # Unique ID
- self.__log = None # The log handle when running a task
# Infer the kind identifier
modulename = type(self).__module__
@@ -474,6 +473,7 @@ class Plugin():
self.call(... command which takes time ...)
"""
with self.__context.timed_activity(activity_name,
+ unique_id=self.__unique_id,
detail=detail,
silent_nested=silent_nested):
yield
@@ -589,27 +589,18 @@ class Plugin():
def _get_provenance(self):
return self.__provenance
- # Accessor for logging handle
- #
- def _get_log_handle(self, log):
- return self.__log
-
- # Mutator for logging handle
- #
- def _set_log_handle(self, log):
- self.__log = log
-
# Context manager for getting the open file handle to this
# plugin's log. Used in the child context to add stuff to
# a log.
#
@contextmanager
def _output_file(self):
- if not self.__log:
+ log = self.__context.get_log_handle()
+ if log is None:
with open(os.devnull, "w") as output:
yield output
else:
- yield self.__log
+ yield log
# _preflight():
# Calls preflight() for the plugin, and allows generic preflight