Skip to content

Commit ae15a4c

Browse files
committed
changed tracking ID generation
1 parent dbd3d69 commit ae15a4c

File tree

3 files changed

+7
-70
lines changed

3 files changed

+7
-70
lines changed

composer.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
},
2828
"extra": {
2929
"laravel": {
30-
"providers": [
31-
"PhpMonsters\\Log\\XLogServiceProvider"
32-
],
3330
"aliases": {
3431
"XLog": "PhpMonsters\\Log\\Facades\\XLog"
3532
}

src/Logger.php

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static function exception(Exception $e, bool $trace = false, string $name
3636
'code' => $e->getCode(),
3737
'file' => basename($e->getFile()),
3838
'line' => $e->getLine(),
39-
self::getTrackIdKey() => self::getTrackId(),
39+
'x_track_id' => REQUEST_TRACKING_ID,
4040
];
4141

4242
if ($trace) {
@@ -46,29 +46,6 @@ public static function exception(Exception $e, bool $trace = false, string $name
4646
return self::__callStatic($name, $arguments);
4747
}
4848

49-
/**
50-
* @return string
51-
*/
52-
public static function getTrackIdKey(): string
53-
{
54-
return env('XLOG_TRACK_ID_KEY', 'xTrackId');
55-
}
56-
57-
/**
58-
* @return string
59-
*/
60-
protected static function getTrackId(): string
61-
{
62-
$trackIdKey = self::getTrackIdKey();
63-
64-
try {
65-
$trackId = resolve($trackIdKey);
66-
} catch (Exception $e) {
67-
$trackId = '-';
68-
}
69-
70-
return $trackId;
71-
}
7249

7350
/**
7451
* @param $name
@@ -95,31 +72,20 @@ public static function __callStatic($name, $arguments)
9572
$arguments[1] = [$arguments[1]];
9673
}
9774

98-
$arguments[1]['sid'] = self::getSessionId();
99-
10075
$arguments[1]['uip'] = @clientIp();
10176

10277
// add user id to all logs
10378
$arguments[1]['uid'] = self::getUserTag(); // user id as a tag
10479

105-
// get request track ID from service container
106-
$trackIdKey = self::getTrackIdKey();
107-
if (!isset($arguments[1][$trackIdKey])) {
108-
$arguments[1][$trackIdKey] = self::getTrackId($trackIdKey);
80+
if (session_status() === PHP_SESSION_ACTIVE) {
81+
$arguments[1]['sid'] = session_id();
10982
}
11083

111-
return call_user_func_array(['Illuminate\Support\Facades\Log', $name], $arguments);
112-
}
84+
// get request track ID from service container
85+
$arguments[1]['x_track_id'] = REQUEST_TRACKING_ID;
11386

114-
/**
115-
* @return string
116-
*/
117-
private static function getSessionId(): string
118-
{
119-
if (session_status() === PHP_SESSION_ACTIVE) {
120-
return session_id();
121-
}
122-
return '';
87+
88+
return call_user_func_array(['Illuminate\Support\Facades\Log', $name], $arguments);
12389
}
12490

12591
/**

src/XLogServiceProvider.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)