English | 简体中文
A lightweight error log collection tool written in Go. Aggregate error logs from multiple projects onto a single page, organized by date with pagination, and leverage DeepSeek to automatically analyze error causes — so you can spot and fix issues before your clients even notice.
This project has been parsed by Zread. Click to view an AI-generated project overview.
| List | Details |
|---|---|
![]() |
![]() |
- Centralized Management: Error logs from multiple projects in one place, auto-organized by date
- AI Analysis: Integrated DeepSeek with streaming output for error diagnosis and fix suggestions
- Dark Mode: Light / Dark / System three theme options
- Auto Cleanup: Background task periodically purges expired logs, retention days configurable
- BasicAuth Protection: Optional HTTP basic authentication to prevent unauthorized access
- Single Binary Deployment: Compiles to a single executable, copy and run anywhere
Download the latest release from Releases, extract, and run:
chmod +x ./app
./app -port=9999 -retain=7 -user=admin -pass=123123Visit http://YOUR_SERVER_IP:9999/read to view the log page.
git clone https://github.com/zxc7563598/oh-shit-logger.git
cd oh-shit-logger
go build -o ./app .
./app -port=9999| Flag | Description | Default |
|---|---|---|
-port |
Server port | 9999 |
-retain |
Log retention days | 7 |
-user |
BasicAuth username | - |
-pass |
BasicAuth password | - |
Warning
BasicAuth is disabled when both -user and -pass are omitted. This is not recommended in production.
Set it via the "Configure DeepSeek API Key" button in the web UI (only displays a masked version, never exposes the saved key), or manually create config.json:
{
"api_key": "sk-xxxxxxxxxxxxxxxx"
}We recommend using php-lazylog, a companion PHP Composer library that automatically reports exceptions to oh-shit-logger — no manual integration required.
To integrate manually, format errors as JSON in your exception handler and POST to the /write endpoint:
/**
* Format a Throwable as a standard JSON string.
* POST to oh-shit-logger's /write endpoint.
*/
function formatThrowable(Throwable $e, array $context = []): string
{
$trace = array_map(static function ($t) {
return [
'file' => $t['file'] ?? null,
'line' => $t['line'] ?? null,
'function' => $t['function'] ?? null,
'class' => $t['class'] ?? null,
];
}, $e->getTrace());
return json_encode([
'uuid' => bin2hex(random_bytes(8)),
'project' => 'your-project-name',
'level' => 'error',
'timestamp' => date('c'),
'message' => $e->getMessage(),
'code' => $e->getCode(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => $trace,
'context' => (object) $context,
'server' => [
'hostname' => gethostname() ?: 'unknown',
'ip' => $_SERVER['SERVER_ADDR'] ?? '127.0.0.1',
'php_version' => PHP_VERSION,
],
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}
// Report the error
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'http://YOUR_SERVER_IP:9999/write',
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => formatThrowable($exception, [
'module' => 'user-center',
'action' => 'login',
]),
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);Note
Only report fatal errors and uncaught exceptions to avoid overwhelming the logs.
| Method | Path | Description |
|---|---|---|
POST |
/write |
Submit an error log |
GET |
/read?date=2024-01-01&page=1 |
View logs (Web UI, BasicAuth) |
DELETE |
/delete?uuid=xxx&date=2024-01-01 |
Delete a log entry |
GET |
/apikey |
Get API key status (masked, never exposes full key) |
POST |
/apikey |
Save DeepSeek API Key |
POST |
/chat-stream |
AI streaming analysis (SSE) |
oh-shit-logger/
├── main.go # Entry point, route registration
├── config/ # Configuration (CLI flags + config.json)
├── handlers/ # HTTP handlers (write / read / delete / chat / apikey)
├── middleware/ # HTTP middleware (BasicAuth)
├── models/ # Data models
├── storage/ # Log storage (per-date files, JSON Lines)
├── cleanup/ # Background expired log cleanup
├── templates/ # HTML templates
├── static/ # Static assets
└── data/ # Log data directory (auto-created at runtime)
Issues and suggestions are welcome via GitHub Issues.
If this project helps you, please give it a ⭐️ Star!

