diff --git a/bd_api/custom/logger.py b/bd_api/custom/logger.py index 9862e8a3..1adf0ec9 100644 --- a/bd_api/custom/logger.py +++ b/bd_api/custom/logger.py @@ -27,6 +27,7 @@ def emit(self, record: LogRecord): def setup_logger( level: str = "INFO", + ignore: list[str] = [], serialize: bool = False, format: str = "[{time:YYYY-MM-DD HH:mm:ss}] {message}", ): @@ -36,6 +37,8 @@ def setup_logger( for name in root.manager.loggerDict.keys(): getLogger(name).handlers = [] getLogger(name).propagate = True + if name in ignore: + getLogger(name).setLevel("ERROR") logger.remove() @@ -45,10 +48,3 @@ def setup_logger( format=format, serialize=serialize, ) - logger.add( - "debug.log", - level="DEBUG", - format=format, - rotation="30 MB", - retention="7 days", - ) diff --git a/bd_api/settings/local.py b/bd_api/settings/local.py index f2ba8a41..78d9354f 100644 --- a/bd_api/settings/local.py +++ b/bd_api/settings/local.py @@ -47,7 +47,7 @@ DEFAULT_FROM_EMAIL = getenv("EMAIL_HOST_USER") # Logging -setup_logger(level="DEBUG", serialize=False) +setup_logger(level="DEBUG", ignore=["faker"], serialize=False) # Google Application Credentials GOOGLE_APPLICATION_CREDENTIALS = getenv("GOOGLE_APPLICATION_CREDENTIALS") diff --git a/bd_api/settings/remote.py b/bd_api/settings/remote.py index 3626d76c..b6de29fd 100644 --- a/bd_api/settings/remote.py +++ b/bd_api/settings/remote.py @@ -52,7 +52,7 @@ DEFAULT_FROM_EMAIL = getenvp("EMAIL_HOST_USER") # Logging -setup_logger(level="INFO", serialize=True) +setup_logger(level="INFO", ignore=["faker"], serialize=True) # Google Application Credentials GOOGLE_APPLICATION_CREDENTIALS = getenvp("GOOGLE_APPLICATION_CREDENTIALS", "")