{"id":19723819,"url":"https://github.com/schema31/php-monitoring","last_synced_at":"2025-09-13T13:15:32.468Z","repository":{"id":62541049,"uuid":"293563242","full_name":"Schema31/php-monitoring","owner":"Schema31","description":null,"archived":false,"fork":false,"pushed_at":"2020-09-08T13:34:05.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-10T16:39:35.304Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Schema31.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":"2020-09-07T15:19:58.000Z","updated_at":"2020-09-08T13:33:08.000Z","dependencies_parsed_at":"2022-11-02T15:45:32.862Z","dependency_job_id":null,"html_url":"https://github.com/Schema31/php-monitoring","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Schema31%2Fphp-monitoring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Schema31%2Fphp-monitoring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Schema31%2Fphp-monitoring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Schema31%2Fphp-monitoring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Schema31","download_url":"https://codeload.github.com/Schema31/php-monitoring/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241045481,"owners_count":19899654,"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":[],"created_at":"2024-11-11T23:23:36.027Z","updated_at":"2025-02-27T18:44:19.641Z","avatar_url":"https://github.com/Schema31.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-monitoring\n======\n\n[Packagist][link-packagist]\n\nLogger class for PHP. It require the [Schema31/php-gcloud-monitoring-sdk](https://github.com/Schema31/php-gcloud-monitoring-sdk)\n\nInstall\n-------\n\nYou can install the library using [composer](https://getcomposer.org/):\n\n```sh\n$ composer require schema31/php-monitoring\n```\n\nHow to use\n----------\n\n## Configurations\n\n### Internal configuration\n\nYou can pass the configuration values:\n\n```php\nuse Schema31\\PhpMonitoring\\Logger;\nuse Schema31\\PhpMonitoring\\LoggerConstants;\n\n...\n\n$logger = new Logger(\"streamName\", \"authentication\", LoggerConstants::REST, LoggerConstants::DEBUG);\n\n```\n\n### Configuration constants\n\nYou can define constants and the library use it automatically: \n\n```php\nuse Schema31\\PhpMonitoring\\Logger;\nuse Schema31\\PhpMonitoring\\LoggerConstants;\n\n...\n\ndefine('LOGGER_STREAMNAME', 'streamName');\ndefine('LOGGER_AUTHENTICATION', 'authentication');\ndefine('LOGGER_PROTOCOL', LoggerConstants::REST);\ndefine('LOGGER_THRESHOLD', LoggerConstants::DEBUG);\n\n$logger = new Logger();\n```\n\n## Sending a message\n\n```php\n//Method chaining is allowed\n$logger-\u003esetProtocol(LoggerConstants::REST) //if you want to ovverride the default\n-\u003esetLevel(LoggerConstants::ALERT)\n-\u003esetFacility(\"PhpMonitoring\")\n-\u003esetFile(__FILE__)\n-\u003esetLine(__LINE__)\n-\u003esetShortMessage(\"Short Message \" . uniqid())\n-\u003esetFullMessage(\"Full Message\")\n-\u003esetSingleAdditional(\"key1\", \"value1\")\n-\u003epublish();\n```\n\n## Sending an exception\n\nYou can send a log based on an exception:\n\n```php\ntry{\n    throw new \\Exception(\"Test Exception\");\n}catch(\\Exception $exc){\n    $logger\n    -\u003esetException($exc)\n    -\u003epublish();\n}\n```\n\nOr\n\n```php\ntry{\n    throw new \\Exception(\"Test Exception\");\n}catch(\\Exception $exc){\n    $logger\n    -\u003esetException($exc)\n    -\u003esetFacility(\"PhpMonitoring\") //You can override the facility of the exception\n    -\u003esetLevel(LoggerConstants::CRITICAL) //You can override the level of the exception\n    -\u003esetSingleAdditional(\"key1\", \"value1\") //You can add other additionals\n    -\u003epublish();\n}\n```\n\n[link-packagist]: https://packagist.org/packages/schema31/php-monitoring\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschema31%2Fphp-monitoring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschema31%2Fphp-monitoring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschema31%2Fphp-monitoring/lists"}