Log Management
Lovrabet CLI automatically records every command you execute, like an "operation history". These logs are very useful when encountering problems.
Why Do We Need Logs?
Imagine these scenarios:
- API pull worked fine yesterday, but fails today
- Build time is getting longer, but don't know what's slow
- Need to share error messages with colleagues
Logs help you solve these problems!
How to Use
View Logs
lovrabet logs
This displays recent operation records, including:
- What commands you executed
- When they were executed
- Execution results
- How long they took
Clear Logs
lovrabet logs --clear
When log files are too large or you want to start recording fresh, you can clear all logs.
What Information Do Logs Contain?
Each log entry includes the following information:
| Field | Description | Example |
|---|---|---|
timestamp | Execution time | 2024-09-18 14:30:25 |
level | Log level | info, success, error, warn |
command | Executed command | start, build, api-pull |
message | Operation description | Development server started successfully |
duration | Duration (milliseconds) | 1500 |
details | Detailed information | Error stack, configuration info, etc. |
Log Level Description
- 🟢 info: General information, e.g., "Pulling API"
- ✅ success: Successful operation, e.g., "Page created successfully"
- ⚠️ warn: Warning information, e.g., "Configuration missing, using default"
- ❌ error: Error information, e.g., "Login failed"
Practical Scenarios
1️⃣ Troubleshooting
When a command fails, logs help you quickly locate the problem:
# View logs after build failure
lovrabet logs
# You'll see information like:
# [ERROR] build failed: Module not found: 'missing-package'
# [INFO] Build duration: 3500ms
2️⃣ Performance Analysis
By comparing duration across different periods, you can discover performance issues:
# View recent build times
lovrabet logs | grep "build"
# Example output:
# 2024-09-15: build success (2500ms)
# 2024-09-16: build success (3200ms)
# 2024-09-17: build success (4800ms) # Noticeably slower!
3️⃣ Team Collaboration
When encountering problems, you can share relevant log information with colleagues:
# Export last 10 log entries
lovrabet logs | tail -10
# Or directly share the .lovrabet.log file
Log File Location
Log files are saved in .lovrabet.log in the project root directory.
# View log file location
ls -la .lovrabet.log
# View file content directly (not recommended, format is hard to read)
cat .lovrabet.log
Note: Log file is in JSON Lines format, viewing directly may not be very readable. Recommended to use
lovrabet logscommand.
Best Practices
1. Regular Cleanup
Log files grow over time, recommended to clean regularly:
# Clean old logs weekly
lovrabet logs --clear
2. Check Logs When Errors Occur
Any command failure, check logs first:
# Immediately view after command failure
lovrabet logs
3. Preserve Key Information
When encountering hard-to-reproduce issues, backup logs:
# Backup current logs
cp .lovrabet.log .lovrabet.log.backup
FAQ
Log file too large, what to do?
Clear directly:
lovrabet logs --clear
Logs not displaying, what to do?
Check if you're in project root directory:
# Confirm in project root
ls .lovrabetrc
# If this file doesn't exist, you're not in a Lovrabet project
cd /path/to/your/project
Want to view other project's logs, what to do?
Need to switch to corresponding project directory:
cd /path/to/other/project
lovrabet logs