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 |
|
|
|
|
31
|
|
|
{ |
32
|
|
|
protected $app; |
33
|
|
|
|
34
|
1192 |
|
public function __construct(Application $app) |
35
|
|
|
{ |
36
|
1192 |
|
$this->app = $app; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* ログ出力を行う。アクセスされている画面によりログ出力先を分けている。 |
41
|
|
|
* |
42
|
|
|
* @param mixed $level |
|
|
|
|
43
|
|
|
* @param string $message |
44
|
|
|
* @param array $context |
|
|
|
|
45
|
|
|
*/ |
46
|
587 |
|
public function log($level, $message, array $context = array()) |
47
|
|
|
{ |
48
|
587 |
|
if ($this->app->isFrontRequest()) { |
49
|
|
|
// フロント画面用のログ出力 |
50
|
264 |
|
$this->app['monolog.logger.front']->log($level, $message, $context); |
51
|
325 |
|
} elseif ($this->app->isAdminRequest()) { |
52
|
|
|
// 管理画面用のログ出力 |
53
|
312 |
|
$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
|
587 |
|
if ($this->app['debug']) { |
60
|
|
|
// debugが有効時はフロント、管理両方のログをmonologにも出力 |
61
|
584 |
|
$this->app['monolog']->log($level, $message, $context); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
} |
67
|
|
|
|