-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PON-521: Added log handler for razorpay logs (#191)
- Loading branch information
Showing
3 changed files
with
79 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace Razorpay\Magento\Model; | ||
|
||
use Magento\Framework\Filesystem\DriverInterface; | ||
use Monolog\Formatter\LineFormatter; | ||
use Monolog\Handler\StreamHandler; | ||
use Monolog\Logger; | ||
/** | ||
* Used to display webhook url link | ||
*/ | ||
class LogHandler extends \Magento\Framework\Logger\Handler\Base | ||
{ | ||
/** | ||
* Logging level | ||
* @var int | ||
*/ | ||
protected $loggerType = Logger::INFO; | ||
|
||
/** | ||
* File name | ||
* @var string | ||
*/ | ||
public $fileName = ''; | ||
/** | ||
* File name | ||
* @var string | ||
*/ | ||
public $cutomfileName = 'NO_PATH'; | ||
/** | ||
* @var TimezoneInterface | ||
*/ | ||
protected $_localeDate; | ||
|
||
public function __construct( | ||
DriverInterface $filesystem, | ||
\Magento\Framework\Filesystem $corefilesystem, | ||
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, | ||
$filePath = null | ||
) { | ||
$this->_localeDate = $localeDate; | ||
$corefilesystem= $corefilesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR); | ||
$logpath = $corefilesystem->getAbsolutePath('log/Razorpay/'); | ||
|
||
|
||
// Custom log file name for each day because log will be full for optimization | ||
$filename = 'rzp_'.Date('Y_m_d').'.log'; | ||
|
||
$filepath = $logpath . $filename; | ||
|
||
$this->cutomfileName = $filepath; | ||
|
||
parent::__construct( | ||
$filesystem, | ||
$filepath | ||
); | ||
|
||
} | ||
} |