apploud / logger
Monolog integration into Apploud projects
v1.4.1
2024-10-24 15:16 UTC
Requires
- php: ^8.1
- contributte/monolog: ^0.5.2
- lcobucci/jwt: ^5.0
- mangoweb/monolog-tracy-handler: ^1.1
- monolog/monolog: ^3.6
- nette/di: ^3.2
- nette/php-generator: ^3.0 || ^4.0
- nette/schema: ^1.0
- psr/http-message: ^1.0 || ^2.0
- psr/log: ^2.0 || ^3.0
- ramsey/uuid: ^4.7
Requires (Dev)
- mockery/mockery: ^1.6
- php-parallel-lint/php-parallel-lint: ^1.4
- phpstan/phpstan: ^1.11
- phpstan/phpstan-phpunit: ^1.4
- phpstan/phpstan-strict-rules: ^1.6
- phpunit/phpunit: ^10.5
- roave/security-advisories: dev-latest
- slevomat/coding-standard: ^8.15
README
This package integrates Monolog into Apploud projects.
It uses contributte ingegration and adds some features:
\Apploud\Logger\Logger
class withlogException()
method to easily log exceptions- default logger configuration, which can be updated across projects with
composer update
- local storage driver, which adds bluescreen URL to logs accessible through webserver
Installation
Just use composer:
composer require apploud/logger
Minimal configuration
Add extension to config.neon
:
extensions: logger: Apploud\Logger\DI\LoggerExtension logger: bluescreen: logDir: %appDir%/../log # path to store bluescreens in logDirUrl: %server.baseUrl%/_belogs # URL to bluescreens directory, without trailing slash
Usage
Extension adds \Apploud\Logger\Logger
to DI container. This logger also implements \Psr\Log\LoggerInterface
interface.
Advanced configuration
See commented example:
logger: bluescreen: logDir: %appDir%/../log # path to store bluescreens in logDirUrl: %server.baseUrl%/_belogs # URL to bluescreens directory, without trailing slash minLevel: Monolog\Level::Warning # minimal Level for creating bluescreens, defaults to Warning requestIds: process: true # if true, Request ID processor adds request tracing information to logs requestIdHeader: X-Request-ID correlationIdHeader: X-Correlation-ID extraFieldName: request # field name in `extra` section jwt: process: true # if true, JWT processor adds decoded fields from JTW token in Authorization header to logs fields: # which fields from JWT should be added to logs - sub - jti extraFieldName: jwt # field name in `extra` section extraHandlers: # Adds handlers to default logger, syntax same as in contributte extension - factory: Monolog\Handler\StreamHandler("%appDir%/../log/default.log") setup: - setFormatter(Monolog\Formatter\JsonFormatter()) extraProcessors: # Adds processors to default logger, syntax same as in contributte extension - Monolog\Processor\MemoryPeakUsageProcessor() channels: # Adds other loggers, syntax same as in contributte extension someChannel: ... someOtherChannel: ... contributte: manager: false # if true, enables logger manager (see contributte docs) holder: false # if true, enables logger holder (see contributte docs) monolog: # can be used to configure contributte extension directly, if used, previous options are ignored