{"id":24488096,"url":"https://github.com/naoray/laravel-github-monolog","last_synced_at":"2026-01-12T14:34:12.311Z","repository":{"id":271754707,"uuid":"914442542","full_name":"Naoray/laravel-github-monolog","owner":"Naoray","description":"Laravel log Channel for GitHub issues","archived":false,"fork":false,"pushed_at":"2025-03-26T13:18:44.000Z","size":194,"stargazers_count":91,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T08:17:13.984Z","etag":null,"topics":["github-issue","laravel","logging","monolog"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Naoray.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["naoray"]}},"created_at":"2025-01-09T15:53:45.000Z","updated_at":"2025-03-26T13:18:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"fbb53bad-9240-4faa-ac1a-5a09d939d64f","html_url":"https://github.com/Naoray/laravel-github-monolog","commit_stats":null,"previous_names":["naoray/laravel-github-monolog"],"tags_count":8,"template":false,"template_full_name":"spatie/package-skeleton-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Naoray%2Flaravel-github-monolog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Naoray%2Flaravel-github-monolog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Naoray%2Flaravel-github-monolog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Naoray%2Flaravel-github-monolog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Naoray","download_url":"https://codeload.github.com/Naoray/laravel-github-monolog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246049630,"owners_count":20715511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github-issue","laravel","logging","monolog"],"created_at":"2025-01-21T16:18:17.628Z","updated_at":"2026-01-12T14:34:12.287Z","avatar_url":"https://github.com/Naoray.png","language":"PHP","funding_links":["https://github.com/sponsors/naoray"],"categories":[],"sub_categories":[],"readme":"# Laravel GitHub Issue Logger\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/naoray/laravel-github-monolog.svg?style=flat-square)](https://packagist.org/packages/naoray/laravel-github-monolog)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/naoray/laravel-github-monolog/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/naoray/laravel-github-monolog/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/naoray/laravel-github-monolog/fix-php-code-style-issues.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/naoray/laravel-github-monolog/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/naoray/laravel-github-monolog.svg?style=flat-square)](https://packagist.org/packages/naoray/laravel-github-monolog)\n\nAutomatically create GitHub issues from your Laravel exceptions \u0026 logs. Perfect for smaller projects without the need for full-featured logging services.\n\n## Requirements\n\n- PHP ^8.3\n- Laravel ^11.37|^12.0\n- Monolog ^3.6\n\n## Features\n\n- ✨ Automatically create GitHub issues from Exceptions \u0026 Logs\n- 🔍 Group similar errors into single issues\n- 💬 Add comments to existing issues for recurring errors\n- 🏷️ Support customizable labels\n- 🎯 Smart deduplication to prevent issue spam\n- ⚡️ Buffered logging for better performance\n- 📝 Customizable issue templates\n- 🕵🏻‍♂️ Tracing Support (Request \u0026 User)\n\n## Showcase\n\nWhen an error occurs in your application, a GitHub issue is automatically created with comprehensive error information and stack trace:\n\n\u003cimg src=\"https://github.com/user-attachments/assets/bd1a7e9b-e1f3-43ed-b779-14fbaa974916\" width=\"800\" alt=\"issue raised\"\u003e\n\nThe issue appears in your repository with all the detailed information about the error:\n\n\u003cimg src=\"https://github.com/user-attachments/assets/0fe6e6d7-8ecd-4253-8c05-e8ba2025a536\" width=\"800\" alt=\"issue detail\"\u003e\n\nIf the same error occurs again, instead of creating a duplicate, a new comment is automatically added to track the occurrence:\n\n\u003cimg src=\"https://github.com/user-attachments/assets/c76fd583-63a9-49b8-a7fb-a6dcf2c00ee6\" width=\"800\" alt=\"comment added\"\u003e\n\n## Installation\n\nInstall with Composer:\n\n```bash\ncomposer require naoray/laravel-github-monolog\n```\n\n## Configuration\n\nAdd the GitHub logging channel to `config/logging.php`:\n\n```php\n'channels' =\u003e [\n    // ... other channels ...\n\n    'github' =\u003e [\n        // Required configuration\n        'driver' =\u003e 'custom',\n        'via' =\u003e \\Naoray\\LaravelGithubMonolog\\GithubIssueHandlerFactory::class,\n        'repo' =\u003e env('GITHUB_REPO'),    // Format: \"username/repository\"\n        'token' =\u003e env('GITHUB_TOKEN'),  // Your GitHub Personal Access Token\n\n        // Optional configuration\n        'level' =\u003e env('LOG_LEVEL', 'error'),\n        'labels' =\u003e ['bug'],\n    ],\n]\n```\n\nAdd these variables to your `.env` file:\n\n```\nGITHUB_REPO=username/repository\nGITHUB_TOKEN=your-github-personal-access-token\n```\n\nYou can use the `github` log channel as your default `LOG_CHANNEL` or add it as part of your stack in `LOG_STACK`.\n\n### Getting a GitHub Token\n\nTo obtain a Personal Access Token:\n\n1. Go to [Generate a new token](https://github.com/settings/tokens/new?description=Laravel%20GitHub%20Issue%20Logger\u0026scopes=repo) (this link pre-selects the required scopes)\n2. Review the pre-selected scopes (the `repo` scope should be checked)\n3. Click \"Generate token\"\n4. Copy the token immediately (you won't be able to access it again after leaving the page)\n5. Add it to your `.env` file as `GITHUB_TOKEN`\n\n\u003e **Note**: The token requires the `repo` scope to create issues in both public and private repositories.\n\n## Usage\n\nWhenever an exception is thrown it will be logged as an issue to your repository.\n\nYou can also use it like any other Laravel logging channel:\n\n```php\n// Single channel\nLog::channel('github')-\u003eerror('Something went wrong!');\n\n// Or as part of a stack\nLog::stack(['daily', 'github'])-\u003eerror('Something went wrong!');\n```\n\n## Advanced Configuration\n\n### Customizing Templates\n\nThe package uses Markdown templates to format issues and comments. You can customize these templates by publishing them:\n\n```bash\nphp artisan vendor:publish --tag=\"github-monolog-views\"\n```\n\nThis will copy the templates to `resources/views/vendor/github-monolog/` where you can modify them:\n\n- `issue.md`: Template for new issues\n- `comment.md`: Template for comments on existing issues\n- `previous_exception.md`: Template for previous exceptions in the chain\n\n\u003e **Important**:\n\u003e - The templates use HTML comments as section markers (e.g. `\u003c!-- stacktrace:start --\u003e` and `\u003c!-- stacktrace:end --\u003e`). These markers are used to intelligently remove empty sections from the rendered output. Please keep these markers intact when customizing the templates.\n\u003e - If you've previously published and customized templates, you may need to republish them to get the latest structure with triage headers and collapsible sections. Compare your custom templates with the new defaults and migrate any customizations.\n\nAvailable template variables:\n- `{level}`: Log level (error, warning, etc.)\n- `{message}`: The error message or log content\n- `{class}`: Exception class name\n- `{signature}`: Internal signature used for deduplication\n- `{timestamp}`: Timestamp when the error occurred (format: Y-m-d H:i:s)\n- `{environment_name}`: Environment name (e.g., production, staging) from APP_ENV\n- `{route_summary}`: HTTP method and path (e.g., \"GET /api/users\")\n- `{user_summary}`: User ID or \"Unauthenticated\"\n- `{simplified_stack_trace}`: A cleaned up stack trace\n- `{full_stack_trace}`: The complete stack trace\n- `{previous_exceptions}`: Details of any previous exceptions\n- `{environment}`: Full environment data (JSON)\n- `{request}`: Full request data (JSON)\n- `{route}`: Full route data (JSON)\n- `{user}`: Full user data (JSON)\n- `{queries}`: Recent database queries\n- `{job}`: Job context data (JSON)\n- `{command}`: Command context data (JSON)\n- `{outgoing_requests}`: Outgoing HTTP requests\n- `{session}`: Session data (JSON)\n- `{context}`: Additional context data (JSON)\n- `{extra}`: Extra log data (JSON)\n\n### Deduplication\n\nGroup similar errors to avoid duplicate issues. The package uses Laravel's cache system for deduplication storage.\n\n```php\n'github' =\u003e [\n    // ... basic config from above ...\n    'deduplication' =\u003e [\n        'time' =\u003e 60,        // Time window in seconds - how long to wait before creating a new issue\n        'store' =\u003e null,     // Uses your default cache store (from cache.default)\n        'prefix' =\u003e 'dedup', // Prefix for cache keys\n    ],\n]\n```\n\nFor cache store configuration, refer to the [Laravel Cache documentation](https://laravel.com/docs/cache).\n\n### Buffering\n\nBuffer logs to reduce GitHub API calls. Customize the buffer size and overflow behavior to optimize performance:\n\n```php\n'github' =\u003e [\n    // ... basic config from above ...\n    'buffer' =\u003e [\n        'limit' =\u003e 0,        // Maximum records in buffer (0 = unlimited, flush on shutdown)\n        'flush_on_overflow' =\u003e true,  // When limit is reached: true = flush all, false = remove oldest\n    ],\n]\n```\n\nWhen buffering is active:\n- Logs are collected in memory until flushed\n- Buffer is automatically flushed on application shutdown\n- When limit is reached:\n  - With `flush_on_overflow = true`: All records are flushed\n  - With `flush_on_overflow = false`: Only the oldest record is removed\n\n### Tracing\n\n\u003e **Note:** Tracing is opt-in and disabled by default. To enable tracing capabilities, you must add the `tracing` configuration to your `config/logging.php` file under the `github` channel configuration.\n\nThe package includes optional tracing capabilities that allow you to track requests, user data, queries, and more in your logs. Enable this feature through your configuration:\n\n```php\n'tracing' =\u003e [\n    'enabled' =\u003e true,           // Master switch for all tracing\n    'requests' =\u003e true,          // Enable request tracing\n    'route' =\u003e true,            // Enable route tracing\n    'user' =\u003e true,             // Enable user tracing\n    'queries' =\u003e [               // Database query tracing\n        'enabled' =\u003e true,\n        'limit' =\u003e 10,           // Maximum number of queries to track\n    ],\n    'jobs' =\u003e true,             // Enable job context tracing\n    'commands' =\u003e true,         // Enable command context tracing\n    'outgoing_requests' =\u003e [    // Outgoing HTTP request tracing\n        'enabled' =\u003e true,\n        'limit' =\u003e 5,           // Maximum number of outgoing requests to track\n    ],\n    'environment' =\u003e true,      // Enable environment data collection\n    'session' =\u003e true,          // Enable session data collection\n    'redact' =\u003e [               // Data redaction configuration\n        'headers' =\u003e [],        // Additional headers to redact (beyond defaults)\n        'payload_fields' =\u003e [], // Additional payload fields to redact (beyond defaults)\n        'query_bindings' =\u003e false, // Whether to redact query bindings\n    ],\n]\n```\n\n#### Request Tracing\nWhen request tracing is enabled, the following data is automatically logged:\n- URL\n- HTTP Method\n- Route information\n- Headers (filtered to remove sensitive data)\n- Request body\n\n#### Route Tracing\nWhen route tracing is enabled, the following route information is logged:\n- Route name\n- URI pattern\n- Route parameters\n- Controller action\n- Middleware stack\n- HTTP methods\n\n#### User Tracing\nBy default, user tracing only logs the user identifier to comply with GDPR regulations. However, you can customize the user data being logged by setting your own resolver:\n\n```php\nuse Naoray\\LaravelGithubMonolog\\Tracing\\UserDataCollector;\n\nUserDataCollector::setUserDataResolver(function ($user) {\n    return [\n        'username' =\u003e $user-\u003eusername,\n        // Add any other user fields you want to log\n    ];\n});\n```\n\n\u003e **Note:** When customizing user data collection, ensure you comply with relevant privacy regulations and only collect necessary information.\n\n#### Query Tracing\nWhen query tracing is enabled, recent database queries are logged with:\n- SQL statement\n- Query bindings (can be redacted)\n- Execution time\n- Connection name\n\nYou can limit the number of queries tracked using the `limit` configuration option.\n\n#### Job Tracing\nWhen job tracing is enabled, queue job context is logged including:\n- Job name and class\n- Queue name\n- Connection name\n- Attempt number\n- Job payload (sensitive data is redacted)\n\n#### Command Tracing\nWhen command tracing is enabled, artisan command context is logged including:\n- Command name\n- Command arguments\n- Command options (sensitive data is redacted)\n\n#### Outgoing Request Tracing\nWhen outgoing request tracing is enabled, HTTP requests made by your application are logged with:\n- Request URL and method\n- Response status code\n- Request duration\n- Request headers\n\nYou can limit the number of outgoing requests tracked using the `limit` configuration option.\n\n#### Environment Tracing\nWhen environment tracing is enabled, application environment data is collected including:\n- App environment and debug mode\n- Laravel and PHP versions\n- Hostname\n- Git commit (if configured)\n\n#### Session Tracing\nWhen session tracing is enabled, session data is logged including:\n- Session data (sensitive fields are redacted)\n- Flash data (old and new)\n\n#### Data Redaction\nThe package automatically redacts sensitive data from headers, payloads, and query bindings. You can customize what gets redacted:\n\n- `headers`: Additional header names to redact beyond the default sensitive headers\n- `payload_fields`: Additional payload field names to redact beyond the default sensitive fields\n- `query_bindings`: Set to `true` to redact all query bindings (default: `false`)\n\n### Signature Generator\n\nControl how errors are grouped by customizing the signature generator. By default, the package uses a generator that creates signatures based on exception details or log message content.\n\n```php\n'github' =\u003e [\n    // ... basic config from above ...\n    'signature_generator' =\u003e \\Naoray\\LaravelGithubMonolog\\Deduplication\\DefaultSignatureGenerator::class,\n]\n```\n\nYou can implement your own signature generator by implementing the `SignatureGeneratorInterface`:\n\n```php\nuse Monolog\\LogRecord;\nuse Naoray\\LaravelGithubMonolog\\Deduplication\\SignatureGeneratorInterface;\n\nclass CustomSignatureGenerator implements SignatureGeneratorInterface\n{\n    public function generate(LogRecord $record): string\n    {\n        // Your custom logic to generate a signature\n        return md5($record-\u003emessage);\n    }\n}\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Krishan Koenig](https://github.com/Naoray)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaoray%2Flaravel-github-monolog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaoray%2Flaravel-github-monolog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaoray%2Flaravel-github-monolog/lists"}