Add custom log levels. Closes #1

This commit is contained in:
agatha 2023-11-11 14:34:14 -05:00
parent bf34654a46
commit 73e5a63565
2 changed files with 5 additions and 2 deletions

View File

@ -2,6 +2,9 @@
import sys import sys
from loguru import logger from loguru import logger
logger.level('CREATE', no=34, color='<green>')
logger.level('DELETE', no=35, color='<red>')
def setup_logger(): def setup_logger():
logger.remove() logger.remove()

View File

@ -16,9 +16,9 @@ def log_event(event):
actor = event.get('actor') actor = event.get('actor')
if event_type == 'DeleteEvent': 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: 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(): def main():