Logger   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 37
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A log() 0 19 4
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * This program is free software; you can redistribute it and/or
11
 * modify it under the terms of the GNU General Public License
12
 * as published by the Free Software Foundation; either version 2
13
 * of the License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23
 */
24
25
namespace Eccube\Log;
26
27
use Eccube\Application;
28
use Psr\Log\AbstractLogger;
29
30
class Logger extends AbstractLogger
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
31
{
32
    protected $app;
33
34 1091
    public function __construct(Application $app)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
35
    {
36 1091
        $this->app = $app;
37
    }
38
39
    /**
40
     * ログ出力を行う。アクセスされている画面によりログ出力先を分けている。
41
     *
42
     * @param mixed $level
0 ignored issues
show
introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
43
     * @param string $message
44
     * @param array $context
0 ignored issues
show
introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
45
     */
46 486
    public function log($level, $message, array $context = array())
47
    {
48 486
        if ($this->app->isFrontRequest()) {
49
            // フロント画面用のログ出力
50 174
            $this->app['monolog.logger.front']->log($level, $message, $context);
51 314
        } elseif ($this->app->isAdminRequest()) {
52
            // 管理画面用のログ出力
53 301
            $this->app['monolog.logger.admin']->log($level, $message, $context);
54
        } else {
55
            // 両方に当てはまらない場合、monolog用へログ出力
56 13
            $this->app['monolog']->log($level, $message, $context);
57
        }
58
59 486
        if ($this->app['debug']) {
60
            // debugが有効時はフロント、管理両方のログをmonologにも出力
61 483
            $this->app['monolog']->log($level, $message, $context);
62
        }
63
64
    }
65
66
}
67