{"id":16467132,"url":"https://github.com/theriddleofenigma/laravel-google-chat-log","last_synced_at":"2025-03-16T18:31:27.538Z","repository":{"id":43662506,"uuid":"340838726","full_name":"theriddleofenigma/laravel-google-chat-log","owner":"theriddleofenigma","description":"Brings up the option for sending the logs to google chat [Google Workplace formerly called GSuite].","archived":false,"fork":false,"pushed_at":"2024-01-27T11:10:02.000Z","size":42,"stargazers_count":22,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-13T22:06:09.242Z","etag":null,"topics":["error-logging","google-chat","gsuite","laravel","laravel-logs","logs","lumen"],"latest_commit_sha":null,"homepage":"https://theriddleofenigma.github.io/laravel-google-chat-log/","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/theriddleofenigma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"custom":["https://www.buymeacoffee.com/riddleofenigma"]}},"created_at":"2021-02-21T06:59:18.000Z","updated_at":"2025-01-23T16:49:58.000Z","dependencies_parsed_at":"2022-08-24T14:36:59.430Z","dependency_job_id":null,"html_url":"https://github.com/theriddleofenigma/laravel-google-chat-log","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theriddleofenigma%2Flaravel-google-chat-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theriddleofenigma%2Flaravel-google-chat-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theriddleofenigma%2Flaravel-google-chat-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theriddleofenigma%2Flaravel-google-chat-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theriddleofenigma","download_url":"https://codeload.github.com/theriddleofenigma/laravel-google-chat-log/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243826788,"owners_count":20354220,"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":["error-logging","google-chat","gsuite","laravel","laravel-logs","logs","lumen"],"created_at":"2024-10-11T11:46:10.988Z","updated_at":"2025-03-16T18:31:27.195Z","avatar_url":"https://github.com/theriddleofenigma.png","language":"PHP","funding_links":["https://www.buymeacoffee.com/riddleofenigma"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003ccode\u003e\u0026hearts; Made with \u0026lt;love/\u0026gt; And I love \u0026lt;code/\u0026gt;\u003c/code\u003e\u003c/p\u003e\n\n# Laravel Google Chat Log\n\nBrings up the option for sending the logs to google chat [Google Workspace formerly called GSuite] from [Laravel](https://laravel.com)/[Lumen](https://lumen.laravel.com).\n\n## Installation\n### Composer install\n```shell\ncomposer require theriddleofenigma/laravel-google-chat-log\n```\n\nFor laravel 9.x or lower, please use v1.x\n```shell\ncomposer require theriddleofenigma/laravel-google-chat-log:^1.3\n```\n\nAdd the following code to the channels array in `config/logging.php` in your laravel/lumen application.\n```php\n'google-chat' =\u003e [\n    'driver' =\u003e 'monolog',\n    'url' =\u003e env('LOG_GOOGLE_CHAT_WEBHOOK_URL'),\n    'notify_users' =\u003e [\n        'default' =\u003e env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_DEFAULT'),\n        'emergency' =\u003e env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_EMERGENCY'),\n        'alert' =\u003e env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_ALERT'),\n        'critical' =\u003e env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_CRITICAL'),\n        'error' =\u003e env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_ERROR'),\n        'warning' =\u003e env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_WARNING'),\n        'notice' =\u003e env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_NOTICE'),\n        'info' =\u003e env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_INFO'),\n        'debug' =\u003e env('LOG_GOOGLE_CHAT_NOTIFY_USER_ID_DEBUG'),\n    ],\n    'level' =\u003e env('LOG_LEVEL', 'debug'),\n    'handler' =\u003e \\Enigma\\GoogleChatHandler::class,\n],\n```\n\nYou can provide the eight logging levels defined in the [RFC 5424 specification](https://tools.ietf.org/html/rfc5424): `emergency`, `alert`, `critical`, `error`, `warning`, `notice`, `info`, and `debug`\n\n\u003cb\u003eNote*:\u003c/b\u003e Make sure to set the \u003cb\u003eLOG_GOOGLE_CHAT_WEBHOOK_URL\u003c/b\u003e env variable.\nAnd all other \u003cb\u003eLOG_GOOGLE_CHAT_NOTIFY_USER_ID\u003c/b\u003e are optional.\nHere, you can set multiple google chat webhook url as comma separated value for the \u003cb\u003eLOG_GOOGLE_CHAT_WEBHOOK_URL\u003c/b\u003e env variable.\n\n\u003cb\u003eNote*:\u003c/b\u003e For lumen, make sure the `$app-\u003ewithFacades();` is uncommented in the \u003cb\u003ebootstrap/app.php\u003c/b\u003e.\n\nNow, you can notify a specific user with `@mention` in the error log by setting the corresponding USER_ID to the `LOG_GOOGLE_CHAT_NOTIFY_USER_ID_DEFAULT` env variable. User Ids mapped under `LOG_GOOGLE_CHAT_NOTIFY_USER_ID_DEFAULT` will be notified for all log levels.  \n\nFor getting the \u003cb\u003eUSER_ID\u003c/b\u003e, right-click the user-icon of the person whom you want to notify in the Google chat from your browser window and select inspect. Under the `div` element find the attribute data_member_id, then the USER_ID can be found as `data-member-id=\"user/human/{USER_ID}\u003e\"`.\n\nIn order to notify all the users like `@all`, Set ```LOG_GOOGLE_CHAT_NOTIFY_USER_ID_DEFAULT=all```. Also, you can set multiple USER_IDs as comma separated value.\nIn order to notify different users for different log levels, you can set the corresponding env keys mentioned to configure in the `logging.php` file.\n\nNow, you can add custom additional logs to the Google chat message by passing a closure function to the GoogleChatHandler::$additionalLogs property.\n```php\nuse Enigma\\GoogleChatHandler;\nuse Illuminate\\Http\\Request;\n\nclass AppServiceProvider {\n    public function register() {}\n    public function boot() {\n        GoogleChatHandler::$additionalLogs = function () {\n            return [\n                'tenant' =\u003e request()-\u003euser()?-\u003etenant-\u003ename,\n                'request' =\u003e json_encode(request()-\u003etoArray()),\n            ];\n        };\n    }\n}\n```\n\n## License\n\nCopyright © Kumaravel\n\nLaravel Google Chat Log is open-sourced software licensed under the [MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheriddleofenigma%2Flaravel-google-chat-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheriddleofenigma%2Flaravel-google-chat-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheriddleofenigma%2Flaravel-google-chat-log/lists"}