-
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.
- Loading branch information
1 parent
2914f05
commit 26305b1
Showing
21 changed files
with
126 additions
and
49 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
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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,50 @@ | ||
import importlib | ||
import os | ||
from datetime import datetime | ||
import logging.config | ||
|
||
|
||
def default_logger(log_to_file: bool) -> logging.Logger: | ||
"""Generates a default console logger. | ||
Args: | ||
log_to_file: Boolean flag to stream logs to a file. | ||
Returns: | ||
logging.Logger: | ||
Logger object. | ||
""" | ||
# todo: Use dictconfig instead of this ugliness | ||
logging.getLogger("uvicorn.error").handlers = [] | ||
logging.getLogger("uvicorn.error").propagate = False | ||
|
||
logging.getLogger("uvicorn.access").handlers = [] | ||
logging.getLogger("uvicorn.access").propagate = False | ||
|
||
logging.getLogger("uvicorn.asgi").handlers = [] | ||
logging.getLogger("uvicorn.asgi").propagate = False | ||
|
||
logging.getLogger("uvicorn.default").handlers = [] | ||
logging.getLogger("uvicorn.default").propagate = False | ||
|
||
if log_to_file: | ||
if not os.path.isdir("logs"): | ||
os.mkdir("logs") | ||
logfile: str = datetime.now().strftime( | ||
os.path.join("logs", "pyninja_%d-%m-%Y.log") | ||
) | ||
handler = logging.FileHandler(filename=logfile) | ||
else: | ||
handler = logging.StreamHandler() | ||
logger = logging.getLogger(__name__) | ||
logger.setLevel(level=logging.INFO) | ||
handler.setFormatter( | ||
fmt=logging.Formatter( | ||
fmt="%(asctime)s - %(levelname)-8s - [%(funcName)s:%(lineno)d] - %(message)s" | ||
) | ||
) | ||
logger.addHandler(hdlr=handler) | ||
return logger | ||
|
||
|
||
LOGGER: logging.getLogger = None |
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
Oops, something went wrong.