Permalink
Browse files

Use logging in cleanup task (fixes GH-640)

  • Loading branch information...
1 parent 0c930a0 commit 3b29ec2d5cfec6005209e82404e6b4694da61de2 @dcramer dcramer committed Nov 1, 2012
Showing with 9 additions and 8 deletions.
  1. +9 −8 src/sentry/tasks/cleanup.py
@@ -36,11 +36,13 @@ def cleanup(days=30, logger=None, site=None, server=None, level=None,
MessageFilterValue, FilterKey, FilterValue, SearchDocument, ProjectCountByMinute
from sentry.utils.query import RangeQuerySetWrapper, SkinnyQuerySet
+ logger = cleanup.get_logger()
+
def cleanup_groups(iterable):
for obj in iterable:
- print ">>> Removing all matching <SearchDocument: group=%s>" % (obj.pk)
+ logger.info("Removing all matching <SearchDocument: group=%s>", obj.pk)
SearchDocument.objects.filter(group=obj).delete()
- print ">>> Removing <%s: id=%s>" % (obj.__class__.__name__, obj.pk)
+ logger.info("Removing <%s: id=%s>", obj.__class__.__name__, obj.pk)
obj.delete()
# TODO: we should collect which messages above were deleted
@@ -68,7 +70,7 @@ def cleanup_groups(iterable):
groups_to_check = set()
if resolved is None:
for obj in RangeQuerySetWrapper(qs):
- print ">>> Removing <%s: id=%s>" % (obj.__class__.__name__, obj.pk)
+ logger.info("Removing <%s: id=%s>", obj.__class__.__name__, obj.pk)
obj.delete()
groups_to_check.add(obj.group_id)
@@ -87,7 +89,7 @@ def cleanup_groups(iterable):
qs = qs.filter(group__status=0)
for obj in RangeQuerySetWrapper(qs):
- print ">>> Removing <%s: id=%s>" % (obj.__class__.__name__, obj.pk)
+ logger.info("Removing <%s: id=%s>", obj.__class__.__name__, obj.pk)
obj.delete()
# Group
@@ -112,7 +114,7 @@ def cleanup_groups(iterable):
qs = qs.filter(project=project)
for obj in RangeQuerySetWrapper(qs):
- print ">>> Removing <%s: id=%s>" % (obj.__class__.__name__, obj.pk)
+ logger.info("Removing <%s: id=%s>", obj.__class__.__name__, obj.pk)
obj.delete()
# Filters
@@ -124,10 +126,9 @@ def cleanup_groups(iterable):
if project:
mqs = mqs.filter(project=project)
- print "checking filters"
for obj in RangeQuerySetWrapper(qs):
if not mqs.filter(key=obj.key).exists():
- print ">>> Removing filters for unused filter %s=*" % (obj.key,)
+ logger.info("Removing filters for unused filter %s=*", obj.key,)
qs.filter(key=obj.key).delete()
obj.delete()
@@ -137,7 +138,7 @@ def cleanup_groups(iterable):
for obj in RangeQuerySetWrapper(qs):
if not mqs.filter(key=obj.key, value=obj.value).exists():
- print ">>> Removing filters for unused filter %s=%s" % (obj.key, obj.value)
+ logger.info("Removing filters for unused filter %s=%s", obj.key, obj.value)
qs.filter(key=obj.key).delete()
obj.delete()

0 comments on commit 3b29ec2

Please sign in to comment.