diff options
Diffstat (limited to 'import_issues.py')
-rwxr-xr-x | import_issues.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/import_issues.py b/import_issues.py index 4b1722e..666644e 100755 --- a/import_issues.py +++ b/import_issues.py @@ -123,6 +123,7 @@ import argparse import csv +import logging import json import os import re @@ -137,6 +138,9 @@ from typing import Dict, List, Optional ID_RE = re.compile(r'^[0-9]+$') +logging.basicConfig(format='%(levelname)s:%(funcName)s:%(message)s', + level=logging.DEBUG) +log = logging.getLogger() email_count = 0 issue_count = 0 @@ -173,7 +177,7 @@ def do_mail( ): global email_count email_count += 1 - print(f"---- #{email_count}") + log.info(f"---- #{email_count}") date = format_datetime(datetime.now(timezone.utc)) msg_id = make_msgid() @@ -491,7 +495,7 @@ def run( for issue_json in issue_jsons: issue_json['notes'].sort(key=lambda x: x['created_at']) - print("-------- CREATING TICKETS") + log.info("-------- CREATING TICKETS") issue_id_map: Dict[int, int] = {} @@ -560,7 +564,7 @@ def run( issue_id_map[gitlab_issue_id] = srht_issue_id - print("-------- CREATING COMMENTS") + log.info("-------- CREATING COMMENTS") for issue_json in issue_jsons: for note_json in issue_json['notes']: @@ -607,7 +611,7 @@ def run( is_confidential=(note_json['confidential'] is True), ) - print("-------- CLOSING CLOSED ISSUES") + log.info("-------- CLOSING CLOSED ISSUES") for issue_json in issue_jsons: if issue_json['state'] == 'closed': @@ -807,7 +811,7 @@ def main(): assert smtp_user, f"No SMTP user given." assert smtp_password, f"No SMTP password given." - print(f"Connecting to {smtp_host}:{smtp_port}, user {smtp_user!r}.") + log.info(f"Connecting to {smtp_host}:{smtp_port}, user {smtp_user!r}.") if smtp_ssl: smtp = smtplib.SMTP_SSL(host=smtp_host, port=smtp_port) |