Skip to content

Commit 00b9ab7

Browse files
committed
add more fields
1 parent 9e9277b commit 00b9ab7

File tree

6 files changed

+72
-28
lines changed

6 files changed

+72
-28
lines changed

src/Understand/UnderstandLaravel5/Commands/DebugConnectionCommand.php

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

src/Understand/UnderstandLaravel5/ExceptionLogger.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ protected function getMetaFields()
138138
'user_agent' => 'UnderstandFieldProvider::getClientUserAgent',
139139
'laravel_version' => 'UnderstandFieldProvider::getLaravelVersion',
140140
'sql_queries' => 'UnderstandFieldProvider::getSqlQueries',
141+
'artisan_command' => 'UnderstandFieldProvider::getArtisanCommandName',
142+
'console' => 'UnderstandFieldProvider::getRunningInConsole',
143+
'logger_version' => 'UnderstandFieldProvider::getLoggerVersion',
141144
];
142145
}
143146

src/Understand/UnderstandLaravel5/FieldProvider.php

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ class FieldProvider
3434
'getProcessIdentifier',
3535
'getUserId',
3636
'getGroupId',
37+
'getLaravelVersion',
38+
'getSqlQueries',
39+
'getArtisanCommandName',
40+
'getRunningInConsole',
41+
'getLoggerVersion',
3742
];
3843

3944
/**
@@ -77,9 +82,11 @@ class FieldProvider
7782
protected $dataCollector;
7883

7984
/**
80-
* Create field provider instance and set default providers to provider list
81-
*
82-
* @param type $app
85+
* @var Application
86+
*/
87+
protected $app;
88+
89+
/**
8390
* @return void
8491
*/
8592
public function __construct()
@@ -90,6 +97,14 @@ public function __construct()
9097
}
9198
}
9299

100+
/**
101+
* @param Application $app
102+
*/
103+
public function setApp(Application $app)
104+
{
105+
$this->app = $app;
106+
}
107+
93108
/**
94109
* Set session store
95110
*
@@ -219,7 +234,7 @@ protected function getSessionId()
219234
{
220235
return null;
221236
}
222-
237+
223238
$sessionId = $this->session->getId();
224239

225240
// by default we provide only hashed version of session id
@@ -258,7 +273,7 @@ protected function getRouteName()
258273
{
259274
return null;
260275
}
261-
276+
262277
return $this->router->getCurrentRoute()->getName();
263278
}
264279

@@ -273,7 +288,7 @@ protected function getUrl()
273288
{
274289
return null;
275290
}
276-
291+
277292
$url = $this->request->path();
278293

279294
if ( ! starts_with($url, '/'))
@@ -302,7 +317,7 @@ protected function getRequestMethod()
302317
{
303318
return null;
304319
}
305-
320+
306321
return $this->request->method();
307322
}
308323

@@ -317,7 +332,7 @@ protected function getServerIp()
317332
{
318333
return null;
319334
}
320-
335+
321336
return $this->request->server->get('SERVER_ADDR');
322337
}
323338

@@ -332,7 +347,7 @@ protected function getClientIp()
332347
{
333348
return null;
334349
}
335-
350+
336351
return $this->request->getClientIp();
337352
}
338353

@@ -347,7 +362,7 @@ protected function getClientUserAgent()
347362
{
348363
return null;
349364
}
350-
365+
351366
return $this->request->server->get('HTTP_USER_AGENT');
352367
}
353368

@@ -373,7 +388,7 @@ protected function getFromSession($key)
373388
{
374389
return null;
375390
}
376-
391+
377392
return $this->session->get($key);
378393
}
379394

@@ -409,30 +424,57 @@ protected function getUserId()
409424
return $userId;
410425
}
411426
}
412-
catch (\Exception $e)
427+
catch (\Exception $e)
413428
{}
414429

415-
try
430+
try
416431
{
417432
if (class_exists('\Sentinel') && ($user = \Sentinel::getUser()))
418433
{
419434
return $user->id;
420435
}
421-
}
422-
catch (\Exception $e)
436+
}
437+
catch (\Exception $e)
423438
{}
424-
439+
425440
try
426441
{
427442
if (class_exists('\Sentry') && ($user = \Sentry::getUser()))
428443
{
429444
return $user->id;
430445
}
431446
}
432-
catch (\Exception $e)
447+
catch (\Exception $e)
433448
{}
434449
}
435450

451+
/**
452+
* @return string
453+
*/
454+
protected function getArtisanCommandName()
455+
{
456+
if ($this->app->runningInConsole() && isset($_SERVER['argv']))
457+
{
458+
return implode(' ', $_SERVER['argv']);
459+
}
460+
}
461+
462+
/**
463+
* @return bool
464+
*/
465+
protected function getRunningInConsole()
466+
{
467+
return $this->app->runningInConsole();
468+
}
469+
470+
/**
471+
* @return float
472+
*/
473+
protected function getLoggerVersion()
474+
{
475+
return Logger::VERSION;
476+
}
477+
436478
/**
437479
* Return process identifier token
438480
*

src/Understand/UnderstandLaravel5/Logger.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
class Logger
77
{
88

9+
/**
10+
* Version Number
11+
*/
12+
const VERSION = 2.0;
13+
914
/**
1015
* Field provider
1116
*

src/Understand/UnderstandLaravel5/UnderstandLaravel5ServiceProvider.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ protected function registerFieldProvider()
8787
$fieldProvider->setEnvironment($app->environment());
8888
$fieldProvider->setTokenProvider($app['understand.tokenProvider']);
8989
$fieldProvider->setDataCollector($app['understand.dataCollector']);
90+
$fieldProvider->setApp($app);
9091

9192
return $fieldProvider;
9293
});
@@ -291,12 +292,12 @@ protected function listenQueryEvents()
291292
*/
292293
protected function handleEvent($level, $message, $context)
293294
{
294-
// `info`, `debug` and NOT `\Exception` or `\Throwable`
295+
// `\Log::info`, `\Log::debug` and NOT `\Exception` or `\Throwable`
295296
if (in_array($level, ['info', 'debug']) && ! ($message instanceof Exception || $message instanceof Throwable))
296297
{
297298
$this->app['understand.eventLogger']->logEvent($level, $message, $context);
298299
}
299-
// `notice`, `warning`, `error`, `critical`, `alert`, `emergency` and `\Exception`, `\Throwable`
300+
// `\Log::notice`, `\Log::warning`, `\Log::error`, `\Log::critical`, `\Log::alert`, `\Log::emergency` and `\Exception`, `\Throwable`
300301
else
301302
{
302303
$this->app['understand.exceptionLogger']->logError($level, $message, $context);

src/config/understand-laravel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
*/
3131
'sql_enabled' => true,
3232

33-
// `info`, `debug` and NOT `\Exception` or `\Throwable`
33+
// `\Log::info`, `\Log::debug` and NOT `\Exception` or `\Throwable`
3434
'events' => [
3535
'meta' => [
3636
// ...
3737
]
3838
],
3939

40-
// `notice`, `warning`, `error`, `critical`, `alert`, `emergency` and `\Exception`, `\Throwable`
40+
// `\Log::notice`, `\Log::warning`, `\Log::error`, `\Log::critical`, `\Log::alert`, `\Log::emergency` and `\Exception`, `\Throwable`
4141
'errors' => [
4242
'meta' => [
4343
// ...

0 commit comments

Comments
 (0)