mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-09 22:38:19 +02:00
getmail command: optional logging
This commit is contained in:
parent
fafc183e28
commit
2948b1b1cc
1 changed files with 18 additions and 9 deletions
|
|
@ -10,6 +10,13 @@ logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
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):
|
def handle(self, *args, **options):
|
||||||
mailboxes = Mailbox.active_mailboxes.all()
|
mailboxes = Mailbox.active_mailboxes.all()
|
||||||
if args:
|
if args:
|
||||||
|
|
@ -17,14 +24,16 @@ class Command(BaseCommand):
|
||||||
name=' '.join(args)
|
name=' '.join(args)
|
||||||
)
|
)
|
||||||
for mailbox in mailboxes:
|
for mailbox in mailboxes:
|
||||||
logger.info(
|
if options['logging']:
|
||||||
'Gathering messages for %s',
|
logger.info(
|
||||||
mailbox.name
|
'Gathering messages for %s',
|
||||||
)
|
mailbox.name
|
||||||
|
)
|
||||||
messages = mailbox.get_new_mail()
|
messages = mailbox.get_new_mail()
|
||||||
for message in messages:
|
for message in messages:
|
||||||
logger.info(
|
if options['logging']:
|
||||||
'Received %s (from %s)',
|
logger.info(
|
||||||
message.subject,
|
'Received %s (from %s)',
|
||||||
message.from_address
|
message.subject,
|
||||||
)
|
message.from_address
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue