summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-02-05 13:18:06 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-02-10 23:07:48 +0000
commitda8110a86ad8b57b8c41873d40aeac346ee66b88 (patch)
tree0c25d2757da8ed119316af0886ebb64818bdc8cd /bitbake/lib
parent0c89846dafa229b5af9653d6e141011c35451825 (diff)
downloadpoky-da8110a86ad8b57b8c41873d40aeac346ee66b88.tar.gz
bitbake: toaster: improve logging facilities for toaster
This patch improves the logging facilities for toaster in order to help diagnose bugs that happen on user machines. The logs are stored now under "/tmp/toaster_$$" where $$ is a PID-based unique identifier. On shutdown, toaster will automatically erase all logs unless errors are listed in the log file. On error, Toaster provides suggestions on what to do. This patch includes a minor fix found as a result of logging improvements. (Bitbake rev: 8a8248f7b7e30469f592e2f8adbf6ce21e8685c5) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/ui/buildinfohelper.py47
-rw-r--r--bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py2
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py2
-rw-r--r--bitbake/lib/toaster/toastermain/settings.py6
-rw-r--r--bitbake/lib/toaster/toastermain/urls.py18
5 files changed, 57 insertions, 18 deletions
diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py
index 4e2d4a7dec..491fd1566d 100644
--- a/bitbake/lib/bb/ui/buildinfohelper.py
+++ b/bitbake/lib/bb/ui/buildinfohelper.py
@@ -656,18 +656,41 @@ class BuildInfoHelper(object):
656 assert path.startswith("/") 656 assert path.startswith("/")
657 assert 'build' in self.internal_state 657 assert 'build' in self.internal_state
658 658
659 def _slkey(layer_version): 659 if self.brbe is None:
660 assert isinstance(layer_version, Layer_Version) 660 def _slkey_interactive(layer_version):
661 return len(layer_version.layer.local_path) 661 assert isinstance(layer_version, Layer_Version)
662 662 return len(layer_version.layer.local_path)
663 # Heuristics: we always match recipe to the deepest layer path that 663
664 # we can match to the recipe file path 664 # Heuristics: we always match recipe to the deepest layer path in the discovered layers
665 for bl in sorted(self.orm_wrapper.layer_version_objects, reverse=True, key=_slkey): 665 for lvo in sorted(self.orm_wrapper.layer_version_objects, reverse=True, key=_slkey_interactive):
666 if (path.startswith(bl.layer.local_path)): 666 # we can match to the recipe file path
667 return bl 667 if path.startswith(lvo.layer.local_path):
668 668 return lvo
669 #if we get here, we didn't read layers correctly; mockup the new layer 669
670 unknown_layer, created = Layer.objects.get_or_create(name="unknown", local_path="/", layer_index_url="") 670 else:
671 br_id, be_id = self.brbe.split(":")
672 from bldcontrol.bbcontroller import getBuildEnvironmentController
673 from bldcontrol.models import BuildRequest
674 bc = getBuildEnvironmentController(pk = be_id)
675
676 def _slkey_managed(layer_version):
677 return len(bc.getGitCloneDirectory(layer_version.giturl, layer_version.commit) + layer_version.dirpath)
678
679 # Heuristics: we match the path to where the layers have been checked out
680 for brl in sorted(BuildRequest.objects.get(pk = br_id).brlayer_set.all(), reverse = True, key = _slkey_managed):
681 localdirname = os.path.join(os.path.join(bc.be.sourcedir, bc.getGitCloneDirectory(brl.giturl, brl.commit)), brl.dirpath)
682 if path.startswith(localdirname):
683 #logger.warn("-- managed: matched path %s with layer %s " % (path, localdirname))
684 # we matched the BRLayer, but we need the layer_version that generated this br
685 for lvo in self.orm_wrapper.layer_version_objects:
686 if brl.name == lvo.layer.name:
687 return lvo
688
689 #if we get here, we didn't read layers correctly; dump whatever information we have on the error log
690 logger.error("Could not match layer version for recipe path %s : %s" % (path, self.orm_wrapper.layer_version_objects))
691
692 #mockup the new layer
693 unknown_layer, created = Layer.objects.get_or_create(name="__FIXME__unidentified_layer", local_path="/", layer_index_url="")
671 unknown_layer_version_obj, created = Layer_Version.objects.get_or_create(layer = unknown_layer, build = self.internal_state['build']) 694 unknown_layer_version_obj, created = Layer_Version.objects.get_or_create(layer = unknown_layer, build = self.internal_state['build'])
672 695
673 return unknown_layer_version_obj 696 return unknown_layer_version_obj
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
index 3b539b591a..c4ab87bdc9 100644
--- a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
+++ b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
@@ -68,7 +68,7 @@ class Command(NoArgsCommand):
68 task = None 68 task = None
69 bbctrl.build(list(map(lambda x:x.target, br.brtarget_set.all())), task) 69 bbctrl.build(list(map(lambda x:x.target, br.brtarget_set.all())), task)
70 70
71 logger.debug("runbuilds: Build launched, exiting") 71 logger.debug("runbuilds: Build launched, exiting. Follow build logs at %s/toaster_ui.log" % bec.be.builddir)
72 # disconnect from the server 72 # disconnect from the server
73 bbctrl.disconnect() 73 bbctrl.disconnect()
74 74
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 7353844bf1..b67a6767b3 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -3248,7 +3248,7 @@ else:
3248 def xhr_build(request, pid): 3248 def xhr_build(request, pid):
3249 raise Exception("page not available in interactive mode") 3249 raise Exception("page not available in interactive mode")
3250 3250
3251 def xhr_projectinfo(request, pid): 3251 def xhr_projectinfo(request):
3252 raise Exception("page not available in interactive mode") 3252 raise Exception("page not available in interactive mode")
3253 3253
3254 def xhr_projectedit(request, pid): 3254 def xhr_projectedit(request, pid):
diff --git a/bitbake/lib/toaster/toastermain/settings.py b/bitbake/lib/toaster/toastermain/settings.py
index 7cf905266d..ea7c3534da 100644
--- a/bitbake/lib/toaster/toastermain/settings.py
+++ b/bitbake/lib/toaster/toastermain/settings.py
@@ -344,7 +344,7 @@ LOGGING = {
344 }, 344 },
345 'formatters': { 345 'formatters': {
346 'datetime': { 346 'datetime': {
347 'format': '%(levelname)s %(asctime)s %(message)s' 347 'format': '%(asctime)s %(levelname)s %(message)s'
348 } 348 }
349 }, 349 },
350 'handlers': { 350 'handlers': {
@@ -365,8 +365,8 @@ LOGGING = {
365 'level': 'DEBUG', 365 'level': 'DEBUG',
366 }, 366 },
367 'django.request': { 367 'django.request': {
368 'handlers': ['mail_admins'], 368 'handlers': ['console'],
369 'level': 'ERROR', 369 'level': 'WARN',
370 'propagate': True, 370 'propagate': True,
371 }, 371 },
372 } 372 }
diff --git a/bitbake/lib/toaster/toastermain/urls.py b/bitbake/lib/toaster/toastermain/urls.py
index 6112067579..f66f11dcde 100644
--- a/bitbake/lib/toaster/toastermain/urls.py
+++ b/bitbake/lib/toaster/toastermain/urls.py
@@ -23,6 +23,9 @@ from django.conf.urls import patterns, include, url
23from django.views.generic import RedirectView 23from django.views.generic import RedirectView
24from django.views.decorators.cache import never_cache 24from django.views.decorators.cache import never_cache
25 25
26import logging
27
28logger = logging.getLogger("toaster")
26 29
27# Uncomment the next two lines to enable the admin: 30# Uncomment the next two lines to enable the admin:
28from django.contrib import admin 31from django.contrib import admin
@@ -47,10 +50,12 @@ import toastermain.settings
47 50
48if toastermain.settings.FRESH_ENABLED: 51if toastermain.settings.FRESH_ENABLED:
49 urlpatterns.insert(1, url(r'', include('fresh.urls'))) 52 urlpatterns.insert(1, url(r'', include('fresh.urls')))
53 logger.info("Enabled django-fresh extension")
50 54
51if toastermain.settings.DEBUG_PANEL_ENABLED: 55if toastermain.settings.DEBUG_PANEL_ENABLED:
52 import debug_toolbar 56 import debug_toolbar
53 urlpatterns.insert(1, url(r'', include(debug_toolbar.urls))) 57 urlpatterns.insert(1, url(r'', include(debug_toolbar.urls)))
58 logger.info("Enabled django_toolbar extension")
54 59
55 60
56if toastermain.settings.MANAGED: 61if toastermain.settings.MANAGED:
@@ -70,4 +75,15 @@ for t in os.walk(os.path.dirname(currentdir)):
70 75
71 if "urls.py" in t[2] and t[0] != currentdir: 76 if "urls.py" in t[2] and t[0] != currentdir:
72 modulename = os.path.basename(t[0]) 77 modulename = os.path.basename(t[0])
73 urlpatterns.insert(0, url(r'^' + modulename + '/', include ( modulename + '.urls'))) 78 # make sure we don't have this module name in
79 conflict = False
80 for p in urlpatterns:
81 if p.regex.pattern == '^' + modulename + '/':
82 conflict = True
83 if not conflict:
84 urlpatterns.insert(0, url(r'^' + modulename + '/', include ( modulename + '.urls')))
85 else:
86 logger.warn("Module \'%s\' has a regexp conflict, was not added to the urlpatterns" % modulename)
87
88from pprint import pformat
89logger.debug("urlpatterns list %s", pformat(urlpatterns))