summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-08-18 17:28:52 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-19 18:03:54 +0100
commitadf3bdcbe8b0b0bbe9de2800f2d20a53e8d88543 (patch)
treef98e6a93ff627f944e4ebd1915a793b65be4a079
parentcc9ac01d0726203fbe916cec51cc464eaeae9305 (diff)
toaster: use loggers instead of prints
Switching debugging from using print statement to using loggers, as it uses the logging infrastructure to process the messages. The messages are logged with the "toaster" logger which is defined in the toastermain/settings.py. Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/toaster/orm/models.py22
-rwxr-xr-xlib/toaster/toastergui/views.py4
2 files changed, 17 insertions, 9 deletions
diff --git a/lib/toaster/orm/models.py b/lib/toaster/orm/models.py
index 26abf370..c3fb766c 100644
--- a/lib/toaster/orm/models.py
+++ b/lib/toaster/orm/models.py
@@ -29,6 +29,11 @@ from django.core import validators
from django.conf import settings
import django.db.models.signals
+
+import logging
+logger = logging.getLogger("toaster")
+
+
class GitURLValidator(validators.URLValidator):
import re
regex = re.compile(
@@ -855,8 +860,8 @@ class LayerIndexLayerSource(LayerSource):
except Exception as e:
import traceback
if proxy_settings is not None:
- print "EE: Using proxy ", proxy_settings
- print "EE: could not connect to %s, skipping update: %s\n%s" % (self.apiurl, e, traceback.format_exc(e))
+ logger.info("EE: Using proxy %s" % proxy_settings)
+ logger.warning("EE: could not connect to %s, skipping update: %s\n%s" % (self.apiurl, e, traceback.format_exc(e)))
return
# update branches; only those that we already have names listed in the
@@ -865,7 +870,7 @@ class LayerIndexLayerSource(LayerSource):
if len(whitelist_branch_names) == 0:
raise Exception("Failed to make list of branches to fetch")
- print "Fetching branches"
+ logger.debug("Fetching branches")
branches_info = _get_json_response(apilinks['branches']
+ "?filter=name:%s" % "OR".join(whitelist_branch_names))
for bi in branches_info:
@@ -895,7 +900,7 @@ class LayerIndexLayerSource(LayerSource):
transaction.set_autocommit(True)
# update layerbranches/layer_versions
- print "Fetching layer information"
+ logger.debug("Fetching layer information")
layerbranches_info = _get_json_response(apilinks['layerBranches']
+ "?filter=branch:%s" % "OR".join(map(lambda x: str(x.up_id), [i for i in Branch.objects.filter(layer_source = self) if i.up_id is not None] ))
)
@@ -933,7 +938,7 @@ class LayerIndexLayerSource(LayerSource):
try:
dependlist[lv].append(Layer_Version.objects.get(layer_source = self, layer__up_id = ldi['dependency'], up_branch = lv.up_branch))
except Layer_Version.DoesNotExist:
- print "Cannot find layer version ", self, ldi['dependency'], lv.up_branch
+ logger.warning("Cannot find layer version %s dep:%s up_brach:%s" % (self, ldi['dependency'], lv.up_branch))
for lv in dependlist:
LayerVersionDependency.objects.filter(layer_version = lv).delete()
@@ -944,7 +949,7 @@ class LayerIndexLayerSource(LayerSource):
# update machines
- print "Fetching machine information"
+ logger.debug("Fetching machine information")
machines_info = _get_json_response(apilinks['machines']
+ "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self)))
)
@@ -962,7 +967,7 @@ class LayerIndexLayerSource(LayerSource):
transaction.set_autocommit(True)
# update recipes; paginate by layer version / layer branch
- print "Fetching target information"
+ logger.debug("Fetching target information")
recipes_info = _get_json_response(apilinks['recipes']
+ "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self)))
)
@@ -1236,8 +1241,7 @@ def invalidate_cache(**kwargs):
try:
cache.clear()
except Exception as e:
- print "Problem with cache backend: Failed to clear cache"
- pass
+ logger.warning("Problem with cache backend: Failed to clear cache: %s" % e)
django.db.models.signals.post_save.connect(invalidate_cache)
django.db.models.signals.post_delete.connect(invalidate_cache)
diff --git a/lib/toaster/toastergui/views.py b/lib/toaster/toastergui/views.py
index d6bd7c94..0f05955a 100755
--- a/lib/toaster/toastergui/views.py
+++ b/lib/toaster/toastergui/views.py
@@ -42,6 +42,10 @@ import json
from os.path import dirname
import itertools
+import logging
+
+logger = logging.getLogger("toaster")
+
# all new sessions should come through the landing page;
# determine in which mode we are running in, and redirect appropriately
def landing(request):