amesplash / campaignmonitor-log
Campaign Monitor PSR-3 Log Decorator
1.0.0
2019-04-06 12:18 UTC
Requires
- php: ^7.2,<7.4
- campaignmonitor/createsend-php: ^6.0
- psr/log: ^1.1
Requires (Dev)
- eloquent/phony-phpunit: ^5.0
- phpstan/phpstan: ^0.11.5
- squizlabs/php_codesniffer: ^3.4
Provides
This package is auto-updated.
Last update: 2024-11-21 21:09:27 UTC
README
PSR-3 Log decorator for Campaign Monitor.
Installation
$ composer require amesplash/campaignmonitor-log
If not already available the above command will also install campaignmonitor/createsend-php
.
Usage
Construct a new LogDecorator instance with any PSR-3 compatible logger. You can pass through your default context as the second argument.
Construct your Campaign Monitor instances passing your desired log level and the LogDecorator instance.
<?php declare(strict_types=1); namespace App; use CS_REST_Campaigns; use Psr\Log\LoggerInterface; use Psr\Container\ContainerInterface; use Amesplash\CampaignMonitorLog\LogDecorator; final class MyCampaignMonitorCampaignFactory { public function __invoke(ContainerInterface $container) : CS_REST_Campaigns { $params = $container->get('params'); $psr3Logger = $container->get('monolog or any other PSR 3 Logger'); $defaultContext = [ 'Campaign' => 'Functional Dev', ]; $logDecorator = new LogDecorator($psr3Logger, $defaultContext); return new CS_REST_Campaigns( $params->get('campaignmonitor.campaign_id'), ['api_key' => $params->get('campaignmonitor.api_key')], 'https', CS_REST_LOG_VERBOSE, 'api.createsend.com', $logDecorator ); } }
Log Levels
This library maps the Camapign Monitor log levels defined in vendor/campaignmonitor/class/log.php
as follows:
If your log level is CS_REST_LOG_NONE
it will be pointless to instantiate the LogDecorator.