{"id":14987256,"url":"https://github.com/seunmatt/codeigniter-log-viewer","last_synced_at":"2025-04-05T07:06:25.539Z","repository":{"id":61058116,"uuid":"116760854","full_name":"SeunMatt/codeigniter-log-viewer","owner":"SeunMatt","description":"This is a simple Log Viewer for viewing Code Igniter logs on the browser and via API clients","archived":false,"fork":false,"pushed_at":"2024-07-13T07:02:19.000Z","size":254,"stargazers_count":100,"open_issues_count":3,"forks_count":40,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-05T07:06:21.825Z","etag":null,"topics":["codeigniter","codeigniter-log-viewer","igniter-logs","log-viewer","php"],"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/SeunMatt.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":"2018-01-09T03:25:57.000Z","updated_at":"2025-02-28T12:14:30.000Z","dependencies_parsed_at":"2024-06-19T00:18:31.668Z","dependency_job_id":"e083affc-21ad-4ae7-8797-7623bb3d7296","html_url":"https://github.com/SeunMatt/codeigniter-log-viewer","commit_stats":{"total_commits":49,"total_committers":7,"mean_commits":7.0,"dds":0.4285714285714286,"last_synced_commit":"8f17091797e945063d555134675743c46a00570c"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeunMatt%2Fcodeigniter-log-viewer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeunMatt%2Fcodeigniter-log-viewer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeunMatt%2Fcodeigniter-log-viewer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeunMatt%2Fcodeigniter-log-viewer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SeunMatt","download_url":"https://codeload.github.com/SeunMatt/codeigniter-log-viewer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299832,"owners_count":20916190,"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":["codeigniter","codeigniter-log-viewer","igniter-logs","log-viewer","php"],"created_at":"2024-09-24T14:14:20.383Z","updated_at":"2025-04-05T07:06:25.521Z","avatar_url":"https://github.com/SeunMatt.png","language":"PHP","readme":"CodeIgniter Log Viewer\n======================\n\n[![Latest Stable Version](https://poser.pugx.org/seunmatt/codeigniter-log-viewer/v/stable)](https://packagist.org/packages/seunmatt/codeigniter-log-viewer) [![Total Downloads](https://poser.pugx.org/seunmatt/codeigniter-log-viewer/downloads)](https://packagist.org/packages/seunmatt/codeigniter-log-viewer) [![License](https://poser.pugx.org/seunmatt/codeigniter-log-viewer/license)](https://packagist.org/packages/seunmatt/codeigniter-log-viewer) \n\nThis is a simple Log Viewer for viewing CodeIgniter logs in the browser or via API calls (that returns a JSON response)\n\nThis project is inspired by the [laravel-log-viewer project](https://github.com/rap2hpoutre/laravel-log-viewer).\n\nA typical log view looks like this:\n\n![sample.png](sample.png)\n\nUsage\n=====\n\n**For CodeIgniter 3, see this [reference guide](https://github.com/SeunMatt/codeigniter-log-viewer/wiki/CodeIgniter-3-Guide)**\n\nRequirements\n-----------\n- PHP \u003e= 7.4\n- CodeIgniter 4\n\nComposer Installation\n---------------------\n```\ncomposer require seunmatt/codeigniter-log-viewer\n```\n\nController Integration for Browser Display\n------------------------------------------\n\n\nAll that is required is to execute the `showLogs()` method in a Controller that is mapped to a route:\n\nA typical Controller *(LogViewerController.php)* will have the following content:\n\n```php\nnamespace App\\Controllers;\nuse CILogViewer\\CILogViewer;\n\nclass LogViewerController extends BaseController\n{\n    public function index() {\n        $logViewer = new CILogViewer();\n        return $logViewer-\u003eshowLogs();\n    }\n}\n```\n\nThen the route `app/Config/Routes.php` can be configured like:\n\n```php\n$routes-\u003eget('logs', \"LogViewerController::index\");\n```\n\nAnd that's all! If you visit `/logs` on your browser \nyou should see all the logs that are in `writable/logs` folder and their content\n\n\nConfiguration\n==============\n\nThe package allows you to configure some of its parameters by creating a `CILogViewer` class in CodeIgniter's `Config` folder and then adding the following variables:\n\n- The folder path for log files can be configured with the `$logFolderPath` config var.\n\n- The file pattern for matching all the log files in the log folder can be configured by adding `$logFilePattern` config var.\n- The name of the view that renders the logs page can be changed using the  `$viewName` config var. Please note that this can be a route relative to your `View` path or a namespace route.\n\nExample configuration file `app/Config/CILogViewer.php`:\n\n```php\n\u003c?php\nnamespace Config;\nuse CodeIgniter\\Config\\BaseConfig;\n\nclass CILogViewer extends BaseConfig {\n    public $logFilePattern = 'log-*.log';\n    public $viewName = 'logs'; //where logs exists in app/Views/logs.php\n}\n```\n\n\nViewing Log Files via API Calls\n===============================\n\nIf you're developing an API Service, powered by CodeIgniter, this library can still be used to view your log files.\n\nController Setup\n----------------\n**The setup is the same as that mentioned above:** \n - Create a Controller e.g. `ApiLogViewerController.php`, \n - Create a function e.g. `index()`\n - In the function, call `echo $this-\u003elogViewer-\u003eshowLogs();`\n - Finally, map your controller function to a route.\n \n API Commands\n ------------\n \n The API is implemented via a set of query params that can be appended to the `/logs` path.\n \n Query:\n \n - `/logs?api=list` will list all the log files available in the configured folder\n\nResponse:\n\n ```json\n{\n    \"status\": true,\n    \"log_files\": [\n        {\n            \"file_b64\": \"bG9nLTIwMTgtMDEtMTkucGhw\",\n            \"file_name\": \"log-2018-01-19.php\"\n        },\n        {\n            \"file_b64\": \"bG9nLTIwMTgtMDEtMTcucGhw\",\n            \"file_name\": \"log-2018-01-17.php\"\n        }\n    ]\n}\n```\n\n**file_b64 is the base64 encoded name of the file that will be used in further operations and API calls**\n \n Query:\n \n - `/logs?api=view\u0026f=bG9nLTIwMTgtMDEtMTcucGhw` will return the logs contained in the log file specified by the `f` parameter. \n \n The value of the `f` (*f stands for file*) is the base64 encoded format of the log file name. It is obtained from the `/logs?api=list` API call. \n A list of all available log files is also returned.\n \n Response:\n \n ```json\n {\n     \"log_files\": [\n         {\n             \"file_b64\": \"bG9nLTIwMTgtMDEtMTkucGhw\",\n             \"file_name\": \"log-2018-01-19.php\"\n         },\n         {\n             \"file_b64\": \"bG9nLTIwMTgtMDEtMTcucGhw\",\n             \"file_name\": \"log-2018-01-17.php\"\n         }\n     ],\n     \"status\": true,\n     \"logs\": [\n         \"ERROR - 2018-01-23 07:12:31 --\u003e 404 Page Not Found: admin/Logs/index\",\n         \"ERROR - 2018-01-23 07:12:37 --\u003e 404 Page Not Found: admin//index\",\n         \"ERROR - 2018-01-23 15:23:02 --\u003e 404 Page Not Found: Faviconico/index\"\n     ]\n }\n ```\n \n The API Query can also take one last parameter, `sline` that will determine how the logs are returned\n When it's `true` the logs are returned in a single line:\n \n Query:\n \n `/logs?api=view\u0026f=bG9nLTIwMTgtMDEtMTkucGhw\u0026sline=true`\n \n Response:\n \n ```json\n{\n    \"log_files\": [\n        {\n            \"file_b64\": \"bG9nLTIwMTgtMDEtMTkucGhw\",\n            \"file_name\": \"log-2018-01-19.php\"\n        },\n        {\n            \"file_b64\": \"bG9nLTIwMTgtMDEtMTcucGhw\",\n            \"file_name\": \"log-2018-01-17.php\"\n        }\n    ],\n    \"status\": true,\n    \"logs\": \"ERROR - 2018-01-23 07:12:31 --\u003e 404 Page Not Found: admin/Logs/index\\r\\nERROR - 2018-01-23 07:12:37 --\u003e 404 Page Not Found: admin//index\\r\\nERROR - 2018-01-23 15:23:02 --\u003e 404 Page Not Found: Faviconico/index\\r\\n\"\n}\n```\n \n \n When it's `false` (**Default**), the logs are returned in as an array, where each element is a line in the log file:\n\nQuery:\n\n `/logs?api=view\u0026f=bG9nLTIwMTgtMDEtMTkucGhw\u0026sline=false` OR `logs?api=view\u0026f=bG9nLTIwMTgtMDEtMTkucGhw` \n\nResponse:\n \n ```json\n{\n    \n    \"logs\": [\n        \"ERROR - 2018-01-23 07:12:31 --\u003e 404 Page Not Found: admin/Logs/index\",\n        \"ERROR - 2018-01-23 07:12:37 --\u003e 404 Page Not Found: admin//index\",\n        \"ERROR - 2018-01-23 15:23:02 --\u003e 404 Page Not Found: Faviconico/index\"\n    ]\n}\n```\n \nQuery:\n\n`/logs?api=delete\u0026f=bG9nLTIwMTgtMDEtMTkucGhw` will delete a single log file. The **f** parameter is the base64 encoded name of the file\nand can be obtained from the view api above.\n\nQuery: \n\n`/logs?api=delete\u0026f=all` will delete all log files in the configured folder path. Take note of the value for **f** which is the literal '**all**'.\n \n **IF A FILE IS TOO LARGE (\u003e 50MB), YOU CAN DOWNLOAD IT WITH THIS API QUERY `/logs?dl=bG9nLTIwMTgtMDEtMTcucGhw`**\n \n \nSECURITY NOTE\n=============\n**It is Highly Recommended that you protect/secure the route for your logs. It should not be an open resource!**\n\nChange Log\n==========\n[Change Log is available here](./CHANGELOG.md)\n\n\nAuthor\n======\n- [Seun Matt](https://smattme.com)\n\nContributors\n============\n- [Miguel Martinez](https://github.com/savioret)\n\n\nLICENSE\n=======\n[MIT](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseunmatt%2Fcodeigniter-log-viewer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseunmatt%2Fcodeigniter-log-viewer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseunmatt%2Fcodeigniter-log-viewer/lists"}