job-runner/psr-log-adapter

1.3.0 2024-04-25 10:55 UTC

README

Build Status Type Coverage Type Coverage Latest Stable Version License

This package provides a psr-log adapter for JobRunner.

Installation

composer require job-runner/psr-log-adapter

Usage

<?php

declare(strict_types=1);

use JobRunner\JobRunner\Job\CliJob;
use JobRunner\JobRunner\Job\JobList;
use JobRunner\JobRunner\CronJobRunner;
use JobRunner\JobRunner\PsrLog\PsrLogEventListener;

require 'vendor/autoload.php';


$myLogger = new \Psr\Log\NullLogger();
$jobList = new JobList();
$jobList->push(new CliJob('php ' . __DIR__ . '/tutu.php', '* * * * *'));

CronJobRunner::create()->withEventListener(new PsrLogEventListener($myLogger));->run($jobList);