From c29ad2f5be32b9611c650841fd5ddc4bada1757f Mon Sep 17 00:00:00 2001 From: agatha Date: Fri, 10 Nov 2023 22:46:54 -0500 Subject: [PATCH] Monitor and log CreateEvents --- main.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 71bcff4..d5dc970 100644 --- a/main.py +++ b/main.py @@ -1,16 +1,18 @@ """GitMon""" +import time +from loguru import logger from gitmon.api import GitHubApi from gitmon.logger import setup_logger from config import token -def print_event(event): +def log_event(event): event_type = event.get('type') repo = event.get('repo') actor = event.get('actor') - print(f'{event_type}:\t{repo["name"]}, {actor["login"]}') + logger.info(f'{event_type}:\t{repo["name"]}, {actor["login"]}') def main(): @@ -18,9 +20,13 @@ def main(): setup_logger() api = GitHubApi(token) - events = api.get_events() - for event in events: - print_event(event) + while True: + events = api.get_events() + for event in events: + if event['type'] == 'CreateEvent': + log_event(event) + + time.sleep(10) if __name__ == '__main__':