Blame view

vendor/cakephp/debug_kit/src/Panel/LogPanel.php 1.43 KB
c4650843   Etienne Pallier   Ajout du dossier ...
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
<?php
/**
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
namespace DebugKit\Panel;

use Cake\Log\Log;
use DebugKit\DebugPanel;

/**
 * Log Panel - Reads log entries made this request.
 *
 */
class LogPanel extends DebugPanel
{

    /**
     * Initialize hook - sets up the log listener.
     *
     * @return void
     */
    public function initialize()
    {
        if (Log::getConfig('debug_kit_log_panel')) {
            return;
        }
        Log::setConfig('debug_kit_log_panel', [
            'engine' => 'DebugKit.DebugKit',
        ]);
    }

    /**
     * Get the panel data
     *
     * @return array
     */
    public function data()
    {
        return [
            'logger' => Log::engine('debug_kit_log_panel')
        ];
    }

    /**
     * Get the summary data.
     *
     * @return string
     */
    public function summary()
    {
        $logger = Log::engine('debug_kit_log_panel');
        if (!$logger) {
            return '0';
        }

        return (string)$logger->count();
    }
}