-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from MEHRSHAD-MIRSHEKARY/feature/optional-formats
Feature/optional formats
- Loading branch information
Showing
5 changed files
with
118 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .format_options import FORMAT_OPTIONS |
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,15 @@ | ||
FORMAT_OPTIONS = { | ||
1: "%(levelname)s | %(asctime)s | %(module)s | %(message)s", | ||
2: "%(levelname)s | %(asctime)s | %(message)s", | ||
3: "%(levelname)s | %(message)s", | ||
4: "%(asctime)s - %(name)s - %(levelname)s - %(message)s", | ||
5: "%(levelname)s | %(message)s | [in %(pathname)s:%(lineno)d]", | ||
6: "%(asctime)s | %(levelname)s | %(message)s", | ||
7: "%(levelname)s | %(asctime)s | in %(module)s: %(message)s", | ||
8: "%(levelname)s | %(message)s | [%(filename)s:%(lineno)d]", | ||
9: "[%(asctime)s] | %(levelname)s | in %(module)s: %(message)s", | ||
10: "%(asctime)s | %(processName)s | %(name)s | %(levelname)s | %(message)s", | ||
11: "%(asctime)s | %(threadName)s | %(name)s | %(levelname)s | %(message)s", | ||
12: "%(levelname)s | [%(asctime)s] | (%(filename)s:%(lineno)d) | %(message)s", | ||
13: "%(levelname)s | [%(asctime)s] | {%(name)s} | (%(filename)s:%(lineno)d): %(message)s", | ||
} |
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,20 +1,37 @@ | ||
from django_logging.settings.conf import LogConfig, LogManager | ||
|
||
from typing import List | ||
from typing import List, Optional, Union, Dict | ||
|
||
|
||
def set_logging(log_levels: List[str], | ||
log_dir: str, | ||
log_email_notifier_enable: bool, | ||
log_email_notifier_log_levels: List[str]): | ||
def set_logging( | ||
log_levels: List[str], | ||
log_dir: str, | ||
log_file_formats: Dict[str, Union[int, str]], | ||
console_level: str, | ||
console_format: Optional[Union[int, str]], | ||
log_date_format: str, | ||
log_email_notifier_enable: bool, | ||
log_email_notifier_log_levels: List[str], | ||
log_email_notifier_log_format: Union[int, str] | ||
): | ||
""" | ||
Sets up the logging configuration. | ||
Args: | ||
log_levels (List[str]): A list of log levels to configure. | ||
log_dir (str): The directory where log files will be stored. | ||
""" | ||
log_config = LogConfig(log_levels, log_dir, log_email_notifier_enable, log_email_notifier_log_levels) | ||
log_config = LogConfig( | ||
log_levels, | ||
log_dir, | ||
log_file_formats, | ||
console_level, | ||
console_format, | ||
log_date_format, | ||
log_email_notifier_enable, | ||
log_email_notifier_log_levels, | ||
log_email_notifier_log_format | ||
) | ||
log_manager = LogManager(log_config) | ||
log_manager.create_log_files() | ||
log_manager.set_conf() |