Skip to content

Commit

Permalink
test-rollbar command (#2438)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe authored May 6, 2024
1 parent b1183e8 commit ca7f11a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions peterbecom/base/management/commands/test-rollbar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import rollbar
from django.conf import settings
from django.core.management.base import BaseCommand


class Command(BaseCommand):
def handle(self, **options):
ROLLBAR_ENABLED = settings.ROLLBAR and settings.ROLLBAR.get("enabled", True)
if ROLLBAR_ENABLED:
redacted = (
settings.ROLLBAR["access_token"][:4]
+ "..."
+ settings.ROLLBAR["access_token"][-4:]
)
self.stdout.write(
self.style.WARNING(f"ROLLBAR is enabled access token {redacted!r}")
)
rollbar.init(
settings.ROLLBAR["access_token"], settings.ROLLBAR["environment"]
)
uuid = rollbar.report_message("testing rollbar")
self.stdout.write(self.style.SUCCESS(f"Reported message with UUID {uuid}"))
elif not settings.ROLLBAR:
self.stdout.write(self.style.ERROR("settings.ROLLBAR not defined"))
elif not settings.ROLLBAR.get("enabled", True):
self.stdout.write(self.style.ERROR("settings.ROLLBAR.enabled is falsy"))

0 comments on commit ca7f11a

Please sign in to comment.