-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdemo_logging.py
49 lines (35 loc) · 1.08 KB
/
demo_logging.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
"""
demo_logging -- simple demo of blink1 library with logging
run with:
DEBUGLBLINK1=1 python3 ./blink1_demo/demo_logging.py
"""
from blink1.blink1 import Blink1
import time,sys
import logging
logging.basicConfig()
#logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO)
#logging.basicConfig(filename="test.log", format='%(filename)s: %(message)s', filemode='w')
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)
log.info("hello info")
log.debug("hello debug")
log.warning("hello warning")
log.error("hello error")
try:
blink1 = Blink1()
except:
log.error("no blink1 found")
sys.exit()
log.info("blink(1) found")
log.info(" serial number: " + blink1.get_serial_number())
log.info(" firmware version: " + blink1.get_version())
log.info("fading to #ffffff")
blink1.fade_to_rgb(1000, 255, 255, 255)
log.info("waiting 2.5 seconds, unplug to check error raising...");
time.sleep(2.5)
log.info("fading to #000000")
blink1.fade_to_color(1000, 'black')
log.info("closing connection to blink(1)")
blink1.close()
log.info("done")