4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.7 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2017 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
30 * Class CRM_Core_Error_Log
32 * A PSR-3 wrapper for CRM_Core_Error.
34 class CRM_Core_Error_Log
extends \Psr\Log\AbstractLogger
{
37 * CRM_Core_Error_Log constructor.
39 public function __construct() {
41 \Psr\Log\LogLevel
::DEBUG
=> PEAR_LOG_DEBUG
,
42 \Psr\Log\LogLevel
::INFO
=> PEAR_LOG_INFO
,
43 \Psr\Log\LogLevel
::NOTICE
=> PEAR_LOG_NOTICE
,
44 \Psr\Log\LogLevel
::WARNING
=> PEAR_LOG_WARNING
,
45 \Psr\Log\LogLevel
::ERROR
=> PEAR_LOG_ERR
,
46 \Psr\Log\LogLevel
::CRITICAL
=> PEAR_LOG_CRIT
,
47 \Psr\Log\LogLevel
::ALERT
=> PEAR_LOG_ALERT
,
48 \Psr\Log\LogLevel
::EMERGENCY
=> PEAR_LOG_EMERG
,
53 * Logs with an arbitrary level.
56 * @param string $message
57 * @param array $context
59 public function log($level, $message, array $context = array()) {
60 // FIXME: This flattens a $context a bit prematurely. When integrating
61 // with external/CMS logs, we should pass through $context.
62 if (!empty($context)) {
63 if (isset($context['exception'])) {
64 $context['exception'] = CRM_Core_Error
::formatTextException($context['exception']);
66 $message .= "\n" . print_r($context, 1);
68 if (CRM_Utils_System
::isDevelopment() && CRM_Utils_Array
::value('civi.tag', $context) === 'deprecated') {
69 trigger_error($message, E_USER_DEPRECATED
);
72 CRM_Core_Error
::debug_log_message($message, FALSE, '', $this->map
[$level]);