{"id":16314853,"url":"https://github.com/forecho/laravel-trace-log","last_synced_at":"2025-07-18T19:34:04.491Z","repository":{"id":44943967,"uuid":"448798047","full_name":"forecho/laravel-trace-log","owner":"forecho","description":"Trace Log for Laravel/Lumen","archived":false,"fork":false,"pushed_at":"2022-08-11T03:10:15.000Z","size":22,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-11T23:47:18.798Z","etag":null,"topics":["laravel","laravel-package","tracelog"],"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/forecho.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-17T07:44:23.000Z","updated_at":"2023-10-25T02:38:11.000Z","dependencies_parsed_at":"2022-09-16T23:51:44.087Z","dependency_job_id":null,"html_url":"https://github.com/forecho/laravel-trace-log","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/forecho/laravel-trace-log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forecho%2Flaravel-trace-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forecho%2Flaravel-trace-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forecho%2Flaravel-trace-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forecho%2Flaravel-trace-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/forecho","download_url":"https://codeload.github.com/forecho/laravel-trace-log/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forecho%2Flaravel-trace-log/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265820261,"owners_count":23833563,"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":["laravel","laravel-package","tracelog"],"created_at":"2024-10-10T21:55:26.407Z","updated_at":"2025-07-18T19:34:04.465Z","avatar_url":"https://github.com/forecho.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Trace Log for Laravel/Lumen\n\n\u003ca href=\"https://packagist.org/packages/forecho/laravel-trace-log\"\u003e\u003cimg src=\"https://poser.pugx.org/forecho/laravel-trace-log/v/stable.svg\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/forecho/laravel-trace-log\"\u003e\u003cimg src=\"https://poser.pugx.org/forecho/laravel-trace-log/v/unstable.svg\" alt=\"Latest Unstable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/forecho/laravel-trace-log\"\u003e\u003cimg src=\"https://poser.pugx.org/forecho/laravel-trace-log/downloads\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/forecho/laravel-trace-log\"\u003e\u003cimg src=\"https://poser.pugx.org/forecho/laravel-trace-log/license\" alt=\"License\"\u003e\u003c/a\u003e\n\n## Install\n\n```shell\ncomposer require forecho/laravel-trace-log\n```\n\nif you use Lumen, you need add service provider to your `bootstrap/app.php` file.\n\n```php\n$app-\u003eregister(Forecho\\LaravelTraceLog\\TraceLogServiceProvider::class);\n```\n\n## Configuration\n\nThis step is optional\n\n```shell\nphp artisan vendor:publish --provider=\"Forecho\\LaravelTraceLog\\TraceLogServiceProvider\"\n```\n\nif you use Lumen, you need add config file to your `config` directory.\n\n```shell\ncp vendor/forecho/laravel-trace-log/config/tracelog.php config/\n```\n\nand you need add code to your `bootstrap/app.php` file.\n\n```php\n$app-\u003econfigure('tracelog');\n```\n\n**Note**\n\n- The number of bits of the value corresponding to the key in `log_filter_half_hide_keys` must be greater than 2,\n  otherwise all data is hidden.\n- If the configuration file causes an error, the filtering function will be invalid, the error message can be searched\n  for `request_params_filter_key_config_error` to view the log.\n\n`additional_fields` is an array of additional fields that will be added to the log. eg:\n\n```php\n'additional_fields' =\u003e [\n    'user_id' =\u003e [App\\Models\\User::class, 'getId'],\n    'tag' =\u003e 'test', // value can use closure、string、array\n  ],\n```\n\nadd `getId()` method to User model, and the value of the field will be the return value of the method.\n\n```php\nnamespace App\\Models;\n\nclass User \n{\n    public static function getId(): ?int\n    {\n        return data_get(Auth::user(), 'id');\n    }\n}\n\n```\n\n## Usage\n\n### Middleware(Optional)\n\nchange `App\\Http\\Kernel.php` file to add `TraceLogMiddleware` middleware.\n\n```php\nuse Forecho\\LaravelTraceLog\\Middleware\\TraceLogMiddleware;\n\nprotected $middlewareGroups = [\n    // ...\n\n    'api' =\u003e [\n        // ...        \n        'request.tracelog'\n    ],\n];\n\n\nprotected $routeMiddleware = [\n    // ...    \n    'request.tracelog' =\u003e TraceLogMiddleware::class\n];\n```\n\n### Logging\n\n```php\n\nuse Forecho\\LaravelTraceLog\\TraceLog;\n\nTraceLog::warning('This is a warning message.', ['foo' =\u003e 'bar']);\nTraceLog::error('This is an error message.', ['foo' =\u003e 'bar']);\nTraceLog::info('This is an info message.', ['foo' =\u003e 'bar']);\nTraceLog::debug('This is a debug message.', ['foo' =\u003e 'bar']);\n```\n\n### Get Trace ID\n\n```php\nuse Forecho\\LaravelTraceLog\\TraceLog;\n\nTraceLog::getTraceId();\n```\n\n### Curl Request\n\nif you want next system use the same trace_id, you need add `trace_id` to your `header`\n\n```php\nuse Forecho\\LaravelTraceLog\\TraceLog;\n\n$key = config('tracelog.trace_id_header_key');\n$headers = [\n  $key =\u003e TraceLog::getTraceId(),\n]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforecho%2Flaravel-trace-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforecho%2Flaravel-trace-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforecho%2Flaravel-trace-log/lists"}