maatify / logger
PSR-3 compatible PHP logger with a Monolog backend, secret redaction and a JSON file fallback
Requires
- php: >=8.4.27 <8.5.0 || >=8.5.12 <8.6.0
- ext-json: *
- monolog/monolog: ^3.9
- psr/log: ^3.0
Requires (Dev)
- composer/semver: ^3.4
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Maatify Logger
maatify/logger is a PSR-3 compatible logger for PHP: a Monolog-backed Logger, a static LoggerService facade, a legacy RecordLog entry point, redaction of secrets before anything is written, and a JSON file fallback used only when Monolog is not loadable.
Published release: 7.0.0 (2026-10-31), distributed through Packagist.
Key Features
- PSR-3 logger:
Maatify\Logger\LoggerimplementsPsr\Log\LoggerInterface. - Facade and legacy entry points: static
LoggerServicemethods andLogger::RecordLog()for existing code. - Secrets are redacted before they are written: sensitive context keys,
key=valuesecrets,Authorization: Bearer/Basicvalues andThrowablemessages and traces are masked. The list and a custom hook are configurable. - Request path only: the file fallback records
REQUEST_URIwithout its query string or fragment; the full URI is an explicit opt-in. - Time-partitioned files:
logs/YYYY/MM/DD/HH/with a404index.phpguard in each created folder. - Never throws on I/O failure in the fallback: write problems go to an internal error file instead.
Requirements
composer.json is the source of truth for requirements and dependencies; this table reflects it.
| Requirement | Constraint |
|---|---|
| PHP | >=8.4.27 <8.5.0 || >=8.5.12 <8.6.0 |
| Extensions | ext-json |
monolog/monolog |
^3.9 |
psr/log |
^3.0 |
Installation
Install the published release:
composer require maatify/logger:7.0.0
The command resolves through Packagist.
Quick Usage
use Maatify\Logger\LoggerService; LoggerService::info('User login successful', 'auth/logs'); try { throw new RuntimeException('DB connection failed'); } catch (Throwable $e) { LoggerService::logException($e, 'system/errors', context: ['requestId' => 'abc123']); }
Complete, runnable examples: examples/. Walkthroughs: docs/guides/USAGE_GUIDE.md.
Public Runtime API
An overview only. The complete inventory (signatures, behavior, errors) is LOGGER_PACKAGE_REFERENCE.md.
| Area | Types |
|---|---|
| PSR-3 logger | Logger (emergency() … debug(), log()) |
| Facade | LoggerService (static log(), level methods, logException()) |
| Legacy | Logger::RecordLog(), Logger::LEVEL_* constants |
| Redaction | Logger::setSensitiveKeys(), Logger::setRedactor(), Logger::redactContext() |
| Request URI policy | Logger::sanitizeRequestUri(), Logger::logFullRequestUri() |
Critical Runtime Behavior
- Monolog is the active backend: because
monolog/monologis a required dependency, entries go tologs/YYYY/MM/DD/HH/app_YYYY-MM-DD-HH.log. The per-call log file name only routes files in the file fallback; with Monolog it is carried in the context. - Redaction runs first on every call, in both backends, and never throws.
- Invalid level: a non-string or unknown level throws
Psr\Log\InvalidArgumentException.
Security and Trust Boundaries
The package masks well-known secret shapes; it cannot know every application secret. Add your own keys with Logger::setSensitiveKeys() or a hook with Logger::setRedactor(). Store logs outside the web root or deny access to them in your server configuration: the index.php guard in each log folder does not stop a web server from serving a known .log path. REMOTE_ADDR and USER_AGENT are written by the file fallback unconditionally; apply your own retention policy to log files. See SECURITY.md for reporting.
Examples
Maintained, smoke-executed examples using only the Public Runtime API: examples/.
Documentation
Quality Status
PHPStan level max with no baseline, a PHPUnit suite, a Consumer Verification Harness (clean consumer install, production autoload) and smoke-executed examples run in CI; the CI gate job aggregates them.
Development and Testing
composer ci
Each gate and its CI mapping are listed in CONTRIBUTING.md.
License
Proprietary. See LICENSE.
👤 Author
Engineered by Mohamed Abdulalim (@megyptm)
Backend Lead & Technical Architect
https://www.maatify.dev
Built with ❤️ by Maatify.dev — Unified Ecosystem for Modern PHP Libraries