Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
feat(Logger): allow predefine default ITEM_ID like AUDIT_TYPE_ID
Browse files Browse the repository at this point in the history
  • Loading branch information
Constantine Karnaukhov committed Oct 25, 2018
1 parent 4504833 commit 9a4daf6
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class Logger {
private $moduleId = null;
private $auditTypeId = null;
private $itemId = null;

public function __construct($moduleId) {
$this->moduleId = $moduleId;
Expand All @@ -28,6 +29,22 @@ public function setAuditTypeId($auditTypeId): void {
$this->auditTypeId = $auditTypeId;
}

/**
* Get predefined item id
* @return string | null
*/
public function getItemId() {
return $this->itemId;
}

/**
* Set item id
* @param string $itemId
*/
public function setItemId($itemId): void {
$this->itemId = $itemId;
}

/**
* Add message to event log
* @param string | array $message log message string or array with fields to pass into CEventLog::Add
Expand All @@ -36,7 +53,7 @@ public function log($message): void {
$defaults = [
'SEVERITY' => 'INFO',
'AUDIT_TYPE_ID' => $this->auditTypeId,
'ITEM_ID' => '',
'ITEM_ID' => $this->itemId ?: '',
];

$message = $this->logMessToArray($message);
Expand Down

0 comments on commit 9a4daf6

Please sign in to comment.