File: example_command.py

package info (click to toggle)
python-django-structlog 9.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,000 kB
  • sloc: python: 3,359; sh: 206; javascript: 79; makefile: 19
file content (17 lines) | stat: -rw-r--r-- 526 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import structlog
from django.core import management
from django.core.management import BaseCommand
from django_extensions.management.utils import signalcommand

logger = structlog.getLogger(__name__)


class Command(BaseCommand):
    def add_arguments(self, parser):
        parser.add_argument("foo", type=str)

    @signalcommand
    def handle(self, foo, *args, **options):
        logger.info("my log", foo=foo)
        management.call_command("example_nested_command", "buz", verbosity=0)
        logger.info("my log 2")