-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtestharness.py
executable file
·44 lines (32 loc) · 1.03 KB
/
testharness.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
#!/usr/bin/env python3
import logging
import socket
import os
from time import sleep
import seqlog
server_url = os.getenv("SEQ_SERVER_URL", "http://localhost:5341/")
api_key = os.getenv("SEQ_API_KEY", "")
print("Logging to Seq server '{}' (API key = '{}').".format(server_url, api_key))
log_handler = seqlog.log_to_seq(
server_url,
api_key,
level=logging.INFO,
auto_flush_timeout=0.2,
additional_handlers=[logging.StreamHandler()],
override_root_logger=True
)
print("Running...")
logging.info("Hi, {name}. {greeting}", name="Root logger", greeting="Nice to meet you")
logger1 = logging.getLogger("A")
logger1.info("Hi, {name}! {greeting}", name="world", greeting=b"Nice to meet you")
logger2 = logging.getLogger("A.B")
logger2.info("Bye, {name}! {greeting}", name=b"moon", greeting="Nice to meet you")
logger3 = logging.getLogger("C")
logger3.info("By, %s!", "moon")
try:
raise Exception("Hello world!")
except:
logger1.error("Encountered an error!", exc_info=1)
print("Sleeping...")
sleep(0.5)
print("Done.")