Skip to content

Commit 0f39f4c

Browse files
author
Alexandre
committed
Corrected some little bugs and exceptions for returning values from log methods.
1 parent c44f4c2 commit 0f39f4c

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

src/Route.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function __construct(array $attributes = []) {
9090
* @param array $context
9191
* @return bool
9292
*/
93-
abstract public function log($level, $message, array $context = array()): bool;
93+
abstract public function log($level, $message, array $context = []): bool;
9494

9595
/**
9696
* Current date

src/route/DatabaseRoute.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PDO;
1515
use smalex86\logger\Route;
16-
use smalex86\logger\LoggerException;
1716

1817
/**
1918
* DatabaseRoute
@@ -88,7 +87,7 @@ public function __construct(array $attributes = [])
8887
/**
8988
* @inheritdoc
9089
*/
91-
public function log($level, $message, array $context = [])
90+
public function log($level, $message, array $context = []): bool
9291
{
9392
// if level set in psrloglevel string
9493
if (is_string($level)) {
@@ -117,7 +116,7 @@ public function log($level, $message, array $context = [])
117116
$statement->bindParam(':message', $message);
118117
$context = $this->contextStringify($context);
119118
$statement->bindParam(':context', $context);
120-
$statement->execute();
119+
return $statement->execute();
121120
}
122121

123122
}

src/route/FileRoute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(array $attributes = []) {
5151
* @param array $context
5252
* @return bool
5353
*/
54-
public function log($level, $message, array $context = array()): bool
54+
public function log($level, $message, array $context = []): bool
5555
{
5656
// if level set in psrloglevel string
5757
if (is_string($level)) {

src/route/SyslogRoute.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ class SyslogRoute extends Route {
2929
/**
3030
* @inheritdoc
3131
*/
32-
public function log($level, $message, array $context = [])
32+
public function log($level, $message, array $context = []): bool
3333
{
3434
$level = $this->getLogLevelFromRsrLogLevel($level);
3535
if ($level == -1) {
36-
return;
36+
return false;
3737
}
3838
// check for requirement of writing
3939
// it is determined by log maxLevel and msg level
4040
if ($this->maxLevel < $level) {
4141
return false;
4242
}
43-
syslog($level, trim(strtr($this->template, [
43+
return syslog($level, trim(strtr($this->template, [
4444
'{message}' => $message,
4545
'{context}' => $this->contextStringify($context),
4646
])));

0 commit comments

Comments
 (0)