Skip to content

JDTB-31 Save log detail with Timestamp #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Api/LoggerManagementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface LoggerManagementInterface
* @param int $severity
* @param bool $createIssue
* @param \Exception $exception
* @param \DateTime $timestamp
* @return bool
*/
public function addEvent(
Expand All @@ -23,7 +24,8 @@ public function addEvent(
string $identifierValue = '',
int $severity = 1,
bool $createIssue = true,
\Exception $exception = null
\Exception $exception = null,
\DateTime $timestamp = null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These types are incorrect if null value is possible

): bool;

/**
Expand Down
6 changes: 4 additions & 2 deletions Service/LoggerManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class LoggerManagement implements LoggerManagementInterface
* @var ReportManagementInterface
*/
private $reportManagement;

public function __construct(
LogInterfaceFactory $logFactory,
LogRepositoryInterface $logRepository,
Expand Down Expand Up @@ -70,7 +70,8 @@ public function addEvent(
string $identifierValue = '',
int $severity = 1,
bool $createIssue = true,
\Exception $exception = null
\Exception $exception = null,
\DateTime $timestamp = null
): bool {
$issueId = 0;
if ($createIssue === true) {
Expand All @@ -84,6 +85,7 @@ public function addEvent(
$log->setSeverity($severity);
$log->setIdentifierLabel($identifierLabel);
$log->setIdentifierValue($identifierValue);
$timestamp ? $log->setTimestamp($timestamp->format('M j, Y g:i:s A')) : $log->setTimestamp(date('M j, Y g:i:s A'));
$this->logRepository->save($log);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<column xsi:type="int" name="severity" padding="11" unsigned="true" nullable="false" identity="false" comment="Severity"/>
<column xsi:type="varchar" name="identifier_label" nullable="true" length="20" comment="Identifier Label"/>
<column xsi:type="varchar" name="identifier_value" nullable="true" length="50" comment="Identifier Value"/>
<column xsi:type="timestamp" name="timestamp" nullable="false" default="CURRENT_TIMESTAMP" comment="Timestamp"/>
<column xsi:type="timestamp" name="timestamp" nullable="false" comment="Timestamp"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure here, it will not work if someone chooses to use default sync implementation. BTW I don't see any code for queues, so what is the point of this PR?

<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="logger_id"/>
</constraint>
Expand Down