-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fastapi-cache2 for pydantic v2 compatibility
- Loading branch information
1 parent
b5be9cc
commit 87ca88b
Showing
3 changed files
with
96 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import logging | ||
import os | ||
import sys | ||
|
||
|
||
def get_logger() -> logging.Logger: | ||
logger = logging.getLogger('html-reprs') | ||
worker_id = os.environ.get('APP_WORKER_ID', '') | ||
|
||
if not logger.handlers: | ||
handler = logging.StreamHandler(stream=sys.stdout) | ||
if worker_id != '': | ||
handler.setFormatter( | ||
logging.Formatter(f'[%(name)s] [worker {worker_id}] [%(levelname)s] %(message)s') | ||
) | ||
else: | ||
handler.setFormatter(logging.Formatter('[%(name)s] [%(levelname)s] %(message)s')) | ||
logger.addHandler(handler) | ||
|
||
logger.setLevel(logging.DEBUG) | ||
return logger |