mirror of
https://github.com/log-chipper/chipper.git
synced 2026-06-11 09:13:23 -05:00
feat: first init
- Simple unix daemon - Python, Go, and C client
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import socket
|
||||
|
||||
class ChipperClient:
|
||||
def __init__(self, socket_path: str ="/tmp/chipper.sock", service: str = "myapp", source: str = "worker") -> None:
|
||||
self.socket_path = socket_path
|
||||
self.service = service
|
||||
self.source = source
|
||||
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
|
||||
|
||||
def log(self, level: str, msg: str) -> None:
|
||||
# level=info service=pyapp source=worker msg="something"
|
||||
line = f'level={level} service={self.service} source={self.source} msg="{msg}"'
|
||||
self.sock.sendto(line.encode("utf-8"), self.socket_path)
|
||||
|
||||
def close(self) -> None:
|
||||
self.sock.close()
|
||||
Reference in New Issue
Block a user