raneomik / watchdog-bundle
This bundle provides a configurable watchdog for events to fire
Installs: 1 063
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 1
Type:symfony-bundle
Requires
- php: ^7.4|^8.0
- symfony/framework-bundle: ^5.4|^6.0
Requires (Dev)
- ekino/phpstan-banned-code: *
- infection/infection: *
- phpstan/extension-installer: *
- phpstan/phpstan: *
- phpstan/phpstan-phpunit: *
- phpstan/phpstan-symfony: *
- phpunit/phpunit: ^9.5.20|^10.1
- psalm/plugin-symfony: *
- symfony/profiler-pack: ^1.0
- symfony/yaml: ^5.4|^6.0
- symplify/coding-standard: *
- symplify/easy-coding-standard: *
- symplify/phpstan-rules: *
- vimeo/psalm: *
README
A widget bundle providing a watchdog which "woofs" if current time matches provided configuration.
Installation
composer require raneomik/watchdog-bundle
if not using symfony/flex, you need de register the bundle in your project :
// config/bundles.php return [ Raneomik\WatchdogBundle\WatchdogBundle::class => ['all' => true], ];
Configuration
It can be configured as follows:
#config/packages/watchdog.yml watchdog: default: # raise an event if current date time matches (following "Or" logic) - date_time: '2019-12-01 11:00' # a date and time - date: '2019-12-03' # a specific date - hour: '14:00' # a specific hour - time: '14:15' # or time - { start: '2019-12-01', end: '2019-12-31' } # an interval of dates - { start: '10:00', end: '11:00' } # or of times - relative: 'first wednesday of' # a relative format* - compound: # or a composite of the rules above, following "And" logic, for example : - relative: 'monday' # "On mondays" - { start: '20:00', end: '22:30' } # "and between 20:00 and 22:30" maintenance: # define another watchdogs, independent of each other. - compound: - relative: 'sundays' - { start: '05:00', end: '06:00' }
Watchdog service
This bundle provides the Raneomik\WatchdogBundle\Watchdog\WatchdogInterface
service that can be injected anywhere.
It has a isWoofTime
method returning true once configuration matches current date time.
If several ones are defined, they can be injected as follows (based on the example above) :
use Raneomik\WatchdogBundle\Watchdog\WatchdogInterface; class Service { __construct( private WatchdogInterface $default, private WatchdogInterface $maintenance ) { } ....
WatchdogHandlerInterface and WatchdogWoofCheckEvent
This bundle also provides the Raneomik\WatchdogBundle\Handler\WatchdogHandlerInterface
interface with processWoof(array $parameters = [])
method, for more complex processes.
It works with the WatchdogEventSubscriber
subscribed to WatchdogWoofCheckEvent
.
Anywhere you wish to check if it isWoofTime
, dispatch a new WatchdogWoofCheckEvent($parameters, $watchdogId)
,
and if it isWoofTime
, it will trigger all WatchdogHandlerInterface
s
and their processWoof(array $parameters = []) // passed to the WatchdogWoofCheckEvent constructor
.
$watchdogId
is null by default, which results in all defined watchdogs check.
If one is passed by this parameter, it checks only the concerned one.
If you wish to use it but your project isn't set to be autoconfigured, all your Handlers
implementing WatchdogHandlerInterface
must be tagged with raneomik_watchdog.handler
.
WIP: Profiler data collection
You can access watchdog data in Symfony profiler :