Adafruit_Learning_System_Gu.../CircuitPython_Logger/aio_test/code.py
2021-08-18 13:31:55 -04:00

30 lines
915 B
Python

import time
import random
from adafruit_pyportal import PyPortal
from aio_handler import AIOHandler
import adafruit_logging as logging
device=PyPortal()
l = logging.getLogger('aio')
l.addHandler(AIOHandler('test'), device)
def go():
while True:
t = random.randint(1, 5)
if t == 1:
print('debug')
l.debug("debug message: %d", random.randint(0, 1000))
elif t == 2:
print('info')
l.info("info message: %d", random.randint(0, 1000))
elif t == 3:
print('warning')
l.warning("warning message: %d", random.randint(0, 1000))
elif t == 4:
print('error')
l.error("error message: %d", random.randint(0, 1000))
elif t == 5:
print('critical')
l.critical("critical message: %d", random.randint(0, 1000))
time.sleep(5.0 + (random.random() * 5.0))