-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.php
77 lines (64 loc) · 1.76 KB
/
start.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/*
|--------------------------------------------------------------------------
| Include Vendors
|--------------------------------------------------------------------------
|
| Include FirePHP class as FireAnbu dependency.
|
*/
Autoloader::map(array(
'FirePHP' => Bundle::path('fireanbu').'vendors'.DS.'FirePHPCore'.DS.'FirePHP.class'.EXT,
));
/*
|--------------------------------------------------------------------------
| FireAnbu IoC
|--------------------------------------------------------------------------
|
| Register FirePHP singleton using IoC, in case you need to overwrite the
| implementation in your application.
|
*/
IoC::singleton('fireanbu', function ()
{
$fb = new FirePHP;
$fb->setEnabled(Config::get('fireanbu::fireanbu.profiler', true));
return $fb;
});
/*
|--------------------------------------------------------------------------
| Listen to `laravel.log` events
|--------------------------------------------------------------------------
*/
Event::listen('laravel.log', function ($type, $message)
{
$fb = IoC::resolve('fireanbu');
switch (Str::upper($type))
{
case FirePHP::INFO :
case FirePHP::WARN :
case FirePHP::LOG :
case FirePHP::ERROR :
$fb->{$type}($message);
break;
default :
$fb->log($message);
break;
}
});
/*
|--------------------------------------------------------------------------
| Listen to `laravel.query` events
|--------------------------------------------------------------------------
*/
Event::listen('laravel.query', function($sql, $bindings, $time)
{
$fb = IoC::resolve('fireanbu');
foreach ($bindings as $binding)
{
$binding = \DB::connection()->pdo->quote($binding);
$sql = preg_replace('/\?/', $binding, $sql, 1);
$sql = htmlspecialchars($sql);
}
$fb->info($sql, "{$time}ms");
});