{"id":17721872,"url":"https://github.com/tiny-logger/tiny-logger","last_synced_at":"2025-10-27T03:03:57.121Z","repository":{"id":51291571,"uuid":"230115391","full_name":"tiny-logger/tiny-logger","owner":"tiny-logger","description":"Light weight composer package for file logging. Supports web hook requests.","archived":false,"fork":false,"pushed_at":"2024-11-01T17:24:23.000Z","size":108,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-02T16:10:31.990Z","etag":null,"topics":["composer","log","logger","packagist","php","php-library","php7"],"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/tiny-logger.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2019-12-25T14:41:01.000Z","updated_at":"2024-11-01T17:17:45.000Z","dependencies_parsed_at":"2023-11-14T20:26:57.687Z","dependency_job_id":"5dc5f94e-dd72-45b2-85a3-176cd5600184","html_url":"https://github.com/tiny-logger/tiny-logger","commit_stats":{"total_commits":115,"total_committers":2,"mean_commits":57.5,"dds":0.04347826086956519,"last_synced_commit":"bd94b172a367679973a36af05e915d974ba634ed"},"previous_names":["tiny-logger/tiny-logger","serhiicho/tiny-logger"],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiny-logger%2Ftiny-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiny-logger%2Ftiny-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiny-logger%2Ftiny-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiny-logger%2Ftiny-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tiny-logger","download_url":"https://codeload.github.com/tiny-logger/tiny-logger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243532517,"owners_count":20306151,"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":["composer","log","logger","packagist","php","php-library","php7"],"created_at":"2024-10-25T15:36:39.085Z","updated_at":"2025-10-27T03:03:56.842Z","avatar_url":"https://github.com/tiny-logger.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Tiny Logger](https://github.com/tiny-logger/tiny-logger/actions/workflows/php.yml/badge.svg?branch=main)](https://github.com/tiny-logger/tiny-logger/actions/workflows/php.yml)\n[![Latest Stable Version](https://poser.pugx.org/serhii/tiny-logger/v/stable)](https://packagist.org/packages/serhii/tiny-logger)\n[![Total Downloads](https://poser.pugx.org/serhii/tiny-logger/downloads)](https://packagist.org/packages/serhii/tiny-logger)\n[![License](https://poser.pugx.org/serhii/tiny-logger/license)](https://packagist.org/packages/serhii/tiny-logger)\n\u003ca href=\"https://php.net/\" rel=\"nofollow\"\u003e\u003cimg src=\"https://img.shields.io/badge/php-%3E%3D%207.2-8892BF.svg\" alt=\"Minimum PHP Version\" style=\"max-width:100%;\"\u003e\u003c/a\u003e\n\nLightweight composer package for file logging with ability to send errors with webhook.\n\n[Usage example](https://replit.com/@SerhiiCho/Usage-of-tiny-logger-package#public/index.php)\n\n## Set file path\n\nFor setting up the path globally for all the log files you can call `setPath` method in your bootstrap file.\n\n```php\nuse Serhii\\TinyLogger\\Logger;\n\nLogger::setPath('logs/errors.log'); // simple format\nLogger::setPath('logs/%s.log', 'errors'); // sprintf format\n```\n\n\u003e NOTE: If you want to use logger in a cron scripts or something like WordPress hook, you need to call `setPath()` at the very first step of the script execution, it means that your project might have multiple places where you need to set path for your logs. If you don't want to call `setPath()` you can just pass the path to a `tiny_log()` function as a third argument. _See an example in the Usage section._\n\n## Supported PHP versions\n\n- ✅ 7.2\n- ✅ 7.3\n- ✅ 7.4\n- ✅ 8.0\n- ✅ 8.1\n- ✅ 8.2\n- ✅ 8.3\n\n## Usage\n\nThis package comes with a function `tiny_log()` where second and third arguments are not required.\n\n```php\ntiny_log('Some error message');\n// Output in file: [2020-01-12 04:09:16] error: Some error message.\n\ntiny_log('Some error message', 'info');\n// Output in file: [2020-01-12 04:09:16] info: Some error message.\n\ntiny_log('Some error message', 'debug', 'logs/debug.log');\n// If you don't need to set path globally, just pass file path as the third argument to the tiny_log function .\n```\n\nYou can also use Logger class if you want. It will do the same as using function.\n\n```php\nuse \\Serhii\\TinyLogger\\Logger;\n\nLogger::new()-\u003eerror('Some error message');\nLogger::new()-\u003einfo('Some info message');\nLogger::new()-\u003edebug('Some error message');\n````\n\n## Options\n\nFor using one of the available options you can optionally pass certain flag to `tiny_log()` function as the second argument. If you also need to pass error type just separate them with the pipe `|` character. See the example with option `pos`:\n\n```php\ntiny_log('Some error message', 'pos'); // just passing option\ntiny_log('Some error message', 'pos|error'); // 'pos' option with error type 'error'\ntiny_log('Some error message', 'pos|info'); // 'pos' option with error type 'info'\n```\n\n#### Available options\n\n- `pos` - Show position of the logger. In which file and on what line number it is. It is useful when you're debugging, to not forget where you put your logger. See the example of output:\n\n```text\n[2020-01-12 04:09:16] info: Some log message goes here\n\u003e\u003e\u003e /var/www/html/app/Services/App.php on line: 77.\n```\n\n## Send logs with POST request\n\nTiny logger allows you to send logs as a json object on a specific endpoint. To enable this option you need to call `enablePostRequest` method on `Logger` class. To disable POST request use `disablePostRequest` method.\n\n```php\nuse Serhii\\TinyLogger\\Logger;\n\nLogger::enablePostRequest('http://my-site.com/webhook');\n```\n\nNow if error occurs, json will be sent to `http://my-site.com/webhook` endpoint with POST request.\n\n```json\n{\n    \"timestamp\": \"1611675632\",\n    \"message\": \"Undefined variable at line 24 in \\\\App\\\\Models\\\\User class.\",\n    \"type\": \"error\"\n}\n```\n\nIf you need to customize the json object structure, you can pass array as the second argument on `enablePostRequest` method.\n\n```php\nuse Serhii\\TinyLogger\\JsonFieldValue;\nuse Serhii\\TinyLogger\\Logger;\n\nLogger::enablePostRequest('http://my-site.com/webhook', [\n    'time' =\u003e JsonFieldValue::TIMESTAMP,\n    'errorMessage' =\u003e 'Error message: ' . JsonFieldValue::MESSAGE,\n    'errorType' =\u003e JsonFieldValue::ERROR_TYPE,\n    'token' =\u003e getenv('MY_AUTH_TOKEN')\n]);\n```\n\nNow you'll get json like this:\n\n```json\n{\n    \"time\": \"1611675632\",\n    \"errorMessage\": \"Error message: Undefined variable at line 24 in \\\\App\\\\Models\\\\User class.\",\n    \"errorType\": \"error\",\n    \"token\": \"29d62x7g656e6f9\"\n}\n```\nEach JsonFieldValue constant will be replaced with its value. For example JsonFieldValue::MESSAGE will be replaced with the error message. JsonFieldValue::TIMESTAMP will be replaced with error timestamp.\n\n\u003e NOTE: If you want to use logger in a cron scripts or something like WordPress hook, you need to call `enablePostRequest` at the very first step of the script execution.\n\n## Get started\n\nTo install all php dependencies you need to have [Composer PHP package manager](https://getcomposer.org) installed on your machine. Then you need to run the command below in your root directory of the project.\n\n```bash\ncomposer require serhii/tiny-logger\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiny-logger%2Ftiny-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftiny-logger%2Ftiny-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiny-logger%2Ftiny-logger/lists"}