https://github.com/utopia-php/logger
Lite & fast micro PHP logging library that is **easy to use**.
https://github.com/utopia-php/logger
hacktoberfest php utopia utopia-php
Last synced: about 2 months ago
JSON representation
Lite & fast micro PHP logging library that is **easy to use**.
- Host: GitHub
- URL: https://github.com/utopia-php/logger
- Owner: utopia-php
- License: mit
- Created: 2021-11-09T09:31:27.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-17T13:27:03.000Z (6 months ago)
- Last Synced: 2025-03-31T05:08:12.367Z (2 months ago)
- Topics: hacktoberfest, php, utopia, utopia-php
- Language: PHP
- Homepage:
- Size: 170 KB
- Stars: 10
- Watchers: 6
- Forks: 17
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Utopia Logger
[](https://app.travis-ci.com/github/utopia-php/logger)

[](https://appwrite.io/discord)Utopia Logger library is simple and lite library for logging information, such as errors or warnings. This library aims to be as simple and easy to learn and use as possible. This library is maintained by the [Appwrite team](https://appwrite.io).
Although the library was built for the [Utopia Framework](https://github.com/utopia-php/framework) project, it is completely independent, **dependency-free** and can be used with any other PHP project or framework.
## Getting Started
Install using composer:
```bash
composer require utopia-php/logger
``````php
setAction("controller.database.deleteDocument");
$log->setEnvironment("production");
$log->setNamespace("api");
$log->setServer("digitalocean-us-001");
$log->setType(Log::TYPE_WARNING);
$log->setVersion("0.11.5");
$log->setMessage("Document efgh5678 not found");
$log->setUser(new User("efgh5678"));
$log->addBreadcrumb(new Breadcrumb(Log::TYPE_DEBUG, "http", "DELETE /api/v1/database/abcd1234/efgh5678", \microtime(true) - 500));
$log->addBreadcrumb(new Breadcrumb(Log::TYPE_DEBUG, "auth", "Using API key", \microtime(true) - 400));
$log->addBreadcrumb(new Breadcrumb(Log::TYPE_INFO, "auth", "Authenticated with * Using API Key", \microtime(true) - 350));
$log->addBreadcrumb(new Breadcrumb(Log::TYPE_INFO, "database", "Found collection abcd1234", \microtime(true) - 300));
$log->addBreadcrumb(new Breadcrumb(Log::TYPE_DEBUG, "database", "Permission for collection abcd1234 met", \microtime(true) - 200));
$log->addBreadcrumb(new Breadcrumb(Log::TYPE_ERROR, "database", "Missing document when searching by ID!", \microtime(true)));
$log->addTag('sdk', 'Flutter');
$log->addTag('sdkVersion', '0.0.1');
$log->addTag('authMode', 'default');
$log->addTag('authMethod', 'cookie');
$log->addTag('authProvider', 'MagicLink');
$log->addExtra('urgent', false);
$log->addExtra('isExpected', true);// Sentry
$adapter = new Sentry("[YOUR_SENTRY_DSN]");
$logger = new Logger($adapter);
$logger->addLog($log);// AppSignal
$adapter = new AppSignal("[YOUR_APPSIGNAL_KEY]");
$logger = new Logger($adapter);
$logger->addLog($log);// Raygun
$adapter = new Raygun("[YOUR_RAYGUN_KEY]");
$logger = new Logger($adapter);
$logger->addLog($log);// Log Owl
$adapter = new LogOwl("[YOUR_SERVICE_TICKET]");
$logger = new Logger($adapter);
$logger->addLog($log);```
### Adapters
Below is a list of supported adapters, and thier compatibly tested versions alongside a list of supported features and relevant limits.
| Adapter | Status |
|---------|---------|
| Sentry | ✅ |
| AppSignal | ✅ |
| Raygun | ✅ |
| Log Owl | ✅ |` ✅ - supported, 🛠 - work in progress`
## Tests
If you need to install dependencies, run:
```bash
docker run --rm --interactive --tty \
--volume $PWD:/app \
composer update --ignore-platform-reqs --optimize-autoloader --no-plugins --no-scripts --prefer-dist
```To run all unit tests, prepare the `.env` file using `.env.example` as a template. Then, run:
```bash
docker run --rm --interactive --tty --env-file .env \
--volume $PWD:/app \
composer test
```> Make sure to replace `TEST_SENTRY_DSN` with actual keys from Sentry.
> Make sure to replace `TEST_APPSIGNAL_KEY` with key found in Appsignal -> Project -> App Settings -> Push & deploy -> Push Key
> Make sure to replace `TEST_RAYGUN_KEY` with key found in Raygun -> Project -> Application Settings -> Api Key
To run static code analysis, use the following Psalm command:
```bash
docker run --rm --interactive --tty \
--volume $PWD:/app \
composer check
```## System Requirements
Utopia Framework requires PHP 8.0 or later. We recommend using the latest PHP version whenever possible.
## Copyright and license
The MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)