-
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.
Fix: log path invalid; update README
- Loading branch information
Showing
8 changed files
with
59 additions
and
83 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
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 |
---|---|---|
@@ -1 +1 @@ | ||
from log.log_impl import logger | ||
from log.log_impl import get_logger |
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 |
---|---|---|
@@ -1,24 +1,22 @@ | ||
import os | ||
from logging import Formatter, StreamHandler, getLogger, DEBUG | ||
from logging.handlers import RotatingFileHandler | ||
from sys import stdout | ||
|
||
from config import MB, PROJECT_NAME, PATH_LOG_DIR, DEFAULT_ENCODING | ||
from config import MB, PROJECT_NAME, DEFAULT_ENCODING, get_log_file | ||
|
||
__log_file = os.path.join(PATH_LOG_DIR, f'{PROJECT_NAME.lower()}.log') | ||
if not os.path.exists(PATH_LOG_DIR): | ||
os.makedirs(PATH_LOG_DIR) | ||
|
||
# File logger | ||
__file_handler = RotatingFileHandler(__log_file, maxBytes=10 * MB, backupCount=5, encoding=DEFAULT_ENCODING) | ||
__fmt = '%(asctime)s - %(threadName)s(%(thread)d) - %(filename)s:%(lineno)s - %(levelname)s - %(message)s' | ||
__formatter = Formatter(__fmt) | ||
__file_handler.setFormatter(__formatter) | ||
# Console logger | ||
__console_handler = StreamHandler(stdout) | ||
def get_logger(): | ||
__file_handler = RotatingFileHandler(get_log_file(), maxBytes=10 * MB, backupCount=5, encoding=DEFAULT_ENCODING) | ||
__fmt = '%(asctime)s - %(threadName)s(%(thread)d) - %(filename)s:%(lineno)s - %(levelname)s - %(message)s' | ||
__formatter = Formatter(__fmt) | ||
__file_handler.setFormatter(__formatter) | ||
# Console logger | ||
__console_handler = StreamHandler(stdout) | ||
|
||
# Final logger | ||
logger = getLogger(f'{PROJECT_NAME}Logger') | ||
logger.addHandler(__file_handler) | ||
logger.addHandler(__console_handler) | ||
logger.setLevel(DEBUG) | ||
# Final logger | ||
logger = getLogger(f'{PROJECT_NAME}Logger') | ||
logger.addHandler(__file_handler) | ||
logger.addHandler(__console_handler) | ||
logger.setLevel(DEBUG) | ||
return logger |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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