Skip to content

Commit 5e24fa3

Browse files
### 0.3.3 - Fix logger path and way to call handler functions
1 parent e610edc commit 5e24fa3

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,5 @@
9090
### 0.3.1 - Logger Handler fix
9191

9292
### 0.3.2 - Response and Request handler can now be defined as a class member
93+
94+
### 0.3.3 - Fix logger path

src/support/forge/api/Traits/Client/Stackables.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
trait Stackables
1515
{
1616

17-
private $loggerFile = 'webapi-logs.log';
18-
1917
protected function getStacks($config)
2018
{
2119

@@ -25,19 +23,21 @@ protected function getStacks($config)
2523
$request = $this->getRequestStack($config['settings']['requestHandler']);
2624
$stack->push($request);
2725
}
28-
if (is_callable(static::requestHandler)) {
29-
$stack->push($this->getRequestStack(static::requestHandler));
26+
if (method_exists($this, 'requestHandler')) {
27+
$function = [$this, 'requestHandler'];
28+
$stack->push($this->getRequestStack($function));
3029
}
3130

3231
if (!empty($config['settings']['responseHandler'])) {
3332
$response = $this->getResponseStack($config['settings']['responseHandler']);
3433
$stack->push($response);
3534
}
36-
if (is_callable(static::responseHandler)) {
37-
$stack->push($this->getResponseStack(static::responseHandler));
35+
if (method_exists($this, 'responseHandler')) {
36+
$function = [$this, 'responseHandler'];
37+
$stack->push($this->getResponseStack($function));
3838
}
3939

40-
if ($config['log'] !== false) {
40+
if ($config['log'] ?? true !== false) {
4141
$logger = $this->getLoggerStack($config['log'] ?? null);
4242
$stack->push($logger);
4343
}
@@ -55,7 +55,7 @@ protected function getLoggerStack($loggerSettings)
5555
if (!($logger instanceof Logger)) {
5656
$logger = new Logger($loggerSettings['name'] ?? $this->loggerName ?? 'API');
5757
$logger->pushHandler(new RotatingFileHandler($loggerSettings['file'] ??
58-
$this->loggerFile ?? (__DIR__ . '/webapi-logs.log')));
58+
$this->loggerFile ?? ($this->getChildDir() . '/webapi-logs.log')));
5959
}
6060

6161
return Middleware::log($logger, new MessageFormatter($loggerFormat));

0 commit comments

Comments
 (0)