From 823a7e3413e821cb7a69c60c40bad0d7626b1ad8 Mon Sep 17 00:00:00 2001 From: foyou Date: Fri, 28 Apr 2023 08:51:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pygtrans/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/pygtrans/__init__.py b/src/pygtrans/__init__.py index bdf4fa4..1bf5b1d 100644 --- a/src/pygtrans/__init__.py +++ b/src/pygtrans/__init__.py @@ -1,4 +1,5 @@ """谷歌翻译""" +import logging from .ApiKeyTranslate import ApiKeyTranslate from .DetectResponse import DetectResponse @@ -20,3 +21,14 @@ __all__ = [ 'Translate', 'ApiKeyTranslate', 'Null', 'LanguageResponse', 'DetectResponse', 'TranslateResponse' ] + +log = logging.getLogger('pygtrans') +_handler = logging.StreamHandler() +_handler.setFormatter( + logging.Formatter( + fmt=f'%(asctime)s datclass.%(levelname)s %(message)s', + datefmt='%Y-%m-%d %H:%M:%S' + ) +) +log.addHandler(_handler) +log.setLevel(logging.INFO)