From 73e5a63565151e7934b09801feaffc03dd58fcc3 Mon Sep 17 00:00:00 2001 From: agatha Date: Sat, 11 Nov 2023 14:34:14 -0500 Subject: [PATCH] Add custom log levels. Closes #1 --- gitmon/logger.py | 3 +++ main.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gitmon/logger.py b/gitmon/logger.py index 95b0dfe..1f796fa 100644 --- a/gitmon/logger.py +++ b/gitmon/logger.py @@ -2,6 +2,9 @@ import sys from loguru import logger +logger.level('CREATE', no=34, color='') +logger.level('DELETE', no=35, color='') + def setup_logger(): logger.remove() diff --git a/main.py b/main.py index 08465e1..00f2867 100644 --- a/main.py +++ b/main.py @@ -16,9 +16,9 @@ def log_event(event): actor = event.get('actor') if event_type == 'DeleteEvent': - logger.error(f'{event_type}:\thttps://github.com/{repo["name"]}, {actor["login"]}') + logger.log('DELETE', f'{event_type}:\thttps://github.com/{repo["name"]}, {actor["login"]}') else: - logger.info(f'{event_type}:\thttps://github.com/{repo["name"]}, {actor["login"]}') + logger.log('CREATE', f'{event_type}:\thttps://github.com/{repo["name"]}, {actor["login"]}') def main():