mirror of
https://git.juggalol.com/agatha/gitmon.git
synced 2024-11-22 23:46:42 +00:00
Monitor and log CreateEvents
This commit is contained in:
parent
5c4fb60ff2
commit
c29ad2f5be
12
main.py
12
main.py
@ -1,16 +1,18 @@
|
|||||||
"""GitMon"""
|
"""GitMon"""
|
||||||
|
import time
|
||||||
|
from loguru import logger
|
||||||
from gitmon.api import GitHubApi
|
from gitmon.api import GitHubApi
|
||||||
from gitmon.logger import setup_logger
|
from gitmon.logger import setup_logger
|
||||||
|
|
||||||
from config import token
|
from config import token
|
||||||
|
|
||||||
|
|
||||||
def print_event(event):
|
def log_event(event):
|
||||||
event_type = event.get('type')
|
event_type = event.get('type')
|
||||||
repo = event.get('repo')
|
repo = event.get('repo')
|
||||||
actor = event.get('actor')
|
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():
|
def main():
|
||||||
@ -18,9 +20,13 @@ def main():
|
|||||||
setup_logger()
|
setup_logger()
|
||||||
api = GitHubApi(token)
|
api = GitHubApi(token)
|
||||||
|
|
||||||
|
while True:
|
||||||
events = api.get_events()
|
events = api.get_events()
|
||||||
for event in events:
|
for event in events:
|
||||||
print_event(event)
|
if event['type'] == 'CreateEvent':
|
||||||
|
log_event(event)
|
||||||
|
|
||||||
|
time.sleep(10)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user