Yii2-LongLog
Yii2 extension for LongLog application
, (*1)
Installation
composer require "longlog/yii2-ext" "~1.0"
# Configurations
Edit /common/config/main.php
:, (*2)
<?php
return [
'components' => [
'longlog' => [
'class' => '\longlog\yii2\Component',
'endpointUrl' => 'http://api.longlog.ru',
'projectToken' => 'p8eGzXz5o4A2eulYhBvbrkghbAfirRwL',
],
],
];
# Usage
Variant 1: LongLog with client wrapper, (*3)
<?php
// New LongLog instance with client wrapper
$longLog = Yii::$app->longlog->newLog('CRON_SEND_EMAILS');
// Optionaly set payload any string
$longLog->setPayload("userIds: [1,2,3]");
// Remember the processing start time
$longLog->start();
// ...YOUR JOB HERE...
// Submit LongLog to API
$longLog->finish()->submit();
Variant 2: LongLog without client wrapper, (*4)
<?php
// New LongLog instance without client wrapper
$longLog = new \longlog\LongLog('CRON_SEND_EMAILS');
// Optionaly set payload any string
$longLog->setPayload("userIds: [1,2,3]");
// Remember the processing start time
$longLog->start();
// ...YOUR JOB HERE...
// Calculate job processing time and submit log to API
$longLog->finish();
Yii::$app->longlog->getClient()->submit($longLog);