Refactor Newsletter and Bridge to use logger_factory instance
[MAILPOET-2444]
This commit is contained in:
committed by
Jack Kitterhing
parent
e4262b0a6d
commit
0a4aa5ce3f
@ -12,9 +12,13 @@ class AutomatedLatestContent {
|
||||
private $newsletter_id;
|
||||
private $newer_than_timestamp;
|
||||
|
||||
/** @var LoggerFactory */
|
||||
private $logger_factory;
|
||||
|
||||
function __construct($newsletter_id = false, $newer_than_timestamp = false) {
|
||||
$this->newsletter_id = $newsletter_id;
|
||||
$this->newer_than_timestamp = $newer_than_timestamp;
|
||||
$this->logger_factory = LoggerFactory::getInstance();
|
||||
}
|
||||
|
||||
function filterOutSentPosts($where) {
|
||||
@ -42,7 +46,7 @@ class AutomatedLatestContent {
|
||||
$current_user_id = WPFunctions::get()->getCurrentUserId();
|
||||
WPFunctions::get()->wpSetCurrentUser(0);
|
||||
|
||||
LoggerFactory::getLogger('post-notifications')->addInfo(
|
||||
$this->logger_factory->getLogger('post-notifications')->addInfo(
|
||||
'loading automated latest content',
|
||||
['args' => $args, 'posts_to_exclude' => $posts_to_exclude, 'newsletter_id' => $this->newsletter_id, 'newer_than_timestamp' => $this->newer_than_timestamp]
|
||||
);
|
||||
@ -91,7 +95,7 @@ class AutomatedLatestContent {
|
||||
WPFunctions::get()->addAction('pre_get_posts', [$this, 'ensureConsistentQueryType'], $filter_priority);
|
||||
$this->_attachSentPostsFilter();
|
||||
|
||||
LoggerFactory::getLogger('post-notifications')->addInfo(
|
||||
$this->logger_factory->getLogger('post-notifications')->addInfo(
|
||||
'getting automated latest content',
|
||||
['parameters' => $parameters]
|
||||
);
|
||||
@ -166,7 +170,7 @@ class AutomatedLatestContent {
|
||||
'post_date' => $post->post_date,
|
||||
];
|
||||
}
|
||||
LoggerFactory::getLogger('post-notifications')->addInfo(
|
||||
$this->logger_factory->getLogger('post-notifications')->addInfo(
|
||||
'automated latest content loaded posts',
|
||||
['posts' => $posts_to_log]
|
||||
);
|
||||
|
@ -23,8 +23,15 @@ class PostNotificationScheduler {
|
||||
const INTERVAL_IMMEDIATE = 'immediate';
|
||||
const INTERVAL_MONTHLY = 'monthly';
|
||||
|
||||
/** @var LoggerFactory */
|
||||
private $logger_factory;
|
||||
|
||||
public function __construct() {
|
||||
$this->logger_factory = LoggerFactory::getInstance();
|
||||
}
|
||||
|
||||
function transitionHook($new_status, $old_status, $post) {
|
||||
LoggerFactory::getLogger('post-notifications')->addInfo(
|
||||
$this->logger_factory->getLogger('post-notifications')->addInfo(
|
||||
'transition post notification hook initiated',
|
||||
[
|
||||
'post_id' => $post->ID,
|
||||
@ -40,7 +47,7 @@ class PostNotificationScheduler {
|
||||
}
|
||||
|
||||
function schedulePostNotification($post_id) {
|
||||
LoggerFactory::getLogger('post-notifications')->addInfo(
|
||||
$this->logger_factory->getLogger('post-notifications')->addInfo(
|
||||
'schedule post notification hook',
|
||||
['post_id' => $post_id]
|
||||
);
|
||||
@ -88,7 +95,7 @@ class PostNotificationScheduler {
|
||||
$sending_task->status = SendingQueue::STATUS_SCHEDULED;
|
||||
$sending_task->scheduled_at = $next_run_date;
|
||||
$sending_task->save();
|
||||
LoggerFactory::getLogger('post-notifications')->addInfo(
|
||||
$this->logger_factory->getLogger('post-notifications')->addInfo(
|
||||
'schedule post notification',
|
||||
['sending_task' => $sending_task->id(), 'scheduled_at' => $next_run_date]
|
||||
);
|
||||
@ -135,5 +142,4 @@ class PostNotificationScheduler {
|
||||
$relation->save();
|
||||
return $relation->value;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ class API {
|
||||
|
||||
private $api_key;
|
||||
private $wp;
|
||||
/** @var LoggerFactory */
|
||||
private $logger_factory;
|
||||
|
||||
public $url_me = 'https://bridge.mailpoet.com/api/v0/me';
|
||||
public $url_premium = 'https://bridge.mailpoet.com/api/v0/premium';
|
||||
@ -37,6 +39,7 @@ class API {
|
||||
} else {
|
||||
$this->wp = $wp;
|
||||
}
|
||||
$this->logger_factory = LoggerFactory::getInstance();
|
||||
}
|
||||
|
||||
function checkMSSKey() {
|
||||
@ -81,7 +84,7 @@ class API {
|
||||
}
|
||||
|
||||
function logCurlInformation($headers, $info) {
|
||||
LoggerFactory::getLogger('mss')->addInfo(
|
||||
$this->logger_factory->getLogger('mss')->addInfo(
|
||||
'requests-curl.after_request',
|
||||
['headers' => $headers, 'curl_info' => $info]
|
||||
);
|
||||
|
Reference in New Issue
Block a user