Skip to content

Commit 86bf54c

Browse files
authored
Add system logging functionality and update README for clarity (#11)
1 parent 559f041 commit 86bf54c

2 files changed

Lines changed: 54 additions & 8 deletions

File tree

README.md

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,41 @@ flowchart TD
175175
Manufacturer2 --> Series2["Robot Series"]
176176
Manufacturer3 --> Series3["Robot Series"]
177177
Manufacturer1 --> n3["Robot Series"]
178-
style CommTemplate color:#D50000
179-
style SocketController stroke:#000000
180-
style PLCController stroke:#000000
181-
style SerialController stroke:#000000
182-
style CtrlTemplate color:#D50000
183-
style Manufacturer2 stroke:#000000
184-
style Manufacturer3 stroke:#000000
178+
```
179+
180+
### System Logging
181+
182+
By default, the library will show the outgoing commands and incoming data. An example can be seen below:
183+
184+
```console
185+
2025-02-12 13:18:11,350 - INFO - Connected to ElephantRobotics(192.168.1.159:5001)(SEND/RECV)
186+
2025-02-12 13:18:11,351 - SEND - Sending command: power_on()
187+
2025-02-12 13:18:11,954 - RECV - Received response: [ok]
188+
2025-02-12 13:18:11,954 - SEND - Sending command: state_on()
189+
2025-02-12 13:18:12,647 - RECV - Received response: [ok]
190+
2025-02-12 13:18:12,647 - SEND - Sending command: get_angles()
191+
2025-02-12 13:18:12,663 - RECV - Received response: get_angles:[0.290562,-95.891321,-74.804509,-162.949219,1.845703,12.041016]
192+
2025-02-12 13:18:12,663 - SEND - Sending command: task_stop()
193+
2025-02-12 13:18:13,466 - RECV - Received response: [ok]
194+
2025-02-12 13:18:13,466 - SEND - Sending command: state_off()
195+
2025-02-12 13:18:14,176 - RECV - Received response: [ok]
196+
2025-02-12 13:18:14,176 - SEND - Sending command: power_off()
197+
2025-02-12 13:18:14,176 - RECV - Received response: [ok]
198+
2025-02-12 13:18:14,176 - INFO - Disconnected from ElephantRobotics
199+
```
200+
201+
#### Disabling
202+
203+
```python
204+
from armctl import *
205+
Logger.disable()
206+
```
207+
208+
#### Re-Enabling
209+
210+
```python
211+
from armctl import *
212+
Logger.enable()
185213
```
186214

187215
## Under Development

armctl/__init__.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,22 @@
3232

3333
"Vention",
3434
"Jaka",
35-
]
35+
36+
"Logger",
37+
]
38+
39+
class Logger:
40+
"""Global logger utility for armctl."""
41+
@staticmethod
42+
def disable():
43+
"""Disables logging."""
44+
import logging
45+
# Disable all logging at and below the CRITICAL level
46+
logging.disable(logging.CRITICAL)
47+
48+
@staticmethod
49+
def enable():
50+
"""Enables logging."""
51+
import logging
52+
# Re-enable logging to its previous state
53+
logging.disable(logging.NOTSET)

0 commit comments

Comments
 (0)