Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue-39 Logging changes #40

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions secretsanta/main/funs.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def make_santa_dict(dictionary: Dict[str, str], seed: Optional[int] = None,
np.random.seed(seed)

if len(dictionary) == 1:
# Despite this often being perceived as an anti-pattern, we want the exception to be shown in log files also.
logger.error("Only one person listed")
raise ValueError("Only one person listed")
if len(dictionary) <= 3:
Expand Down
4 changes: 3 additions & 1 deletion secretsanta/main/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def setup_logging(level: str = "ERROR"):
:param level: logging level
"""
name_file = f'secretsanta_{time.strftime("%Y%m%d-%H%M%S")}.log'
path_file = Path('./log_files/') / name_file
log_dir = Path("./log_files/")
log_dir.mkdir(exist_ok=True)
path_file = log_dir / name_file
logging.basicConfig(filename=path_file, level=level, format='%(asctime)s %(levelname)s %(message)s',
datefmt='%Y/%m/%d %I:%M:%S %p')
Loading