65 lines
1.2 KiB
Plaintext
65 lines
1.2 KiB
Plaintext
## How to use the logger
|
|
|
|
### GUI Interactions:
|
|
|
|
```python
|
|
ActivityLog.log_gui_interaction(
|
|
action="view_paper_details",
|
|
description="User viewed paper details",
|
|
paper_id=123
|
|
)
|
|
```
|
|
|
|
### Configuration Changes:
|
|
|
|
```python
|
|
ActivityLog.log_gui_interaction(
|
|
action="view_paper_details",
|
|
description="User viewed paper details",
|
|
paper_id=123
|
|
)
|
|
```
|
|
|
|
### Scraper Commands:
|
|
|
|
```python
|
|
ActivityLog.log_scraper_command(
|
|
action="start_scraper",
|
|
status="running"
|
|
)
|
|
```
|
|
|
|
### Scraper Activities:
|
|
|
|
```python
|
|
ActivityLog.log_scraper_activity(
|
|
action="download_paper",
|
|
paper_id=123,
|
|
status="success",
|
|
description="Paper downloaded successfully",
|
|
file_path="/papers/123.pdf"
|
|
)
|
|
```
|
|
|
|
### Error Logging:
|
|
|
|
```python
|
|
# Simple error
|
|
ActivityLog.log_error(
|
|
error_message="Failed to connect to API",
|
|
severity=ErrorSeverity.WARNING.value,
|
|
source="api_client"
|
|
)
|
|
|
|
# Logging an exception
|
|
try:
|
|
result = some_risky_operation()
|
|
except Exception as e:
|
|
ActivityLog.log_error(
|
|
error_message="Operation failed",
|
|
exception=e,
|
|
severity=ErrorSeverity.ERROR.value,
|
|
source="data_processor",
|
|
paper_id=paper_id
|
|
)
|
|
``` |