diff --git a/django_mailbox/management/commands/getmail.py b/django_mailbox/management/commands/getmail.py index 31b2dbd..59d623b 100644 --- a/django_mailbox/management/commands/getmail.py +++ b/django_mailbox/management/commands/getmail.py @@ -10,6 +10,13 @@ logging.basicConfig(level=logging.INFO) class Command(BaseCommand): + args = "" + help = "" + + def add_arguments(self, parser): + parser.add_argument('--logging', type=bool, default=True, dest='logging', + help='Enable logging (default true)') + def handle(self, *args, **options): mailboxes = Mailbox.active_mailboxes.all() if args: @@ -17,14 +24,16 @@ class Command(BaseCommand): name=' '.join(args) ) for mailbox in mailboxes: - logger.info( - 'Gathering messages for %s', - mailbox.name - ) + if options['logging']: + logger.info( + 'Gathering messages for %s', + mailbox.name + ) messages = mailbox.get_new_mail() for message in messages: - logger.info( - 'Received %s (from %s)', - message.subject, - message.from_address - ) + if options['logging']: + logger.info( + 'Received %s (from %s)', + message.subject, + message.from_address + )