Skip to content

Commit 9696f40

Browse files
committed
fixed bug in adding trackId
1 parent 18c4c27 commit 9696f40

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/Logger.php

+14-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __call($name, $arguments)
2424
$name = 'debug';
2525
}
2626

27-
return call_user_func_array(['Illuminate\Support\Facades\Log', $name], $arguments);
27+
return self::__callStatic($name, $arguments);
2828
}
2929

3030
/**
@@ -35,6 +35,10 @@ public function __call($name, $arguments)
3535
*/
3636
public static function __callStatic($name, $arguments)
3737
{
38+
if (!in_array($name, self::$LOG_LEVELS)) {
39+
$name = 'debug';
40+
}
41+
3842
if (session_status() == PHP_SESSION_NONE) {
3943
$arguments[1]['sid'] = session_id();
4044
} else {
@@ -52,6 +56,7 @@ public static function __callStatic($name, $arguments)
5256
$trackIdKey = env('XLOG_TRACK_ID_KEY', 'xTrackId');
5357

5458
// get request track ID from service container
59+
5560
if (!isset($arguments[1][$trackIdKey])) {
5661
$arguments[1][$trackIdKey] = self::getTrackId($trackIdKey);
5762
}
@@ -65,20 +70,20 @@ public static function __callStatic($name, $arguments)
6570
*
6671
* @return mixed
6772
*/
68-
public static function exception(Exception $e, $level = 'error')
73+
public static function exception(Exception $e, $name = 'error')
6974
{
7075
$trackIdKey = env('XLOG_TRACK_ID_KEY', 'xTrackId');
7176

7277
$arguments = [];
7378
$arguments [0] = 'exception' . $e->getMessage();
7479
$arguments [1] = [
75-
'code' => $e->getCode(),
76-
'file' => basename($e->getFile()),
77-
'line' => $e->getLine(),
78-
$trackIdKey => self::getTrackId($trackIdKey)
80+
'code' => $e->getCode(),
81+
'file' => basename($e->getFile()),
82+
'line' => $e->getLine(),
83+
$trackIdKey => self::getTrackId($trackIdKey),
7984
];
8085

81-
return call_user_func_array(['Tartan\Log\Logger', $level], $arguments);
86+
return self::__callStatic($name, $arguments);
8287
}
8388

8489
/**
@@ -93,6 +98,8 @@ protected static function getTrackId($trackIdKey)
9398
} catch (Exception $e) {
9499
$trackId = '-';
95100
}
101+
96102
return $trackId;
97103
}
104+
98105
}

0 commit comments

Comments
 (0)