From cd36f46c4cde694cdf73c35f08dfea1787af486f Mon Sep 17 00:00:00 2001 From: dracador <10620805+dracador@users.noreply.github.com> Date: Thu, 20 Aug 2026 16:08:52 +0200 Subject: [PATCH] do not configure logging on import, use named logger `convert_airtable.py` was configuring the logger for the root level, which clashes with other loggers that are properly configured via a logging dict, like how it's done normally in applications like django. In applications that configure their own logging this caused duplicated log lines and third-party output in seatable's format. It should be possible to toggle seatable_api logging on explicitly if it's needed. In general, libraries should only configure their own named logging space. See https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library --- demo/airtable_importer.py | 8 ++++++++ seatable_api/convert_airtable.py | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/demo/airtable_importer.py b/demo/airtable_importer.py index c9f6fd9..2e6fef8 100755 --- a/demo/airtable_importer.py +++ b/demo/airtable_importer.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import logging import sys from seatable_api import Base, AirtableConvertor from airtable_importer_settings import server_url, api_token, airtable_api_key, airtable_base_id, \ @@ -31,6 +32,13 @@ def import_rows(): if __name__ == '__main__': + logging.basicConfig( + format='[%(asctime)s] [%(levelname)s] %(message)s', + datefmt='%Y-%m-%d %H:%M:%S', + stream=sys.stdout, + level=logging.INFO, + ) + argv_info = '\nusage :\npython3 airtable_importer.py { --import-header | --import-rows }\n' if len(sys.argv) != 2: diff --git a/seatable_api/convert_airtable.py b/seatable_api/convert_airtable.py index 989bf2e..ea9acea 100644 --- a/seatable_api/convert_airtable.py +++ b/seatable_api/convert_airtable.py @@ -1,7 +1,6 @@ import json import logging import re -import sys import time import random import requests @@ -27,8 +26,7 @@ FILE = 'file' IMAGE = 'image' -logging.basicConfig(format='[%(asctime)s] [%(levelname)s] %(message)s', datefmt='%Y-%m-%d %H:%M:%S', stream=sys.stdout, level=logging.INFO) -logger = logging.getLogger() +logger = logging.getLogger(__name__) class LinksConvertor(object):