logmachine 2.3.0__tar.gz → 2.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {logmachine-2.3.0 → logmachine-2.3.1}/PKG-INFO +8 -9
- {logmachine-2.3.0 → logmachine-2.3.1}/README.md +7 -8
- {logmachine-2.3.0 → logmachine-2.3.1}/logmachine/main.py +19 -3
- {logmachine-2.3.0 → logmachine-2.3.1}/logmachine.egg-info/PKG-INFO +8 -9
- {logmachine-2.3.0 → logmachine-2.3.1}/pyproject.toml +1 -1
- {logmachine-2.3.0 → logmachine-2.3.1}/LICENSE +0 -0
- {logmachine-2.3.0 → logmachine-2.3.1}/logmachine/__init__.py +0 -0
- {logmachine-2.3.0 → logmachine-2.3.1}/logmachine.egg-info/SOURCES.txt +0 -0
- {logmachine-2.3.0 → logmachine-2.3.1}/logmachine.egg-info/dependency_links.txt +0 -0
- {logmachine-2.3.0 → logmachine-2.3.1}/logmachine.egg-info/top_level.txt +0 -0
- {logmachine-2.3.0 → logmachine-2.3.1}/setup.cfg +0 -0
- {logmachine-2.3.0 → logmachine-2.3.1}/tests/test_core.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: logmachine
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.1
|
|
4
4
|
Summary: Collaborative, beautiful logging system for distributed developers
|
|
5
5
|
Author-email: Mugabo Gusenga <mugabo@bufferpunk.com>
|
|
6
6
|
Project-URL: Homepage, https://logmachine.bufferpunk.com
|
|
@@ -80,10 +80,8 @@ To use your own central logging server, provide the configuration as shown below
|
|
|
80
80
|
logger_config = {
|
|
81
81
|
"url": "https://logmachine.bufferpunk.com", # Base server URL
|
|
82
82
|
"room": "team_alpha", # Your organization or room
|
|
83
|
-
"endpoint": "/api/logs", # Optional, defaults to /api/logs
|
|
84
|
-
"headers": {"Authorization": "Bearer token"},
|
|
85
|
-
"socketio": True, # Set False to use HTTP
|
|
86
|
-
"socketio_path": "/api/socket.io/" # Optional
|
|
83
|
+
"endpoint": "/api/logs", # Optional, defaults to /api/logs. Use /api/socket.io/ for Socket.IO transport.
|
|
84
|
+
"headers": {"Authorization": "Bearer token"}, # The central server should know your username based on the token you provide here. This is optional and depends on your central server's authentication mechanism.
|
|
87
85
|
}
|
|
88
86
|
logger = LogMachine("with_central", debug_level=0, central=logger_config, socketio=True)
|
|
89
87
|
logger.success("Central logging is working!")
|
|
@@ -140,9 +138,12 @@ for entry in json_logs:
|
|
|
140
138
|
|
|
141
139
|
## 📡 Central Server Compatibility
|
|
142
140
|
|
|
143
|
-
To use Socket.IO, your central server must support
|
|
141
|
+
To use Socket.IO, your central server must support this event:
|
|
144
142
|
|
|
145
143
|
* `log`: Receives log payloads: `{ room: string, data: object }`
|
|
144
|
+
|
|
145
|
+
For central username resolution, your server should expose an endpoint like:
|
|
146
|
+
|
|
146
147
|
* `GET /api/get_username?base=localname`: Returns `{ "username": "..." }`
|
|
147
148
|
|
|
148
149
|
---
|
|
@@ -167,10 +168,8 @@ To use Socket.IO, your central server must support these events:
|
|
|
167
168
|
| --------------- | ------ | -------------------------------------------------- |
|
|
168
169
|
| `url` | `str` | Central server base URL |
|
|
169
170
|
| `room` | `str` | Logical group or org name |
|
|
170
|
-
| `endpoint` | `str` | HTTP endpoint for POST logs (default: `/api/logs`) |
|
|
171
|
+
| `endpoint` | `str` | HTTP endpoint for POST logs (default: `/api/logs` or `/api/socket.io/` for Socket.IO) |
|
|
171
172
|
| `headers` | `dict` | Extra headers to send (e.g. auth token) |
|
|
172
|
-
| `socketio` | `bool` | Whether to use Socket.IO instead of HTTP |
|
|
173
|
-
| `socketio_path` | `str` | Path to socket.io on the server |
|
|
174
173
|
|
|
175
174
|
---
|
|
176
175
|
|
|
@@ -62,10 +62,8 @@ To use your own central logging server, provide the configuration as shown below
|
|
|
62
62
|
logger_config = {
|
|
63
63
|
"url": "https://logmachine.bufferpunk.com", # Base server URL
|
|
64
64
|
"room": "team_alpha", # Your organization or room
|
|
65
|
-
"endpoint": "/api/logs", # Optional, defaults to /api/logs
|
|
66
|
-
"headers": {"Authorization": "Bearer token"},
|
|
67
|
-
"socketio": True, # Set False to use HTTP
|
|
68
|
-
"socketio_path": "/api/socket.io/" # Optional
|
|
65
|
+
"endpoint": "/api/logs", # Optional, defaults to /api/logs. Use /api/socket.io/ for Socket.IO transport.
|
|
66
|
+
"headers": {"Authorization": "Bearer token"}, # The central server should know your username based on the token you provide here. This is optional and depends on your central server's authentication mechanism.
|
|
69
67
|
}
|
|
70
68
|
logger = LogMachine("with_central", debug_level=0, central=logger_config, socketio=True)
|
|
71
69
|
logger.success("Central logging is working!")
|
|
@@ -122,9 +120,12 @@ for entry in json_logs:
|
|
|
122
120
|
|
|
123
121
|
## 📡 Central Server Compatibility
|
|
124
122
|
|
|
125
|
-
To use Socket.IO, your central server must support
|
|
123
|
+
To use Socket.IO, your central server must support this event:
|
|
126
124
|
|
|
127
125
|
* `log`: Receives log payloads: `{ room: string, data: object }`
|
|
126
|
+
|
|
127
|
+
For central username resolution, your server should expose an endpoint like:
|
|
128
|
+
|
|
128
129
|
* `GET /api/get_username?base=localname`: Returns `{ "username": "..." }`
|
|
129
130
|
|
|
130
131
|
---
|
|
@@ -149,10 +150,8 @@ To use Socket.IO, your central server must support these events:
|
|
|
149
150
|
| --------------- | ------ | -------------------------------------------------- |
|
|
150
151
|
| `url` | `str` | Central server base URL |
|
|
151
152
|
| `room` | `str` | Logical group or org name |
|
|
152
|
-
| `endpoint` | `str` | HTTP endpoint for POST logs (default: `/api/logs`) |
|
|
153
|
+
| `endpoint` | `str` | HTTP endpoint for POST logs (default: `/api/logs` or `/api/socket.io/` for Socket.IO) |
|
|
153
154
|
| `headers` | `dict` | Extra headers to send (e.g. auth token) |
|
|
154
|
-
| `socketio` | `bool` | Whether to use Socket.IO instead of HTTP |
|
|
155
|
-
| `socketio_path` | `str` | Path to socket.io on the server |
|
|
156
155
|
|
|
157
156
|
---
|
|
158
157
|
|
|
@@ -53,6 +53,14 @@ class HTTPTransporter(logging.StreamHandler):
|
|
|
53
53
|
super().__init__()
|
|
54
54
|
self.parse_log = kwargs.get('log_parser')
|
|
55
55
|
self.central = kwargs.get('central', None)
|
|
56
|
+
self.session = requests.Session() # Use a session for connection pooling
|
|
57
|
+
|
|
58
|
+
def close(self):
|
|
59
|
+
try:
|
|
60
|
+
self.session.close()
|
|
61
|
+
except Exception:
|
|
62
|
+
pass
|
|
63
|
+
return super().close()
|
|
56
64
|
|
|
57
65
|
def emit(self, record):
|
|
58
66
|
try:
|
|
@@ -64,9 +72,9 @@ class HTTPTransporter(logging.StreamHandler):
|
|
|
64
72
|
|
|
65
73
|
log_data = self.parse_log(msg)
|
|
66
74
|
if log_data:
|
|
67
|
-
response =
|
|
75
|
+
response = self.session.post(
|
|
68
76
|
f"{self.central.get('url', '') + self.central.get('endpoint', '/api/logs')}?room={self.central.get('room', '')}",
|
|
69
|
-
json=log_data,
|
|
77
|
+
json=log_data, timeout=(3, 3),
|
|
70
78
|
headers={**self.central.get('headers', {}), 'Content-Type': 'application/json'}
|
|
71
79
|
)
|
|
72
80
|
if response.status_code != 200:
|
|
@@ -95,6 +103,14 @@ class SocketIOTransporter(logging.StreamHandler):
|
|
|
95
103
|
except Exception as e:
|
|
96
104
|
raise ConnectionError(f"Failed to connect to central server via SocketIO: {e}")
|
|
97
105
|
|
|
106
|
+
def close(self):
|
|
107
|
+
try:
|
|
108
|
+
if self.sio.connected:
|
|
109
|
+
self.sio.disconnect()
|
|
110
|
+
except Exception:
|
|
111
|
+
pass
|
|
112
|
+
return super().close()
|
|
113
|
+
|
|
98
114
|
def emit(self, record):
|
|
99
115
|
try:
|
|
100
116
|
msg = self.format(record)
|
|
@@ -204,7 +220,7 @@ class LogMachine(logging.Logger):
|
|
|
204
220
|
else:
|
|
205
221
|
get_login()
|
|
206
222
|
|
|
207
|
-
if 'socketio' in globals():
|
|
223
|
+
if 'socketio' not in globals():
|
|
208
224
|
ch = HTTPTransporter(log_parser=self.parse_log, central=self.central)
|
|
209
225
|
else:
|
|
210
226
|
ch = SocketIOTransporter(log_parser=self.parse_log, central=self.central)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: logmachine
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.1
|
|
4
4
|
Summary: Collaborative, beautiful logging system for distributed developers
|
|
5
5
|
Author-email: Mugabo Gusenga <mugabo@bufferpunk.com>
|
|
6
6
|
Project-URL: Homepage, https://logmachine.bufferpunk.com
|
|
@@ -80,10 +80,8 @@ To use your own central logging server, provide the configuration as shown below
|
|
|
80
80
|
logger_config = {
|
|
81
81
|
"url": "https://logmachine.bufferpunk.com", # Base server URL
|
|
82
82
|
"room": "team_alpha", # Your organization or room
|
|
83
|
-
"endpoint": "/api/logs", # Optional, defaults to /api/logs
|
|
84
|
-
"headers": {"Authorization": "Bearer token"},
|
|
85
|
-
"socketio": True, # Set False to use HTTP
|
|
86
|
-
"socketio_path": "/api/socket.io/" # Optional
|
|
83
|
+
"endpoint": "/api/logs", # Optional, defaults to /api/logs. Use /api/socket.io/ for Socket.IO transport.
|
|
84
|
+
"headers": {"Authorization": "Bearer token"}, # The central server should know your username based on the token you provide here. This is optional and depends on your central server's authentication mechanism.
|
|
87
85
|
}
|
|
88
86
|
logger = LogMachine("with_central", debug_level=0, central=logger_config, socketio=True)
|
|
89
87
|
logger.success("Central logging is working!")
|
|
@@ -140,9 +138,12 @@ for entry in json_logs:
|
|
|
140
138
|
|
|
141
139
|
## 📡 Central Server Compatibility
|
|
142
140
|
|
|
143
|
-
To use Socket.IO, your central server must support
|
|
141
|
+
To use Socket.IO, your central server must support this event:
|
|
144
142
|
|
|
145
143
|
* `log`: Receives log payloads: `{ room: string, data: object }`
|
|
144
|
+
|
|
145
|
+
For central username resolution, your server should expose an endpoint like:
|
|
146
|
+
|
|
146
147
|
* `GET /api/get_username?base=localname`: Returns `{ "username": "..." }`
|
|
147
148
|
|
|
148
149
|
---
|
|
@@ -167,10 +168,8 @@ To use Socket.IO, your central server must support these events:
|
|
|
167
168
|
| --------------- | ------ | -------------------------------------------------- |
|
|
168
169
|
| `url` | `str` | Central server base URL |
|
|
169
170
|
| `room` | `str` | Logical group or org name |
|
|
170
|
-
| `endpoint` | `str` | HTTP endpoint for POST logs (default: `/api/logs`) |
|
|
171
|
+
| `endpoint` | `str` | HTTP endpoint for POST logs (default: `/api/logs` or `/api/socket.io/` for Socket.IO) |
|
|
171
172
|
| `headers` | `dict` | Extra headers to send (e.g. auth token) |
|
|
172
|
-
| `socketio` | `bool` | Whether to use Socket.IO instead of HTTP |
|
|
173
|
-
| `socketio_path` | `str` | Path to socket.io on the server |
|
|
174
173
|
|
|
175
174
|
---
|
|
176
175
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|