Version Description
- 2020-06-04 =
- Add - PHP 7.4 support
- Fix - Fatal error: Replace Monolog library with custom logging because conflicts with other versions used by other plugins that causing website crashing
Download this release
Release Info
Developer | antoscarface |
Plugin | Pixel Caffeine |
Version | 2.1.3 |
Comparing to | |
See all releases |
Code changes from version 2.1.2 to 2.1.3
- includes/admin/class-aepc-admin-logger.php +16 -29
- includes/admin/logs/class-log-db-handler.php +0 -48
- includes/product-catalogs/feed/class-xml-writer.php +1 -1
- languages/pixel-caffeine.pot +4 -4
- pixel-caffeine.php +3 -3
- readme.txt +6 -2
- vendor/autoload.php +1 -1
- vendor/composer/autoload_classmap.php +0 -1
- vendor/composer/autoload_psr4.php +0 -2
- vendor/composer/autoload_real.php +7 -7
- vendor/composer/autoload_static.php +4 -21
- vendor/composer/installed.json +0 -129
- vendor/monolog/monolog/CHANGELOG.md +0 -388
- vendor/monolog/monolog/LICENSE +0 -19
- vendor/monolog/monolog/src/Monolog/ErrorHandler.php +0 -239
- vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php +0 -78
- vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php +0 -89
- vendor/monolog/monolog/src/Monolog/Formatter/FlowdockFormatter.php +0 -116
- vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php +0 -86
- vendor/monolog/monolog/src/Monolog/Formatter/FormatterInterface.php +0 -36
- vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php +0 -138
- vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php +0 -141
- vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php +0 -208
- vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php +0 -181
- vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php +0 -47
- vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php +0 -166
- vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php +0 -107
- vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php +0 -297
- vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php +0 -48
- vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php +0 -113
- vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php +0 -196
- vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php +0 -68
- vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php +0 -101
- vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php +0 -148
- vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php +0 -240
- vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php +0 -129
- vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php +0 -211
- vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php +0 -72
- vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php +0 -151
- vendor/monolog/monolog/src/Monolog/Handler/Curl/Util.php +0 -57
- vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php +0 -169
- vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php +0 -45
- vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php +0 -107
- vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php +0 -128
- vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php +0 -82
- vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php +0 -140
- vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php +0 -28
- vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php +0 -59
- vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php +0 -34
- vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php +0 -177
- vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php +0 -195
- vendor/monolog/monolog/src/Monolog/Handler/FleepHookHandler.php +0 -126
- vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php +0 -127
- vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerInterface.php +0 -39
- vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerTrait.php +0 -63
- vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php +0 -65
- vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php +0 -117
- vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php +0 -90
- vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php +0 -116
- vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php +0 -367
- vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php +0 -69
- vendor/monolog/monolog/src/Monolog/Handler/InsightOpsHandler.php +0 -62
- vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php +0 -55
- vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php +0 -102
- vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php +0 -67
- vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php +0 -68
- vendor/monolog/monolog/src/Monolog/Handler/MissingExtensionException.php +0 -21
- vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php +0 -59
- vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php +0 -185
- vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php +0 -204
- vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php +0 -45
- vendor/monolog/monolog/src/Monolog/Handler/PHPConsoleHandler.php +0 -242
- vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerInterface.php +0 -40
- vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerTrait.php +0 -73
- vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php +0 -56
- vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php +0 -185
- vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php +0 -234
- vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php +0 -97
- vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php +0 -144
- vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php +0 -190
- vendor/monolog/monolog/src/Monolog/Handler/SamplingHandler.php +0 -82
- vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php +0 -294
- vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php +0 -220
- vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php +0 -120
- vendor/monolog/monolog/src/Monolog/Handler/SlackbotHandler.php +0 -84
- vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php +0 -385
- vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php +0 -177
- vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php +0 -111
- vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php +0 -67
- vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php +0 -56
- vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php +0 -124
- vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php +0 -177
- vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php +0 -72
- vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php +0 -101
- vendor/monolog/monolog/src/Monolog/Logger.php +0 -791
- vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php +0 -64
- vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php +0 -112
- vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php +0 -35
- vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php +0 -63
- vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php +0 -35
- vendor/monolog/monolog/src/Monolog/Processor/MercurialProcessor.php +0 -63
- vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php +0 -31
- vendor/monolog/monolog/src/Monolog/Processor/ProcessorInterface.php +0 -25
- vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php +0 -50
- vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php +0 -44
- vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php +0 -59
- vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php +0 -113
- vendor/monolog/monolog/src/Monolog/Registry.php +0 -134
- vendor/monolog/monolog/src/Monolog/ResettableInterface.php +0 -31
- vendor/monolog/monolog/src/Monolog/SignalHandler.php +0 -115
- vendor/monolog/monolog/src/Monolog/Utils.php +0 -25
- vendor/psr/log/LICENSE +0 -19
- vendor/psr/log/Psr/Log/AbstractLogger.php +0 -128
- vendor/psr/log/Psr/Log/InvalidArgumentException.php +0 -7
- vendor/psr/log/Psr/Log/LogLevel.php +0 -18
- vendor/psr/log/Psr/Log/LoggerAwareInterface.php +0 -18
- vendor/psr/log/Psr/Log/LoggerAwareTrait.php +0 -26
- vendor/psr/log/Psr/Log/LoggerInterface.php +0 -123
- vendor/psr/log/Psr/Log/LoggerTrait.php +0 -140
- vendor/psr/log/Psr/Log/NullLogger.php +0 -28
- vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php +0 -144
- vendor/psr/log/Psr/Log/Test/TestLogger.php +0 -146
includes/admin/class-aepc-admin-logger.php
CHANGED
@@ -1,8 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
use
|
4 |
-
use PixelCaffeine\Logs\
|
5 |
-
use Psr\Log\LoggerInterface;
|
6 |
|
7 |
if ( ! defined( 'ABSPATH' ) ) {
|
8 |
exit; // Exit if accessed directly.
|
@@ -13,32 +12,11 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
13 |
*/
|
14 |
class AEPC_Admin_Logger {
|
15 |
|
16 |
-
const LOG_NAME = 'aepc-fb-api';
|
17 |
-
const LOGS_DIR = '/pixel-caffeine';
|
18 |
-
const LOG_FILENAME = 'logs-%s.log';
|
19 |
-
|
20 |
-
/** @var LoggerInterface */
|
21 |
-
protected $logger;
|
22 |
-
|
23 |
/**
|
24 |
* Setup the logger
|
25 |
*/
|
26 |
public function setup() {
|
27 |
-
global $wpdb;
|
28 |
|
29 |
-
$this->logger = new Logger( self::LOG_NAME );
|
30 |
-
$this->logger->pushHandler( new LogDBHandler( $wpdb ) );
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Get the path to log
|
35 |
-
*
|
36 |
-
* @return string
|
37 |
-
*/
|
38 |
-
protected function get_log_path() {
|
39 |
-
$upload_dir = wp_upload_dir();
|
40 |
-
$filename = sprintf( self::LOG_FILENAME, sanitize_file_name( wp_hash( self::LOG_FILENAME ) ) );
|
41 |
-
return $upload_dir['basedir'] . self::LOGS_DIR . '/' . $filename;
|
42 |
}
|
43 |
|
44 |
/**
|
@@ -53,15 +31,24 @@ class AEPC_Admin_Logger {
|
|
53 |
*
|
54 |
* @param string $message
|
55 |
* @param array $context
|
|
|
|
|
56 |
*/
|
57 |
public function log( $message, array $context = array() ) {
|
58 |
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
59 |
|
60 |
-
$
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
66 |
|
67 |
}
|
1 |
<?php
|
2 |
|
3 |
+
use PixelCaffeine\Logs\Entity\Log;
|
4 |
+
use PixelCaffeine\Logs\LogRepository;
|
|
|
5 |
|
6 |
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
exit; // Exit if accessed directly.
|
12 |
*/
|
13 |
class AEPC_Admin_Logger {
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
/**
|
16 |
* Setup the logger
|
17 |
*/
|
18 |
public function setup() {
|
|
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
|
22 |
/**
|
31 |
*
|
32 |
* @param string $message
|
33 |
* @param array $context
|
34 |
+
*
|
35 |
+
* @throws Exception
|
36 |
*/
|
37 |
public function log( $message, array $context = array() ) {
|
38 |
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
39 |
|
40 |
+
$exception = $context['exception'];
|
41 |
+
unset( $context['exception'] );
|
42 |
+
|
43 |
+
$log = new Log(
|
44 |
+
$exception,
|
45 |
+
$message,
|
46 |
+
new \DateTime(),
|
47 |
+
$context
|
48 |
+
);
|
49 |
+
|
50 |
+
$repository = new LogRepository();
|
51 |
+
$repository->save( $log );
|
52 |
}
|
53 |
|
54 |
}
|
includes/admin/logs/class-log-db-handler.php
DELETED
@@ -1,48 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace PixelCaffeine\Logs;
|
4 |
-
|
5 |
-
|
6 |
-
use Monolog\Handler\AbstractProcessingHandler;
|
7 |
-
use Monolog\Logger;
|
8 |
-
use PixelCaffeine\Logs\Entity\Log;
|
9 |
-
|
10 |
-
class LogDBHandler extends AbstractProcessingHandler {
|
11 |
-
|
12 |
-
/**
|
13 |
-
* @var \wpdb
|
14 |
-
*/
|
15 |
-
protected $wpdb;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @param \wpdb $wpdb
|
19 |
-
* @param bool|int $level The minimum logging level at which this handler will be triggered
|
20 |
-
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
21 |
-
*/
|
22 |
-
public function __construct( \wpdb $wpdb, $level = Logger::DEBUG, $bubble = true ) {
|
23 |
-
$this->wpdb = $wpdb;
|
24 |
-
parent::__construct( $level, $bubble );
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Writes the record down to the log of the implementing handler
|
29 |
-
*
|
30 |
-
* @param array $record
|
31 |
-
*
|
32 |
-
* @return void
|
33 |
-
*/
|
34 |
-
protected function write( array $record ) {
|
35 |
-
$exception = $record['context']['exception'];
|
36 |
-
unset( $record['context']['exception'] );
|
37 |
-
|
38 |
-
$log = new Log(
|
39 |
-
$exception,
|
40 |
-
$record['message'],
|
41 |
-
$record['datetime'],
|
42 |
-
$record['context']
|
43 |
-
);
|
44 |
-
|
45 |
-
$repository = new LogRepository();
|
46 |
-
$repository->save( $log );
|
47 |
-
}
|
48 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/product-catalogs/feed/class-xml-writer.php
CHANGED
@@ -463,7 +463,7 @@ class XMLWriter implements WriterInterface {
|
|
463 |
$length = strlen($string);
|
464 |
for ($i=0; $i < $length; $i++)
|
465 |
{
|
466 |
-
$current = ord($string
|
467 |
if (($current == 0x9) ||
|
468 |
($current == 0xA) ||
|
469 |
($current == 0xD) ||
|
463 |
$length = strlen($string);
|
464 |
for ($i=0; $i < $length; $i++)
|
465 |
{
|
466 |
+
$current = ord($string[$i]);
|
467 |
if (($current == 0x9) ||
|
468 |
($current == 0xA) ||
|
469 |
($current == 0xD) ||
|
languages/pixel-caffeine.pot
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
# Copyright (C)
|
2 |
# This file is distributed under the same license as the Pixel Caffeine package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Pixel Caffeine 2.1.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/pixel-caffeine\n"
|
7 |
-
"POT-Creation-Date:
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
11 |
-
"PO-Revision-Date:
|
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
"Language: en\n"
|
1 |
+
# Copyright (C) 2020 AdEspresso
|
2 |
# This file is distributed under the same license as the Pixel Caffeine package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Pixel Caffeine 2.1.3\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/pixel-caffeine\n"
|
7 |
+
"POT-Creation-Date: 2020-06-04 15:56:47+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"PO-Revision-Date: 2020-MO-DA HO:MI+ZONE\n"
|
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
"Language: en\n"
|
pixel-caffeine.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* Author URI: https://adespresso.com/
|
8 |
* Text Domain: pixel-caffeine
|
9 |
* Domain Path: /languages
|
10 |
-
* Version: 2.1.
|
11 |
* WC requires at least: 3.0.0
|
12 |
* WC tested up to: 4.0.1
|
13 |
*
|
@@ -24,12 +24,12 @@ if ( ! class_exists( 'PixelCaffeine' ) ) :
|
|
24 |
* Main PixelCaffeine Class.
|
25 |
*
|
26 |
* @class PixelCaffeine
|
27 |
-
* @version 2.1.
|
28 |
*/
|
29 |
final class PixelCaffeine {
|
30 |
|
31 |
/** @var string PixelCaffeine version. */
|
32 |
-
public $version = '2.1.
|
33 |
|
34 |
/** @var PixelCaffeine The single instance of the class. */
|
35 |
protected static $_instance = null;
|
7 |
* Author URI: https://adespresso.com/
|
8 |
* Text Domain: pixel-caffeine
|
9 |
* Domain Path: /languages
|
10 |
+
* Version: 2.1.3
|
11 |
* WC requires at least: 3.0.0
|
12 |
* WC tested up to: 4.0.1
|
13 |
*
|
24 |
* Main PixelCaffeine Class.
|
25 |
*
|
26 |
* @class PixelCaffeine
|
27 |
+
* @version 2.1.3
|
28 |
*/
|
29 |
final class PixelCaffeine {
|
30 |
|
31 |
/** @var string PixelCaffeine version. */
|
32 |
+
public $version = '2.1.3';
|
33 |
|
34 |
/** @var PixelCaffeine The single instance of the class. */
|
35 |
protected static $_instance = null;
|
readme.txt
CHANGED
@@ -4,8 +4,8 @@ Donate link: https://adespresso.com/
|
|
4 |
Tags: facebook, facebook pixel, facebook ad, facebook insertions, custom audiences, dynamic events, woocommerce
|
5 |
Requires at least: 4.4
|
6 |
Requires PHP: 5.6
|
7 |
-
Tested up to: 5.4
|
8 |
-
Stable tag: 2.1.
|
9 |
License: GPLv3
|
10 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
@@ -124,6 +124,10 @@ Unfortunately there isn’t any way at the moment to import custom audiences _fr
|
|
124 |
|
125 |
== Changelog ==
|
126 |
|
|
|
|
|
|
|
|
|
127 |
= 2.1.2 - 2020-04-15 =
|
128 |
* Enhancement - Change additional_image_link format when multiple URLs, from single field and separated by comma, to multiple additional_image_link fields
|
129 |
* Enhancement - Make ajax AddToCart working in the new WooCommerce blocks
|
4 |
Tags: facebook, facebook pixel, facebook ad, facebook insertions, custom audiences, dynamic events, woocommerce
|
5 |
Requires at least: 4.4
|
6 |
Requires PHP: 5.6
|
7 |
+
Tested up to: 5.4.1
|
8 |
+
Stable tag: 2.1.3
|
9 |
License: GPLv3
|
10 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
124 |
|
125 |
== Changelog ==
|
126 |
|
127 |
+
= 2.1.3 - 2020-06-04 =
|
128 |
+
* Add - PHP 7.4 support
|
129 |
+
* Fix - Fatal error: Replace Monolog library with custom logging because conflicts with other versions used by other plugins that causing website crashing
|
130 |
+
|
131 |
= 2.1.2 - 2020-04-15 =
|
132 |
* Enhancement - Change additional_image_link format when multiple URLs, from single field and separated by comma, to multiple additional_image_link fields
|
133 |
* Enhancement - Make ajax AddToCart working in the new WooCommerce blocks
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit8643d6565db133891a66b89539172820::getLoader();
|
vendor/composer/autoload_classmap.php
CHANGED
@@ -34,7 +34,6 @@ return array(
|
|
34 |
'PixelCaffeine\\Job\\RefreshAudiencesSize' => $baseDir . '/includes/jobs/class-refresh-audiences-size.php',
|
35 |
'PixelCaffeine\\Logs\\Entity\\Log' => $baseDir . '/includes/admin/logs/entity/class-log.php',
|
36 |
'PixelCaffeine\\Logs\\Exception\\LogNotExistingException' => $baseDir . '/includes/admin/logs/exception/exception-log-not-existing.php',
|
37 |
-
'PixelCaffeine\\Logs\\LogDBHandler' => $baseDir . '/includes/admin/logs/class-log-db-handler.php',
|
38 |
'PixelCaffeine\\Logs\\LogRepository' => $baseDir . '/includes/admin/logs/class-log-repository.php',
|
39 |
'PixelCaffeine\\Logs\\LogRepositoryInterface' => $baseDir . '/includes/admin/logs/interface-log-repository.php',
|
40 |
'PixelCaffeine\\Model\\Job' => $baseDir . '/includes/models/class-job.php',
|
34 |
'PixelCaffeine\\Job\\RefreshAudiencesSize' => $baseDir . '/includes/jobs/class-refresh-audiences-size.php',
|
35 |
'PixelCaffeine\\Logs\\Entity\\Log' => $baseDir . '/includes/admin/logs/entity/class-log.php',
|
36 |
'PixelCaffeine\\Logs\\Exception\\LogNotExistingException' => $baseDir . '/includes/admin/logs/exception/exception-log-not-existing.php',
|
|
|
37 |
'PixelCaffeine\\Logs\\LogRepository' => $baseDir . '/includes/admin/logs/class-log-repository.php',
|
38 |
'PixelCaffeine\\Logs\\LogRepositoryInterface' => $baseDir . '/includes/admin/logs/interface-log-repository.php',
|
39 |
'PixelCaffeine\\Model\\Job' => $baseDir . '/includes/models/class-job.php',
|
vendor/composer/autoload_psr4.php
CHANGED
@@ -8,7 +8,5 @@ $baseDir = dirname($vendorDir);
|
|
8 |
return array(
|
9 |
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
|
10 |
'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),
|
11 |
-
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
|
12 |
-
'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
|
13 |
'Firebase\\JWT\\' => array($vendorDir . '/firebase/php-jwt/src'),
|
14 |
);
|
8 |
return array(
|
9 |
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
|
10 |
'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),
|
|
|
|
|
11 |
'Firebase\\JWT\\' => array($vendorDir . '/firebase/php-jwt/src'),
|
12 |
);
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit3394ddee9ab5867f586acb707b9e9f0a
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
-
call_user_func(\Composer\Autoload\
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
@@ -48,19 +48,19 @@ class ComposerAutoloaderInit3394ddee9ab5867f586acb707b9e9f0a
|
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
-
$includeFiles = Composer\Autoload\
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
-
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
-
function
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit8643d6565db133891a66b89539172820
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInit8643d6565db133891a66b89539172820', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit8643d6565db133891a66b89539172820', 'loadClassLoader'));
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit8643d6565db133891a66b89539172820::getInitializer($loader));
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
+
$includeFiles = Composer\Autoload\ComposerStaticInit8643d6565db133891a66b89539172820::$files;
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
+
composerRequire8643d6565db133891a66b89539172820($fileIdentifier, $file);
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
+
function composerRequire8643d6565db133891a66b89539172820($fileIdentifier, $file)
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
@@ -16,14 +16,6 @@ class ComposerStaticInit3394ddee9ab5867f586acb707b9e9f0a
|
|
16 |
'Symfony\\Polyfill\\Ctype\\' => 23,
|
17 |
'Symfony\\Component\\Filesystem\\' => 29,
|
18 |
),
|
19 |
-
'P' =>
|
20 |
-
array (
|
21 |
-
'Psr\\Log\\' => 8,
|
22 |
-
),
|
23 |
-
'M' =>
|
24 |
-
array (
|
25 |
-
'Monolog\\' => 8,
|
26 |
-
),
|
27 |
'F' =>
|
28 |
array (
|
29 |
'Firebase\\JWT\\' => 13,
|
@@ -39,14 +31,6 @@ class ComposerStaticInit3394ddee9ab5867f586acb707b9e9f0a
|
|
39 |
array (
|
40 |
0 => __DIR__ . '/..' . '/symfony/filesystem',
|
41 |
),
|
42 |
-
'Psr\\Log\\' =>
|
43 |
-
array (
|
44 |
-
0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
|
45 |
-
),
|
46 |
-
'Monolog\\' =>
|
47 |
-
array (
|
48 |
-
0 => __DIR__ . '/..' . '/monolog/monolog/src/Monolog',
|
49 |
-
),
|
50 |
'Firebase\\JWT\\' =>
|
51 |
array (
|
52 |
0 => __DIR__ . '/..' . '/firebase/php-jwt/src',
|
@@ -82,7 +66,6 @@ class ComposerStaticInit3394ddee9ab5867f586acb707b9e9f0a
|
|
82 |
'PixelCaffeine\\Job\\RefreshAudiencesSize' => __DIR__ . '/../..' . '/includes/jobs/class-refresh-audiences-size.php',
|
83 |
'PixelCaffeine\\Logs\\Entity\\Log' => __DIR__ . '/../..' . '/includes/admin/logs/entity/class-log.php',
|
84 |
'PixelCaffeine\\Logs\\Exception\\LogNotExistingException' => __DIR__ . '/../..' . '/includes/admin/logs/exception/exception-log-not-existing.php',
|
85 |
-
'PixelCaffeine\\Logs\\LogDBHandler' => __DIR__ . '/../..' . '/includes/admin/logs/class-log-db-handler.php',
|
86 |
'PixelCaffeine\\Logs\\LogRepository' => __DIR__ . '/../..' . '/includes/admin/logs/class-log-repository.php',
|
87 |
'PixelCaffeine\\Logs\\LogRepositoryInterface' => __DIR__ . '/../..' . '/includes/admin/logs/interface-log-repository.php',
|
88 |
'PixelCaffeine\\Model\\Job' => __DIR__ . '/../..' . '/includes/models/class-job.php',
|
@@ -113,9 +96,9 @@ class ComposerStaticInit3394ddee9ab5867f586acb707b9e9f0a
|
|
113 |
public static function getInitializer(ClassLoader $loader)
|
114 |
{
|
115 |
return \Closure::bind(function () use ($loader) {
|
116 |
-
$loader->prefixLengthsPsr4 =
|
117 |
-
$loader->prefixDirsPsr4 =
|
118 |
-
$loader->classMap =
|
119 |
|
120 |
}, null, ClassLoader::class);
|
121 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInit8643d6565db133891a66b89539172820
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
16 |
'Symfony\\Polyfill\\Ctype\\' => 23,
|
17 |
'Symfony\\Component\\Filesystem\\' => 29,
|
18 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
'F' =>
|
20 |
array (
|
21 |
'Firebase\\JWT\\' => 13,
|
31 |
array (
|
32 |
0 => __DIR__ . '/..' . '/symfony/filesystem',
|
33 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
'Firebase\\JWT\\' =>
|
35 |
array (
|
36 |
0 => __DIR__ . '/..' . '/firebase/php-jwt/src',
|
66 |
'PixelCaffeine\\Job\\RefreshAudiencesSize' => __DIR__ . '/../..' . '/includes/jobs/class-refresh-audiences-size.php',
|
67 |
'PixelCaffeine\\Logs\\Entity\\Log' => __DIR__ . '/../..' . '/includes/admin/logs/entity/class-log.php',
|
68 |
'PixelCaffeine\\Logs\\Exception\\LogNotExistingException' => __DIR__ . '/../..' . '/includes/admin/logs/exception/exception-log-not-existing.php',
|
|
|
69 |
'PixelCaffeine\\Logs\\LogRepository' => __DIR__ . '/../..' . '/includes/admin/logs/class-log-repository.php',
|
70 |
'PixelCaffeine\\Logs\\LogRepositoryInterface' => __DIR__ . '/../..' . '/includes/admin/logs/interface-log-repository.php',
|
71 |
'PixelCaffeine\\Model\\Job' => __DIR__ . '/../..' . '/includes/models/class-job.php',
|
96 |
public static function getInitializer(ClassLoader $loader)
|
97 |
{
|
98 |
return \Closure::bind(function () use ($loader) {
|
99 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit8643d6565db133891a66b89539172820::$prefixLengthsPsr4;
|
100 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit8643d6565db133891a66b89539172820::$prefixDirsPsr4;
|
101 |
+
$loader->classMap = ComposerStaticInit8643d6565db133891a66b89539172820::$classMap;
|
102 |
|
103 |
}, null, ClassLoader::class);
|
104 |
}
|
vendor/composer/installed.json
CHANGED
@@ -82,135 +82,6 @@
|
|
82 |
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
|
83 |
"homepage": "https://github.com/firebase/php-jwt"
|
84 |
},
|
85 |
-
{
|
86 |
-
"name": "monolog/monolog",
|
87 |
-
"version": "1.25.1",
|
88 |
-
"version_normalized": "1.25.1.0",
|
89 |
-
"source": {
|
90 |
-
"type": "git",
|
91 |
-
"url": "https://github.com/Seldaek/monolog.git",
|
92 |
-
"reference": "70e65a5470a42cfec1a7da00d30edb6e617e8dcf"
|
93 |
-
},
|
94 |
-
"dist": {
|
95 |
-
"type": "zip",
|
96 |
-
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/70e65a5470a42cfec1a7da00d30edb6e617e8dcf",
|
97 |
-
"reference": "70e65a5470a42cfec1a7da00d30edb6e617e8dcf",
|
98 |
-
"shasum": ""
|
99 |
-
},
|
100 |
-
"require": {
|
101 |
-
"php": ">=5.3.0",
|
102 |
-
"psr/log": "~1.0"
|
103 |
-
},
|
104 |
-
"provide": {
|
105 |
-
"psr/log-implementation": "1.0.0"
|
106 |
-
},
|
107 |
-
"require-dev": {
|
108 |
-
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
|
109 |
-
"doctrine/couchdb": "~1.0@dev",
|
110 |
-
"graylog2/gelf-php": "~1.0",
|
111 |
-
"jakub-onderka/php-parallel-lint": "0.9",
|
112 |
-
"php-amqplib/php-amqplib": "~2.4",
|
113 |
-
"php-console/php-console": "^3.1.3",
|
114 |
-
"phpunit/phpunit": "~4.5",
|
115 |
-
"phpunit/phpunit-mock-objects": "2.3.0",
|
116 |
-
"ruflin/elastica": ">=0.90 <3.0",
|
117 |
-
"sentry/sentry": "^0.13",
|
118 |
-
"swiftmailer/swiftmailer": "^5.3|^6.0"
|
119 |
-
},
|
120 |
-
"suggest": {
|
121 |
-
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
|
122 |
-
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
|
123 |
-
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
|
124 |
-
"ext-mongo": "Allow sending log messages to a MongoDB server",
|
125 |
-
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
|
126 |
-
"mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
|
127 |
-
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
|
128 |
-
"php-console/php-console": "Allow sending log messages to Google Chrome",
|
129 |
-
"rollbar/rollbar": "Allow sending log messages to Rollbar",
|
130 |
-
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
|
131 |
-
"sentry/sentry": "Allow sending log messages to a Sentry server"
|
132 |
-
},
|
133 |
-
"time": "2019-09-06T13:49:17+00:00",
|
134 |
-
"type": "library",
|
135 |
-
"extra": {
|
136 |
-
"branch-alias": {
|
137 |
-
"dev-master": "2.0.x-dev"
|
138 |
-
}
|
139 |
-
},
|
140 |
-
"installation-source": "dist",
|
141 |
-
"autoload": {
|
142 |
-
"psr-4": {
|
143 |
-
"Monolog\\": "src/Monolog"
|
144 |
-
}
|
145 |
-
},
|
146 |
-
"notification-url": "https://packagist.org/downloads/",
|
147 |
-
"license": [
|
148 |
-
"MIT"
|
149 |
-
],
|
150 |
-
"authors": [
|
151 |
-
{
|
152 |
-
"name": "Jordi Boggiano",
|
153 |
-
"email": "j.boggiano@seld.be",
|
154 |
-
"homepage": "http://seld.be"
|
155 |
-
}
|
156 |
-
],
|
157 |
-
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
|
158 |
-
"homepage": "http://github.com/Seldaek/monolog",
|
159 |
-
"keywords": [
|
160 |
-
"log",
|
161 |
-
"logging",
|
162 |
-
"psr-3"
|
163 |
-
]
|
164 |
-
},
|
165 |
-
{
|
166 |
-
"name": "psr/log",
|
167 |
-
"version": "1.1.0",
|
168 |
-
"version_normalized": "1.1.0.0",
|
169 |
-
"source": {
|
170 |
-
"type": "git",
|
171 |
-
"url": "https://github.com/php-fig/log.git",
|
172 |
-
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd"
|
173 |
-
},
|
174 |
-
"dist": {
|
175 |
-
"type": "zip",
|
176 |
-
"url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
|
177 |
-
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
|
178 |
-
"shasum": ""
|
179 |
-
},
|
180 |
-
"require": {
|
181 |
-
"php": ">=5.3.0"
|
182 |
-
},
|
183 |
-
"time": "2018-11-20T15:27:04+00:00",
|
184 |
-
"type": "library",
|
185 |
-
"extra": {
|
186 |
-
"branch-alias": {
|
187 |
-
"dev-master": "1.0.x-dev"
|
188 |
-
}
|
189 |
-
},
|
190 |
-
"installation-source": "dist",
|
191 |
-
"autoload": {
|
192 |
-
"psr-4": {
|
193 |
-
"Psr\\Log\\": "Psr/Log/"
|
194 |
-
}
|
195 |
-
},
|
196 |
-
"notification-url": "https://packagist.org/downloads/",
|
197 |
-
"license": [
|
198 |
-
"MIT"
|
199 |
-
],
|
200 |
-
"authors": [
|
201 |
-
{
|
202 |
-
"name": "PHP-FIG",
|
203 |
-
"homepage": "http://www.php-fig.org/"
|
204 |
-
}
|
205 |
-
],
|
206 |
-
"description": "Common interface for logging libraries",
|
207 |
-
"homepage": "https://github.com/php-fig/log",
|
208 |
-
"keywords": [
|
209 |
-
"log",
|
210 |
-
"psr",
|
211 |
-
"psr-3"
|
212 |
-
]
|
213 |
-
},
|
214 |
{
|
215 |
"name": "symfony/filesystem",
|
216 |
"version": "v2.8.50",
|
82 |
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
|
83 |
"homepage": "https://github.com/firebase/php-jwt"
|
84 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
{
|
86 |
"name": "symfony/filesystem",
|
87 |
"version": "v2.8.50",
|
vendor/monolog/monolog/CHANGELOG.md
DELETED
@@ -1,388 +0,0 @@
|
|
1 |
-
### 1.25.1 (2019-09-06)
|
2 |
-
|
3 |
-
* Fixed forward-compatible interfaces to be compatible with Monolog 1.x too.
|
4 |
-
|
5 |
-
### 1.25.0 (2019-09-06)
|
6 |
-
|
7 |
-
* Deprecated SlackbotHandler, use SlackWebhookHandler or SlackHandler instead
|
8 |
-
* Deprecated RavenHandler, use sentry/sentry 2.x and their Sentry\Monolog\Handler instead
|
9 |
-
* Deprecated HipChatHandler, migrate to Slack and use SlackWebhookHandler or SlackHandler instead
|
10 |
-
* Added forward-compatible interfaces and traits FormattableHandlerInterface, FormattableHandlerTrait, ProcessableHandlerInterface, ProcessableHandlerTrait. If you use modern PHP and want to make code compatible with Monolog 1 and 2 this can help. You will have to require at least Monolog 1.25 though.
|
11 |
-
* Added support for RFC3164 (outdated BSD syslog protocol) to SyslogUdpHandler
|
12 |
-
* Fixed issue in GroupHandler and WhatFailureGroupHandler where setting multiple processors would duplicate records
|
13 |
-
* Fixed issue in SignalHandler restarting syscalls functionality
|
14 |
-
* Fixed normalizers handling of exception backtraces to avoid serializing arguments in some cases
|
15 |
-
* Fixed ZendMonitorHandler to work with the latest Zend Server versions
|
16 |
-
* Fixed ChromePHPHandler to avoid sending more data than latest Chrome versions allow in headers (4KB down from 256KB).
|
17 |
-
|
18 |
-
### 1.24.0 (2018-11-05)
|
19 |
-
|
20 |
-
* BC Notice: If you are extending any of the Monolog's Formatters' `normalize` method, make sure you add the new `$depth = 0` argument to your function signature to avoid strict PHP warnings.
|
21 |
-
* Added a `ResettableInterface` in order to reset/reset/clear/flush handlers and processors
|
22 |
-
* Added a `ProcessorInterface` as an optional way to label a class as being a processor (mostly useful for autowiring dependency containers)
|
23 |
-
* Added a way to log signals being received using Monolog\SignalHandler
|
24 |
-
* Added ability to customize error handling at the Logger level using Logger::setExceptionHandler
|
25 |
-
* Added InsightOpsHandler to migrate users of the LogEntriesHandler
|
26 |
-
* Added protection to NormalizerHandler against circular and very deep structures, it now stops normalizing at a depth of 9
|
27 |
-
* Added capture of stack traces to ErrorHandler when logging PHP errors
|
28 |
-
* Added RavenHandler support for a `contexts` context or extra key to forward that to Sentry's contexts
|
29 |
-
* Added forwarding of context info to FluentdFormatter
|
30 |
-
* Added SocketHandler::setChunkSize to override the default chunk size in case you must send large log lines to rsyslog for example
|
31 |
-
* Added ability to extend/override BrowserConsoleHandler
|
32 |
-
* Added SlackWebhookHandler::getWebhookUrl and SlackHandler::getToken to enable class extensibility
|
33 |
-
* Added SwiftMailerHandler::getSubjectFormatter to enable class extensibility
|
34 |
-
* Dropped official support for HHVM in test builds
|
35 |
-
* Fixed normalization of exception traces when call_user_func is used to avoid serializing objects and the data they contain
|
36 |
-
* Fixed naming of fields in Slack handler, all field names are now capitalized in all cases
|
37 |
-
* Fixed HipChatHandler bug where slack dropped messages randomly
|
38 |
-
* Fixed normalization of objects in Slack handlers
|
39 |
-
* Fixed support for PHP7's Throwable in NewRelicHandler
|
40 |
-
* Fixed race bug when StreamHandler sometimes incorrectly reported it failed to create a directory
|
41 |
-
* Fixed table row styling issues in HtmlFormatter
|
42 |
-
* Fixed RavenHandler dropping the message when logging exception
|
43 |
-
* Fixed WhatFailureGroupHandler skipping processors when using handleBatch
|
44 |
-
and implement it where possible
|
45 |
-
* Fixed display of anonymous class names
|
46 |
-
|
47 |
-
### 1.23.0 (2017-06-19)
|
48 |
-
|
49 |
-
* Improved SyslogUdpHandler's support for RFC5424 and added optional `$ident` argument
|
50 |
-
* Fixed GelfHandler truncation to be per field and not per message
|
51 |
-
* Fixed compatibility issue with PHP <5.3.6
|
52 |
-
* Fixed support for headless Chrome in ChromePHPHandler
|
53 |
-
* Fixed support for latest Aws SDK in DynamoDbHandler
|
54 |
-
* Fixed support for SwiftMailer 6.0+ in SwiftMailerHandler
|
55 |
-
|
56 |
-
### 1.22.1 (2017-03-13)
|
57 |
-
|
58 |
-
* Fixed lots of minor issues in the new Slack integrations
|
59 |
-
* Fixed support for allowInlineLineBreaks in LineFormatter when formatting exception backtraces
|
60 |
-
|
61 |
-
### 1.22.0 (2016-11-26)
|
62 |
-
|
63 |
-
* Added SlackbotHandler and SlackWebhookHandler to set up Slack integration more easily
|
64 |
-
* Added MercurialProcessor to add mercurial revision and branch names to log records
|
65 |
-
* Added support for AWS SDK v3 in DynamoDbHandler
|
66 |
-
* Fixed fatal errors occuring when normalizing generators that have been fully consumed
|
67 |
-
* Fixed RollbarHandler to include a level (rollbar level), monolog_level (original name), channel and datetime (unix)
|
68 |
-
* Fixed RollbarHandler not flushing records automatically, calling close() explicitly is not necessary anymore
|
69 |
-
* Fixed SyslogUdpHandler to avoid sending empty frames
|
70 |
-
* Fixed a few PHP 7.0 and 7.1 compatibility issues
|
71 |
-
|
72 |
-
### 1.21.0 (2016-07-29)
|
73 |
-
|
74 |
-
* Break: Reverted the addition of $context when the ErrorHandler handles regular php errors from 1.20.0 as it was causing issues
|
75 |
-
* Added support for more formats in RotatingFileHandler::setFilenameFormat as long as they have Y, m and d in order
|
76 |
-
* Added ability to format the main line of text the SlackHandler sends by explictly setting a formatter on the handler
|
77 |
-
* Added information about SoapFault instances in NormalizerFormatter
|
78 |
-
* Added $handleOnlyReportedErrors option on ErrorHandler::registerErrorHandler (default true) to allow logging of all errors no matter the error_reporting level
|
79 |
-
|
80 |
-
### 1.20.0 (2016-07-02)
|
81 |
-
|
82 |
-
* Added FingersCrossedHandler::activate() to manually trigger the handler regardless of the activation policy
|
83 |
-
* Added StreamHandler::getUrl to retrieve the stream's URL
|
84 |
-
* Added ability to override addRow/addTitle in HtmlFormatter
|
85 |
-
* Added the $context to context information when the ErrorHandler handles a regular php error
|
86 |
-
* Deprecated RotatingFileHandler::setFilenameFormat to only support 3 formats: Y, Y-m and Y-m-d
|
87 |
-
* Fixed WhatFailureGroupHandler to work with PHP7 throwables
|
88 |
-
* Fixed a few minor bugs
|
89 |
-
|
90 |
-
### 1.19.0 (2016-04-12)
|
91 |
-
|
92 |
-
* Break: StreamHandler will not close streams automatically that it does not own. If you pass in a stream (not a path/url), then it will not close it for you. You can retrieve those using getStream() if needed
|
93 |
-
* Added DeduplicationHandler to remove duplicate records from notifications across multiple requests, useful for email or other notifications on errors
|
94 |
-
* Added ability to use `%message%` and other LineFormatter replacements in the subject line of emails sent with NativeMailHandler and SwiftMailerHandler
|
95 |
-
* Fixed HipChatHandler handling of long messages
|
96 |
-
|
97 |
-
### 1.18.2 (2016-04-02)
|
98 |
-
|
99 |
-
* Fixed ElasticaFormatter to use more precise dates
|
100 |
-
* Fixed GelfMessageFormatter sending too long messages
|
101 |
-
|
102 |
-
### 1.18.1 (2016-03-13)
|
103 |
-
|
104 |
-
* Fixed SlackHandler bug where slack dropped messages randomly
|
105 |
-
* Fixed RedisHandler issue when using with the PHPRedis extension
|
106 |
-
* Fixed AmqpHandler content-type being incorrectly set when using with the AMQP extension
|
107 |
-
* Fixed BrowserConsoleHandler regression
|
108 |
-
|
109 |
-
### 1.18.0 (2016-03-01)
|
110 |
-
|
111 |
-
* Added optional reduction of timestamp precision via `Logger->useMicrosecondTimestamps(false)`, disabling it gets you a bit of performance boost but reduces the precision to the second instead of microsecond
|
112 |
-
* Added possibility to skip some extra stack frames in IntrospectionProcessor if you have some library wrapping Monolog that is always adding frames
|
113 |
-
* Added `Logger->withName` to clone a logger (keeping all handlers) with a new name
|
114 |
-
* Added FluentdFormatter for the Fluentd unix socket protocol
|
115 |
-
* Added HandlerWrapper base class to ease the creation of handler wrappers, just extend it and override as needed
|
116 |
-
* Added support for replacing context sub-keys using `%context.*%` in LineFormatter
|
117 |
-
* Added support for `payload` context value in RollbarHandler
|
118 |
-
* Added setRelease to RavenHandler to describe the application version, sent with every log
|
119 |
-
* Added support for `fingerprint` context value in RavenHandler
|
120 |
-
* Fixed JSON encoding errors that would gobble up the whole log record, we now handle those more gracefully by dropping chars as needed
|
121 |
-
* Fixed write timeouts in SocketHandler and derivatives, set to 10sec by default, lower it with `setWritingTimeout()`
|
122 |
-
* Fixed PHP7 compatibility with regard to Exception/Throwable handling in a few places
|
123 |
-
|
124 |
-
### 1.17.2 (2015-10-14)
|
125 |
-
|
126 |
-
* Fixed ErrorHandler compatibility with non-Monolog PSR-3 loggers
|
127 |
-
* Fixed SlackHandler handling to use slack functionalities better
|
128 |
-
* Fixed SwiftMailerHandler bug when sending multiple emails they all had the same id
|
129 |
-
* Fixed 5.3 compatibility regression
|
130 |
-
|
131 |
-
### 1.17.1 (2015-08-31)
|
132 |
-
|
133 |
-
* Fixed RollbarHandler triggering PHP notices
|
134 |
-
|
135 |
-
### 1.17.0 (2015-08-30)
|
136 |
-
|
137 |
-
* Added support for `checksum` and `release` context/extra values in RavenHandler
|
138 |
-
* Added better support for exceptions in RollbarHandler
|
139 |
-
* Added UidProcessor::getUid
|
140 |
-
* Added support for showing the resource type in NormalizedFormatter
|
141 |
-
* Fixed IntrospectionProcessor triggering PHP notices
|
142 |
-
|
143 |
-
### 1.16.0 (2015-08-09)
|
144 |
-
|
145 |
-
* Added IFTTTHandler to notify ifttt.com triggers
|
146 |
-
* Added Logger::setHandlers() to allow setting/replacing all handlers
|
147 |
-
* Added $capSize in RedisHandler to cap the log size
|
148 |
-
* Fixed StreamHandler creation of directory to only trigger when the first log write happens
|
149 |
-
* Fixed bug in the handling of curl failures
|
150 |
-
* Fixed duplicate logging of fatal errors when both error and fatal error handlers are registered in monolog's ErrorHandler
|
151 |
-
* Fixed missing fatal errors records with handlers that need to be closed to flush log records
|
152 |
-
* Fixed TagProcessor::addTags support for associative arrays
|
153 |
-
|
154 |
-
### 1.15.0 (2015-07-12)
|
155 |
-
|
156 |
-
* Added addTags and setTags methods to change a TagProcessor
|
157 |
-
* Added automatic creation of directories if they are missing for a StreamHandler to open a log file
|
158 |
-
* Added retry functionality to Loggly, Cube and Mandrill handlers so they retry up to 5 times in case of network failure
|
159 |
-
* Fixed process exit code being incorrectly reset to 0 if ErrorHandler::registerExceptionHandler was used
|
160 |
-
* Fixed HTML/JS escaping in BrowserConsoleHandler
|
161 |
-
* Fixed JSON encoding errors being silently suppressed (PHP 5.5+ only)
|
162 |
-
|
163 |
-
### 1.14.0 (2015-06-19)
|
164 |
-
|
165 |
-
* Added PHPConsoleHandler to send record to Chrome's PHP Console extension and library
|
166 |
-
* Added support for objects implementing __toString in the NormalizerFormatter
|
167 |
-
* Added support for HipChat's v2 API in HipChatHandler
|
168 |
-
* Added Logger::setTimezone() to initialize the timezone monolog should use in case date.timezone isn't correct for your app
|
169 |
-
* Added an option to send formatted message instead of the raw record on PushoverHandler via ->useFormattedMessage(true)
|
170 |
-
* Fixed curl errors being silently suppressed
|
171 |
-
|
172 |
-
### 1.13.1 (2015-03-09)
|
173 |
-
|
174 |
-
* Fixed regression in HipChat requiring a new token to be created
|
175 |
-
|
176 |
-
### 1.13.0 (2015-03-05)
|
177 |
-
|
178 |
-
* Added Registry::hasLogger to check for the presence of a logger instance
|
179 |
-
* Added context.user support to RavenHandler
|
180 |
-
* Added HipChat API v2 support in the HipChatHandler
|
181 |
-
* Added NativeMailerHandler::addParameter to pass params to the mail() process
|
182 |
-
* Added context data to SlackHandler when $includeContextAndExtra is true
|
183 |
-
* Added ability to customize the Swift_Message per-email in SwiftMailerHandler
|
184 |
-
* Fixed SwiftMailerHandler to lazily create message instances if a callback is provided
|
185 |
-
* Fixed serialization of INF and NaN values in Normalizer and LineFormatter
|
186 |
-
|
187 |
-
### 1.12.0 (2014-12-29)
|
188 |
-
|
189 |
-
* Break: HandlerInterface::isHandling now receives a partial record containing only a level key. This was always the intent and does not break any Monolog handler but is strictly speaking a BC break and you should check if you relied on any other field in your own handlers.
|
190 |
-
* Added PsrHandler to forward records to another PSR-3 logger
|
191 |
-
* Added SamplingHandler to wrap around a handler and include only every Nth record
|
192 |
-
* Added MongoDBFormatter to support better storage with MongoDBHandler (it must be enabled manually for now)
|
193 |
-
* Added exception codes in the output of most formatters
|
194 |
-
* Added LineFormatter::includeStacktraces to enable exception stack traces in logs (uses more than one line)
|
195 |
-
* Added $useShortAttachment to SlackHandler to minify attachment size and $includeExtra to append extra data
|
196 |
-
* Added $host to HipChatHandler for users of private instances
|
197 |
-
* Added $transactionName to NewRelicHandler and support for a transaction_name context value
|
198 |
-
* Fixed MandrillHandler to avoid outputing API call responses
|
199 |
-
* Fixed some non-standard behaviors in SyslogUdpHandler
|
200 |
-
|
201 |
-
### 1.11.0 (2014-09-30)
|
202 |
-
|
203 |
-
* Break: The NewRelicHandler extra and context data are now prefixed with extra_ and context_ to avoid clashes. Watch out if you have scripts reading those from the API and rely on names
|
204 |
-
* Added WhatFailureGroupHandler to suppress any exception coming from the wrapped handlers and avoid chain failures if a logging service fails
|
205 |
-
* Added MandrillHandler to send emails via the Mandrillapp.com API
|
206 |
-
* Added SlackHandler to log records to a Slack.com account
|
207 |
-
* Added FleepHookHandler to log records to a Fleep.io account
|
208 |
-
* Added LogglyHandler::addTag to allow adding tags to an existing handler
|
209 |
-
* Added $ignoreEmptyContextAndExtra to LineFormatter to avoid empty [] at the end
|
210 |
-
* Added $useLocking to StreamHandler and RotatingFileHandler to enable flock() while writing
|
211 |
-
* Added support for PhpAmqpLib in the AmqpHandler
|
212 |
-
* Added FingersCrossedHandler::clear and BufferHandler::clear to reset them between batches in long running jobs
|
213 |
-
* Added support for adding extra fields from $_SERVER in the WebProcessor
|
214 |
-
* Fixed support for non-string values in PrsLogMessageProcessor
|
215 |
-
* Fixed SwiftMailer messages being sent with the wrong date in long running scripts
|
216 |
-
* Fixed minor PHP 5.6 compatibility issues
|
217 |
-
* Fixed BufferHandler::close being called twice
|
218 |
-
|
219 |
-
### 1.10.0 (2014-06-04)
|
220 |
-
|
221 |
-
* Added Logger::getHandlers() and Logger::getProcessors() methods
|
222 |
-
* Added $passthruLevel argument to FingersCrossedHandler to let it always pass some records through even if the trigger level is not reached
|
223 |
-
* Added support for extra data in NewRelicHandler
|
224 |
-
* Added $expandNewlines flag to the ErrorLogHandler to create multiple log entries when a message has multiple lines
|
225 |
-
|
226 |
-
### 1.9.1 (2014-04-24)
|
227 |
-
|
228 |
-
* Fixed regression in RotatingFileHandler file permissions
|
229 |
-
* Fixed initialization of the BufferHandler to make sure it gets flushed after receiving records
|
230 |
-
* Fixed ChromePHPHandler and FirePHPHandler's activation strategies to be more conservative
|
231 |
-
|
232 |
-
### 1.9.0 (2014-04-20)
|
233 |
-
|
234 |
-
* Added LogEntriesHandler to send logs to a LogEntries account
|
235 |
-
* Added $filePermissions to tweak file mode on StreamHandler and RotatingFileHandler
|
236 |
-
* Added $useFormatting flag to MemoryProcessor to make it send raw data in bytes
|
237 |
-
* Added support for table formatting in FirePHPHandler via the table context key
|
238 |
-
* Added a TagProcessor to add tags to records, and support for tags in RavenHandler
|
239 |
-
* Added $appendNewline flag to the JsonFormatter to enable using it when logging to files
|
240 |
-
* Added sound support to the PushoverHandler
|
241 |
-
* Fixed multi-threading support in StreamHandler
|
242 |
-
* Fixed empty headers issue when ChromePHPHandler received no records
|
243 |
-
* Fixed default format of the ErrorLogHandler
|
244 |
-
|
245 |
-
### 1.8.0 (2014-03-23)
|
246 |
-
|
247 |
-
* Break: the LineFormatter now strips newlines by default because this was a bug, set $allowInlineLineBreaks to true if you need them
|
248 |
-
* Added BrowserConsoleHandler to send logs to any browser's console via console.log() injection in the output
|
249 |
-
* Added FilterHandler to filter records and only allow those of a given list of levels through to the wrapped handler
|
250 |
-
* Added FlowdockHandler to send logs to a Flowdock account
|
251 |
-
* Added RollbarHandler to send logs to a Rollbar account
|
252 |
-
* Added HtmlFormatter to send prettier log emails with colors for each log level
|
253 |
-
* Added GitProcessor to add the current branch/commit to extra record data
|
254 |
-
* Added a Monolog\Registry class to allow easier global access to pre-configured loggers
|
255 |
-
* Added support for the new official graylog2/gelf-php lib for GelfHandler, upgrade if you can by replacing the mlehner/gelf-php requirement
|
256 |
-
* Added support for HHVM
|
257 |
-
* Added support for Loggly batch uploads
|
258 |
-
* Added support for tweaking the content type and encoding in NativeMailerHandler
|
259 |
-
* Added $skipClassesPartials to tweak the ignored classes in the IntrospectionProcessor
|
260 |
-
* Fixed batch request support in GelfHandler
|
261 |
-
|
262 |
-
### 1.7.0 (2013-11-14)
|
263 |
-
|
264 |
-
* Added ElasticSearchHandler to send logs to an Elastic Search server
|
265 |
-
* Added DynamoDbHandler and ScalarFormatter to send logs to Amazon's Dynamo DB
|
266 |
-
* Added SyslogUdpHandler to send logs to a remote syslogd server
|
267 |
-
* Added LogglyHandler to send logs to a Loggly account
|
268 |
-
* Added $level to IntrospectionProcessor so it only adds backtraces when needed
|
269 |
-
* Added $version to LogstashFormatter to allow using the new v1 Logstash format
|
270 |
-
* Added $appName to NewRelicHandler
|
271 |
-
* Added configuration of Pushover notification retries/expiry
|
272 |
-
* Added $maxColumnWidth to NativeMailerHandler to change the 70 chars default
|
273 |
-
* Added chainability to most setters for all handlers
|
274 |
-
* Fixed RavenHandler batch processing so it takes the message from the record with highest priority
|
275 |
-
* Fixed HipChatHandler batch processing so it sends all messages at once
|
276 |
-
* Fixed issues with eAccelerator
|
277 |
-
* Fixed and improved many small things
|
278 |
-
|
279 |
-
### 1.6.0 (2013-07-29)
|
280 |
-
|
281 |
-
* Added HipChatHandler to send logs to a HipChat chat room
|
282 |
-
* Added ErrorLogHandler to send logs to PHP's error_log function
|
283 |
-
* Added NewRelicHandler to send logs to NewRelic's service
|
284 |
-
* Added Monolog\ErrorHandler helper class to register a Logger as exception/error/fatal handler
|
285 |
-
* Added ChannelLevelActivationStrategy for the FingersCrossedHandler to customize levels by channel
|
286 |
-
* Added stack traces output when normalizing exceptions (json output & co)
|
287 |
-
* Added Monolog\Logger::API constant (currently 1)
|
288 |
-
* Added support for ChromePHP's v4.0 extension
|
289 |
-
* Added support for message priorities in PushoverHandler, see $highPriorityLevel and $emergencyLevel
|
290 |
-
* Added support for sending messages to multiple users at once with the PushoverHandler
|
291 |
-
* Fixed RavenHandler's support for batch sending of messages (when behind a Buffer or FingersCrossedHandler)
|
292 |
-
* Fixed normalization of Traversables with very large data sets, only the first 1000 items are shown now
|
293 |
-
* Fixed issue in RotatingFileHandler when an open_basedir restriction is active
|
294 |
-
* Fixed minor issues in RavenHandler and bumped the API to Raven 0.5.0
|
295 |
-
* Fixed SyslogHandler issue when many were used concurrently with different facilities
|
296 |
-
|
297 |
-
### 1.5.0 (2013-04-23)
|
298 |
-
|
299 |
-
* Added ProcessIdProcessor to inject the PID in log records
|
300 |
-
* Added UidProcessor to inject a unique identifier to all log records of one request/run
|
301 |
-
* Added support for previous exceptions in the LineFormatter exception serialization
|
302 |
-
* Added Monolog\Logger::getLevels() to get all available levels
|
303 |
-
* Fixed ChromePHPHandler so it avoids sending headers larger than Chrome can handle
|
304 |
-
|
305 |
-
### 1.4.1 (2013-04-01)
|
306 |
-
|
307 |
-
* Fixed exception formatting in the LineFormatter to be more minimalistic
|
308 |
-
* Fixed RavenHandler's handling of context/extra data, requires Raven client >0.1.0
|
309 |
-
* Fixed log rotation in RotatingFileHandler to work with long running scripts spanning multiple days
|
310 |
-
* Fixed WebProcessor array access so it checks for data presence
|
311 |
-
* Fixed Buffer, Group and FingersCrossed handlers to make use of their processors
|
312 |
-
|
313 |
-
### 1.4.0 (2013-02-13)
|
314 |
-
|
315 |
-
* Added RedisHandler to log to Redis via the Predis library or the phpredis extension
|
316 |
-
* Added ZendMonitorHandler to log to the Zend Server monitor
|
317 |
-
* Added the possibility to pass arrays of handlers and processors directly in the Logger constructor
|
318 |
-
* Added `$useSSL` option to the PushoverHandler which is enabled by default
|
319 |
-
* Fixed ChromePHPHandler and FirePHPHandler issue when multiple instances are used simultaneously
|
320 |
-
* Fixed header injection capability in the NativeMailHandler
|
321 |
-
|
322 |
-
### 1.3.1 (2013-01-11)
|
323 |
-
|
324 |
-
* Fixed LogstashFormatter to be usable with stream handlers
|
325 |
-
* Fixed GelfMessageFormatter levels on Windows
|
326 |
-
|
327 |
-
### 1.3.0 (2013-01-08)
|
328 |
-
|
329 |
-
* Added PSR-3 compliance, the `Monolog\Logger` class is now an instance of `Psr\Log\LoggerInterface`
|
330 |
-
* Added PsrLogMessageProcessor that you can selectively enable for full PSR-3 compliance
|
331 |
-
* Added LogstashFormatter (combine with SocketHandler or StreamHandler to send logs to Logstash)
|
332 |
-
* Added PushoverHandler to send mobile notifications
|
333 |
-
* Added CouchDBHandler and DoctrineCouchDBHandler
|
334 |
-
* Added RavenHandler to send data to Sentry servers
|
335 |
-
* Added support for the new MongoClient class in MongoDBHandler
|
336 |
-
* Added microsecond precision to log records' timestamps
|
337 |
-
* Added `$flushOnOverflow` param to BufferHandler to flush by batches instead of losing
|
338 |
-
the oldest entries
|
339 |
-
* Fixed normalization of objects with cyclic references
|
340 |
-
|
341 |
-
### 1.2.1 (2012-08-29)
|
342 |
-
|
343 |
-
* Added new $logopts arg to SyslogHandler to provide custom openlog options
|
344 |
-
* Fixed fatal error in SyslogHandler
|
345 |
-
|
346 |
-
### 1.2.0 (2012-08-18)
|
347 |
-
|
348 |
-
* Added AmqpHandler (for use with AMQP servers)
|
349 |
-
* Added CubeHandler
|
350 |
-
* Added NativeMailerHandler::addHeader() to send custom headers in mails
|
351 |
-
* Added the possibility to specify more than one recipient in NativeMailerHandler
|
352 |
-
* Added the possibility to specify float timeouts in SocketHandler
|
353 |
-
* Added NOTICE and EMERGENCY levels to conform with RFC 5424
|
354 |
-
* Fixed the log records to use the php default timezone instead of UTC
|
355 |
-
* Fixed BufferHandler not being flushed properly on PHP fatal errors
|
356 |
-
* Fixed normalization of exotic resource types
|
357 |
-
* Fixed the default format of the SyslogHandler to avoid duplicating datetimes in syslog
|
358 |
-
|
359 |
-
### 1.1.0 (2012-04-23)
|
360 |
-
|
361 |
-
* Added Monolog\Logger::isHandling() to check if a handler will
|
362 |
-
handle the given log level
|
363 |
-
* Added ChromePHPHandler
|
364 |
-
* Added MongoDBHandler
|
365 |
-
* Added GelfHandler (for use with Graylog2 servers)
|
366 |
-
* Added SocketHandler (for use with syslog-ng for example)
|
367 |
-
* Added NormalizerFormatter
|
368 |
-
* Added the possibility to change the activation strategy of the FingersCrossedHandler
|
369 |
-
* Added possibility to show microseconds in logs
|
370 |
-
* Added `server` and `referer` to WebProcessor output
|
371 |
-
|
372 |
-
### 1.0.2 (2011-10-24)
|
373 |
-
|
374 |
-
* Fixed bug in IE with large response headers and FirePHPHandler
|
375 |
-
|
376 |
-
### 1.0.1 (2011-08-25)
|
377 |
-
|
378 |
-
* Added MemoryPeakUsageProcessor and MemoryUsageProcessor
|
379 |
-
* Added Monolog\Logger::getName() to get a logger's channel name
|
380 |
-
|
381 |
-
### 1.0.0 (2011-07-06)
|
382 |
-
|
383 |
-
* Added IntrospectionProcessor to get info from where the logger was called
|
384 |
-
* Fixed WebProcessor in CLI
|
385 |
-
|
386 |
-
### 1.0.0-RC1 (2011-07-01)
|
387 |
-
|
388 |
-
* Initial release
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/LICENSE
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
Copyright (c) 2011-2016 Jordi Boggiano
|
2 |
-
|
3 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
-
of this software and associated documentation files (the "Software"), to deal
|
5 |
-
in the Software without restriction, including without limitation the rights
|
6 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7 |
-
copies of the Software, and to permit persons to whom the Software is furnished
|
8 |
-
to do so, subject to the following conditions:
|
9 |
-
|
10 |
-
The above copyright notice and this permission notice shall be included in all
|
11 |
-
copies or substantial portions of the Software.
|
12 |
-
|
13 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19 |
-
THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/ErrorHandler.php
DELETED
@@ -1,239 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog;
|
13 |
-
|
14 |
-
use Psr\Log\LoggerInterface;
|
15 |
-
use Psr\Log\LogLevel;
|
16 |
-
use Monolog\Handler\AbstractHandler;
|
17 |
-
use Monolog\Registry;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Monolog error handler
|
21 |
-
*
|
22 |
-
* A facility to enable logging of runtime errors, exceptions and fatal errors.
|
23 |
-
*
|
24 |
-
* Quick setup: <code>ErrorHandler::register($logger);</code>
|
25 |
-
*
|
26 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
27 |
-
*/
|
28 |
-
class ErrorHandler
|
29 |
-
{
|
30 |
-
private $logger;
|
31 |
-
|
32 |
-
private $previousExceptionHandler;
|
33 |
-
private $uncaughtExceptionLevel;
|
34 |
-
|
35 |
-
private $previousErrorHandler;
|
36 |
-
private $errorLevelMap;
|
37 |
-
private $handleOnlyReportedErrors;
|
38 |
-
|
39 |
-
private $hasFatalErrorHandler;
|
40 |
-
private $fatalLevel;
|
41 |
-
private $reservedMemory;
|
42 |
-
private $lastFatalTrace;
|
43 |
-
private static $fatalErrors = array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR);
|
44 |
-
|
45 |
-
public function __construct(LoggerInterface $logger)
|
46 |
-
{
|
47 |
-
$this->logger = $logger;
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Registers a new ErrorHandler for a given Logger
|
52 |
-
*
|
53 |
-
* By default it will handle errors, exceptions and fatal errors
|
54 |
-
*
|
55 |
-
* @param LoggerInterface $logger
|
56 |
-
* @param array|false $errorLevelMap an array of E_* constant to LogLevel::* constant mapping, or false to disable error handling
|
57 |
-
* @param int|false $exceptionLevel a LogLevel::* constant, or false to disable exception handling
|
58 |
-
* @param int|false $fatalLevel a LogLevel::* constant, or false to disable fatal error handling
|
59 |
-
* @return ErrorHandler
|
60 |
-
*/
|
61 |
-
public static function register(LoggerInterface $logger, $errorLevelMap = array(), $exceptionLevel = null, $fatalLevel = null)
|
62 |
-
{
|
63 |
-
//Forces the autoloader to run for LogLevel. Fixes an autoload issue at compile-time on PHP5.3. See https://github.com/Seldaek/monolog/pull/929
|
64 |
-
class_exists('\\Psr\\Log\\LogLevel', true);
|
65 |
-
|
66 |
-
$handler = new static($logger);
|
67 |
-
if ($errorLevelMap !== false) {
|
68 |
-
$handler->registerErrorHandler($errorLevelMap);
|
69 |
-
}
|
70 |
-
if ($exceptionLevel !== false) {
|
71 |
-
$handler->registerExceptionHandler($exceptionLevel);
|
72 |
-
}
|
73 |
-
if ($fatalLevel !== false) {
|
74 |
-
$handler->registerFatalHandler($fatalLevel);
|
75 |
-
}
|
76 |
-
|
77 |
-
return $handler;
|
78 |
-
}
|
79 |
-
|
80 |
-
public function registerExceptionHandler($level = null, $callPrevious = true)
|
81 |
-
{
|
82 |
-
$prev = set_exception_handler(array($this, 'handleException'));
|
83 |
-
$this->uncaughtExceptionLevel = $level;
|
84 |
-
if ($callPrevious && $prev) {
|
85 |
-
$this->previousExceptionHandler = $prev;
|
86 |
-
}
|
87 |
-
}
|
88 |
-
|
89 |
-
public function registerErrorHandler(array $levelMap = array(), $callPrevious = true, $errorTypes = -1, $handleOnlyReportedErrors = true)
|
90 |
-
{
|
91 |
-
$prev = set_error_handler(array($this, 'handleError'), $errorTypes);
|
92 |
-
$this->errorLevelMap = array_replace($this->defaultErrorLevelMap(), $levelMap);
|
93 |
-
if ($callPrevious) {
|
94 |
-
$this->previousErrorHandler = $prev ?: true;
|
95 |
-
}
|
96 |
-
|
97 |
-
$this->handleOnlyReportedErrors = $handleOnlyReportedErrors;
|
98 |
-
}
|
99 |
-
|
100 |
-
public function registerFatalHandler($level = null, $reservedMemorySize = 20)
|
101 |
-
{
|
102 |
-
register_shutdown_function(array($this, 'handleFatalError'));
|
103 |
-
|
104 |
-
$this->reservedMemory = str_repeat(' ', 1024 * $reservedMemorySize);
|
105 |
-
$this->fatalLevel = $level;
|
106 |
-
$this->hasFatalErrorHandler = true;
|
107 |
-
}
|
108 |
-
|
109 |
-
protected function defaultErrorLevelMap()
|
110 |
-
{
|
111 |
-
return array(
|
112 |
-
E_ERROR => LogLevel::CRITICAL,
|
113 |
-
E_WARNING => LogLevel::WARNING,
|
114 |
-
E_PARSE => LogLevel::ALERT,
|
115 |
-
E_NOTICE => LogLevel::NOTICE,
|
116 |
-
E_CORE_ERROR => LogLevel::CRITICAL,
|
117 |
-
E_CORE_WARNING => LogLevel::WARNING,
|
118 |
-
E_COMPILE_ERROR => LogLevel::ALERT,
|
119 |
-
E_COMPILE_WARNING => LogLevel::WARNING,
|
120 |
-
E_USER_ERROR => LogLevel::ERROR,
|
121 |
-
E_USER_WARNING => LogLevel::WARNING,
|
122 |
-
E_USER_NOTICE => LogLevel::NOTICE,
|
123 |
-
E_STRICT => LogLevel::NOTICE,
|
124 |
-
E_RECOVERABLE_ERROR => LogLevel::ERROR,
|
125 |
-
E_DEPRECATED => LogLevel::NOTICE,
|
126 |
-
E_USER_DEPRECATED => LogLevel::NOTICE,
|
127 |
-
);
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* @private
|
132 |
-
*/
|
133 |
-
public function handleException($e)
|
134 |
-
{
|
135 |
-
$this->logger->log(
|
136 |
-
$this->uncaughtExceptionLevel === null ? LogLevel::ERROR : $this->uncaughtExceptionLevel,
|
137 |
-
sprintf('Uncaught Exception %s: "%s" at %s line %s', Utils::getClass($e), $e->getMessage(), $e->getFile(), $e->getLine()),
|
138 |
-
array('exception' => $e)
|
139 |
-
);
|
140 |
-
|
141 |
-
if ($this->previousExceptionHandler) {
|
142 |
-
call_user_func($this->previousExceptionHandler, $e);
|
143 |
-
}
|
144 |
-
|
145 |
-
exit(255);
|
146 |
-
}
|
147 |
-
|
148 |
-
/**
|
149 |
-
* @private
|
150 |
-
*/
|
151 |
-
public function handleError($code, $message, $file = '', $line = 0, $context = array())
|
152 |
-
{
|
153 |
-
if ($this->handleOnlyReportedErrors && !(error_reporting() & $code)) {
|
154 |
-
return;
|
155 |
-
}
|
156 |
-
|
157 |
-
// fatal error codes are ignored if a fatal error handler is present as well to avoid duplicate log entries
|
158 |
-
if (!$this->hasFatalErrorHandler || !in_array($code, self::$fatalErrors, true)) {
|
159 |
-
$level = isset($this->errorLevelMap[$code]) ? $this->errorLevelMap[$code] : LogLevel::CRITICAL;
|
160 |
-
$this->logger->log($level, self::codeToString($code).': '.$message, array('code' => $code, 'message' => $message, 'file' => $file, 'line' => $line));
|
161 |
-
} else {
|
162 |
-
// http://php.net/manual/en/function.debug-backtrace.php
|
163 |
-
// As of 5.3.6, DEBUG_BACKTRACE_IGNORE_ARGS option was added.
|
164 |
-
// Any version less than 5.3.6 must use the DEBUG_BACKTRACE_IGNORE_ARGS constant value '2'.
|
165 |
-
$trace = debug_backtrace((PHP_VERSION_ID < 50306) ? 2 : DEBUG_BACKTRACE_IGNORE_ARGS);
|
166 |
-
array_shift($trace); // Exclude handleError from trace
|
167 |
-
$this->lastFatalTrace = $trace;
|
168 |
-
}
|
169 |
-
|
170 |
-
if ($this->previousErrorHandler === true) {
|
171 |
-
return false;
|
172 |
-
} elseif ($this->previousErrorHandler) {
|
173 |
-
return call_user_func($this->previousErrorHandler, $code, $message, $file, $line, $context);
|
174 |
-
}
|
175 |
-
}
|
176 |
-
|
177 |
-
/**
|
178 |
-
* @private
|
179 |
-
*/
|
180 |
-
public function handleFatalError()
|
181 |
-
{
|
182 |
-
$this->reservedMemory = null;
|
183 |
-
|
184 |
-
$lastError = error_get_last();
|
185 |
-
if ($lastError && in_array($lastError['type'], self::$fatalErrors, true)) {
|
186 |
-
$this->logger->log(
|
187 |
-
$this->fatalLevel === null ? LogLevel::ALERT : $this->fatalLevel,
|
188 |
-
'Fatal Error ('.self::codeToString($lastError['type']).'): '.$lastError['message'],
|
189 |
-
array('code' => $lastError['type'], 'message' => $lastError['message'], 'file' => $lastError['file'], 'line' => $lastError['line'], 'trace' => $this->lastFatalTrace)
|
190 |
-
);
|
191 |
-
|
192 |
-
if ($this->logger instanceof Logger) {
|
193 |
-
foreach ($this->logger->getHandlers() as $handler) {
|
194 |
-
if ($handler instanceof AbstractHandler) {
|
195 |
-
$handler->close();
|
196 |
-
}
|
197 |
-
}
|
198 |
-
}
|
199 |
-
}
|
200 |
-
}
|
201 |
-
|
202 |
-
private static function codeToString($code)
|
203 |
-
{
|
204 |
-
switch ($code) {
|
205 |
-
case E_ERROR:
|
206 |
-
return 'E_ERROR';
|
207 |
-
case E_WARNING:
|
208 |
-
return 'E_WARNING';
|
209 |
-
case E_PARSE:
|
210 |
-
return 'E_PARSE';
|
211 |
-
case E_NOTICE:
|
212 |
-
return 'E_NOTICE';
|
213 |
-
case E_CORE_ERROR:
|
214 |
-
return 'E_CORE_ERROR';
|
215 |
-
case E_CORE_WARNING:
|
216 |
-
return 'E_CORE_WARNING';
|
217 |
-
case E_COMPILE_ERROR:
|
218 |
-
return 'E_COMPILE_ERROR';
|
219 |
-
case E_COMPILE_WARNING:
|
220 |
-
return 'E_COMPILE_WARNING';
|
221 |
-
case E_USER_ERROR:
|
222 |
-
return 'E_USER_ERROR';
|
223 |
-
case E_USER_WARNING:
|
224 |
-
return 'E_USER_WARNING';
|
225 |
-
case E_USER_NOTICE:
|
226 |
-
return 'E_USER_NOTICE';
|
227 |
-
case E_STRICT:
|
228 |
-
return 'E_STRICT';
|
229 |
-
case E_RECOVERABLE_ERROR:
|
230 |
-
return 'E_RECOVERABLE_ERROR';
|
231 |
-
case E_DEPRECATED:
|
232 |
-
return 'E_DEPRECATED';
|
233 |
-
case E_USER_DEPRECATED:
|
234 |
-
return 'E_USER_DEPRECATED';
|
235 |
-
}
|
236 |
-
|
237 |
-
return 'Unknown PHP error';
|
238 |
-
}
|
239 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php
DELETED
@@ -1,78 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Formats a log message according to the ChromePHP array format
|
18 |
-
*
|
19 |
-
* @author Christophe Coevoet <stof@notk.org>
|
20 |
-
*/
|
21 |
-
class ChromePHPFormatter implements FormatterInterface
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* Translates Monolog log levels to Wildfire levels.
|
25 |
-
*/
|
26 |
-
private $logLevels = array(
|
27 |
-
Logger::DEBUG => 'log',
|
28 |
-
Logger::INFO => 'info',
|
29 |
-
Logger::NOTICE => 'info',
|
30 |
-
Logger::WARNING => 'warn',
|
31 |
-
Logger::ERROR => 'error',
|
32 |
-
Logger::CRITICAL => 'error',
|
33 |
-
Logger::ALERT => 'error',
|
34 |
-
Logger::EMERGENCY => 'error',
|
35 |
-
);
|
36 |
-
|
37 |
-
/**
|
38 |
-
* {@inheritdoc}
|
39 |
-
*/
|
40 |
-
public function format(array $record)
|
41 |
-
{
|
42 |
-
// Retrieve the line and file if set and remove them from the formatted extra
|
43 |
-
$backtrace = 'unknown';
|
44 |
-
if (isset($record['extra']['file'], $record['extra']['line'])) {
|
45 |
-
$backtrace = $record['extra']['file'].' : '.$record['extra']['line'];
|
46 |
-
unset($record['extra']['file'], $record['extra']['line']);
|
47 |
-
}
|
48 |
-
|
49 |
-
$message = array('message' => $record['message']);
|
50 |
-
if ($record['context']) {
|
51 |
-
$message['context'] = $record['context'];
|
52 |
-
}
|
53 |
-
if ($record['extra']) {
|
54 |
-
$message['extra'] = $record['extra'];
|
55 |
-
}
|
56 |
-
if (count($message) === 1) {
|
57 |
-
$message = reset($message);
|
58 |
-
}
|
59 |
-
|
60 |
-
return array(
|
61 |
-
$record['channel'],
|
62 |
-
$message,
|
63 |
-
$backtrace,
|
64 |
-
$this->logLevels[$record['level']],
|
65 |
-
);
|
66 |
-
}
|
67 |
-
|
68 |
-
public function formatBatch(array $records)
|
69 |
-
{
|
70 |
-
$formatted = array();
|
71 |
-
|
72 |
-
foreach ($records as $record) {
|
73 |
-
$formatted[] = $this->format($record);
|
74 |
-
}
|
75 |
-
|
76 |
-
return $formatted;
|
77 |
-
}
|
78 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php
DELETED
@@ -1,89 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Elastica\Document;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Format a log message into an Elastica Document
|
18 |
-
*
|
19 |
-
* @author Jelle Vink <jelle.vink@gmail.com>
|
20 |
-
*/
|
21 |
-
class ElasticaFormatter extends NormalizerFormatter
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* @var string Elastic search index name
|
25 |
-
*/
|
26 |
-
protected $index;
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @var string Elastic search document type
|
30 |
-
*/
|
31 |
-
protected $type;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* @param string $index Elastic Search index name
|
35 |
-
* @param string $type Elastic Search document type
|
36 |
-
*/
|
37 |
-
public function __construct($index, $type)
|
38 |
-
{
|
39 |
-
// elasticsearch requires a ISO 8601 format date with optional millisecond precision.
|
40 |
-
parent::__construct('Y-m-d\TH:i:s.uP');
|
41 |
-
|
42 |
-
$this->index = $index;
|
43 |
-
$this->type = $type;
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* {@inheritdoc}
|
48 |
-
*/
|
49 |
-
public function format(array $record)
|
50 |
-
{
|
51 |
-
$record = parent::format($record);
|
52 |
-
|
53 |
-
return $this->getDocument($record);
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Getter index
|
58 |
-
* @return string
|
59 |
-
*/
|
60 |
-
public function getIndex()
|
61 |
-
{
|
62 |
-
return $this->index;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Getter type
|
67 |
-
* @return string
|
68 |
-
*/
|
69 |
-
public function getType()
|
70 |
-
{
|
71 |
-
return $this->type;
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Convert a log message into an Elastica Document
|
76 |
-
*
|
77 |
-
* @param array $record Log message
|
78 |
-
* @return Document
|
79 |
-
*/
|
80 |
-
protected function getDocument($record)
|
81 |
-
{
|
82 |
-
$document = new Document();
|
83 |
-
$document->setData($record);
|
84 |
-
$document->setType($this->type);
|
85 |
-
$document->setIndex($this->index);
|
86 |
-
|
87 |
-
return $document;
|
88 |
-
}
|
89 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Formatter/FlowdockFormatter.php
DELETED
@@ -1,116 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* formats the record to be used in the FlowdockHandler
|
16 |
-
*
|
17 |
-
* @author Dominik Liebler <liebler.dominik@gmail.com>
|
18 |
-
*/
|
19 |
-
class FlowdockFormatter implements FormatterInterface
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* @var string
|
23 |
-
*/
|
24 |
-
private $source;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @var string
|
28 |
-
*/
|
29 |
-
private $sourceEmail;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @param string $source
|
33 |
-
* @param string $sourceEmail
|
34 |
-
*/
|
35 |
-
public function __construct($source, $sourceEmail)
|
36 |
-
{
|
37 |
-
$this->source = $source;
|
38 |
-
$this->sourceEmail = $sourceEmail;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* {@inheritdoc}
|
43 |
-
*/
|
44 |
-
public function format(array $record)
|
45 |
-
{
|
46 |
-
$tags = array(
|
47 |
-
'#logs',
|
48 |
-
'#' . strtolower($record['level_name']),
|
49 |
-
'#' . $record['channel'],
|
50 |
-
);
|
51 |
-
|
52 |
-
foreach ($record['extra'] as $value) {
|
53 |
-
$tags[] = '#' . $value;
|
54 |
-
}
|
55 |
-
|
56 |
-
$subject = sprintf(
|
57 |
-
'in %s: %s - %s',
|
58 |
-
$this->source,
|
59 |
-
$record['level_name'],
|
60 |
-
$this->getShortMessage($record['message'])
|
61 |
-
);
|
62 |
-
|
63 |
-
$record['flowdock'] = array(
|
64 |
-
'source' => $this->source,
|
65 |
-
'from_address' => $this->sourceEmail,
|
66 |
-
'subject' => $subject,
|
67 |
-
'content' => $record['message'],
|
68 |
-
'tags' => $tags,
|
69 |
-
'project' => $this->source,
|
70 |
-
);
|
71 |
-
|
72 |
-
return $record;
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* {@inheritdoc}
|
77 |
-
*/
|
78 |
-
public function formatBatch(array $records)
|
79 |
-
{
|
80 |
-
$formatted = array();
|
81 |
-
|
82 |
-
foreach ($records as $record) {
|
83 |
-
$formatted[] = $this->format($record);
|
84 |
-
}
|
85 |
-
|
86 |
-
return $formatted;
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* @param string $message
|
91 |
-
*
|
92 |
-
* @return string
|
93 |
-
*/
|
94 |
-
public function getShortMessage($message)
|
95 |
-
{
|
96 |
-
static $hasMbString;
|
97 |
-
|
98 |
-
if (null === $hasMbString) {
|
99 |
-
$hasMbString = function_exists('mb_strlen');
|
100 |
-
}
|
101 |
-
|
102 |
-
$maxLength = 45;
|
103 |
-
|
104 |
-
if ($hasMbString) {
|
105 |
-
if (mb_strlen($message, 'UTF-8') > $maxLength) {
|
106 |
-
$message = mb_substr($message, 0, $maxLength - 4, 'UTF-8') . ' ...';
|
107 |
-
}
|
108 |
-
} else {
|
109 |
-
if (strlen($message) > $maxLength) {
|
110 |
-
$message = substr($message, 0, $maxLength - 4) . ' ...';
|
111 |
-
}
|
112 |
-
}
|
113 |
-
|
114 |
-
return $message;
|
115 |
-
}
|
116 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php
DELETED
@@ -1,86 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Class FluentdFormatter
|
16 |
-
*
|
17 |
-
* Serializes a log message to Fluentd unix socket protocol
|
18 |
-
*
|
19 |
-
* Fluentd config:
|
20 |
-
*
|
21 |
-
* <source>
|
22 |
-
* type unix
|
23 |
-
* path /var/run/td-agent/td-agent.sock
|
24 |
-
* </source>
|
25 |
-
*
|
26 |
-
* Monolog setup:
|
27 |
-
*
|
28 |
-
* $logger = new Monolog\Logger('fluent.tag');
|
29 |
-
* $fluentHandler = new Monolog\Handler\SocketHandler('unix:///var/run/td-agent/td-agent.sock');
|
30 |
-
* $fluentHandler->setFormatter(new Monolog\Formatter\FluentdFormatter());
|
31 |
-
* $logger->pushHandler($fluentHandler);
|
32 |
-
*
|
33 |
-
* @author Andrius Putna <fordnox@gmail.com>
|
34 |
-
*/
|
35 |
-
class FluentdFormatter implements FormatterInterface
|
36 |
-
{
|
37 |
-
/**
|
38 |
-
* @var bool $levelTag should message level be a part of the fluentd tag
|
39 |
-
*/
|
40 |
-
protected $levelTag = false;
|
41 |
-
|
42 |
-
public function __construct($levelTag = false)
|
43 |
-
{
|
44 |
-
if (!function_exists('json_encode')) {
|
45 |
-
throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s FluentdUnixFormatter');
|
46 |
-
}
|
47 |
-
|
48 |
-
$this->levelTag = (bool) $levelTag;
|
49 |
-
}
|
50 |
-
|
51 |
-
public function isUsingLevelsInTag()
|
52 |
-
{
|
53 |
-
return $this->levelTag;
|
54 |
-
}
|
55 |
-
|
56 |
-
public function format(array $record)
|
57 |
-
{
|
58 |
-
$tag = $record['channel'];
|
59 |
-
if ($this->levelTag) {
|
60 |
-
$tag .= '.' . strtolower($record['level_name']);
|
61 |
-
}
|
62 |
-
|
63 |
-
$message = array(
|
64 |
-
'message' => $record['message'],
|
65 |
-
'context' => $record['context'],
|
66 |
-
'extra' => $record['extra'],
|
67 |
-
);
|
68 |
-
|
69 |
-
if (!$this->levelTag) {
|
70 |
-
$message['level'] = $record['level'];
|
71 |
-
$message['level_name'] = $record['level_name'];
|
72 |
-
}
|
73 |
-
|
74 |
-
return json_encode(array($tag, $record['datetime']->getTimestamp(), $message));
|
75 |
-
}
|
76 |
-
|
77 |
-
public function formatBatch(array $records)
|
78 |
-
{
|
79 |
-
$message = '';
|
80 |
-
foreach ($records as $record) {
|
81 |
-
$message .= $this->format($record);
|
82 |
-
}
|
83 |
-
|
84 |
-
return $message;
|
85 |
-
}
|
86 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Formatter/FormatterInterface.php
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Interface for formatters
|
16 |
-
*
|
17 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
18 |
-
*/
|
19 |
-
interface FormatterInterface
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* Formats a log record.
|
23 |
-
*
|
24 |
-
* @param array $record A record to format
|
25 |
-
* @return mixed The formatted record
|
26 |
-
*/
|
27 |
-
public function format(array $record);
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Formats a set of log records.
|
31 |
-
*
|
32 |
-
* @param array $records A set of records to format
|
33 |
-
* @return mixed The formatted set of records
|
34 |
-
*/
|
35 |
-
public function formatBatch(array $records);
|
36 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php
DELETED
@@ -1,138 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Gelf\Message;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Serializes a log message to GELF
|
19 |
-
* @see http://www.graylog2.org/about/gelf
|
20 |
-
*
|
21 |
-
* @author Matt Lehner <mlehner@gmail.com>
|
22 |
-
*/
|
23 |
-
class GelfMessageFormatter extends NormalizerFormatter
|
24 |
-
{
|
25 |
-
const DEFAULT_MAX_LENGTH = 32766;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* @var string the name of the system for the Gelf log message
|
29 |
-
*/
|
30 |
-
protected $systemName;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @var string a prefix for 'extra' fields from the Monolog record (optional)
|
34 |
-
*/
|
35 |
-
protected $extraPrefix;
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @var string a prefix for 'context' fields from the Monolog record (optional)
|
39 |
-
*/
|
40 |
-
protected $contextPrefix;
|
41 |
-
|
42 |
-
/**
|
43 |
-
* @var int max length per field
|
44 |
-
*/
|
45 |
-
protected $maxLength;
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Translates Monolog log levels to Graylog2 log priorities.
|
49 |
-
*/
|
50 |
-
private $logLevels = array(
|
51 |
-
Logger::DEBUG => 7,
|
52 |
-
Logger::INFO => 6,
|
53 |
-
Logger::NOTICE => 5,
|
54 |
-
Logger::WARNING => 4,
|
55 |
-
Logger::ERROR => 3,
|
56 |
-
Logger::CRITICAL => 2,
|
57 |
-
Logger::ALERT => 1,
|
58 |
-
Logger::EMERGENCY => 0,
|
59 |
-
);
|
60 |
-
|
61 |
-
public function __construct($systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_', $maxLength = null)
|
62 |
-
{
|
63 |
-
parent::__construct('U.u');
|
64 |
-
|
65 |
-
$this->systemName = $systemName ?: gethostname();
|
66 |
-
|
67 |
-
$this->extraPrefix = $extraPrefix;
|
68 |
-
$this->contextPrefix = $contextPrefix;
|
69 |
-
$this->maxLength = is_null($maxLength) ? self::DEFAULT_MAX_LENGTH : $maxLength;
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* {@inheritdoc}
|
74 |
-
*/
|
75 |
-
public function format(array $record)
|
76 |
-
{
|
77 |
-
$record = parent::format($record);
|
78 |
-
|
79 |
-
if (!isset($record['datetime'], $record['message'], $record['level'])) {
|
80 |
-
throw new \InvalidArgumentException('The record should at least contain datetime, message and level keys, '.var_export($record, true).' given');
|
81 |
-
}
|
82 |
-
|
83 |
-
$message = new Message();
|
84 |
-
$message
|
85 |
-
->setTimestamp($record['datetime'])
|
86 |
-
->setShortMessage((string) $record['message'])
|
87 |
-
->setHost($this->systemName)
|
88 |
-
->setLevel($this->logLevels[$record['level']]);
|
89 |
-
|
90 |
-
// message length + system name length + 200 for padding / metadata
|
91 |
-
$len = 200 + strlen((string) $record['message']) + strlen($this->systemName);
|
92 |
-
|
93 |
-
if ($len > $this->maxLength) {
|
94 |
-
$message->setShortMessage(substr($record['message'], 0, $this->maxLength));
|
95 |
-
}
|
96 |
-
|
97 |
-
if (isset($record['channel'])) {
|
98 |
-
$message->setFacility($record['channel']);
|
99 |
-
}
|
100 |
-
if (isset($record['extra']['line'])) {
|
101 |
-
$message->setLine($record['extra']['line']);
|
102 |
-
unset($record['extra']['line']);
|
103 |
-
}
|
104 |
-
if (isset($record['extra']['file'])) {
|
105 |
-
$message->setFile($record['extra']['file']);
|
106 |
-
unset($record['extra']['file']);
|
107 |
-
}
|
108 |
-
|
109 |
-
foreach ($record['extra'] as $key => $val) {
|
110 |
-
$val = is_scalar($val) || null === $val ? $val : $this->toJson($val);
|
111 |
-
$len = strlen($this->extraPrefix . $key . $val);
|
112 |
-
if ($len > $this->maxLength) {
|
113 |
-
$message->setAdditional($this->extraPrefix . $key, substr($val, 0, $this->maxLength));
|
114 |
-
break;
|
115 |
-
}
|
116 |
-
$message->setAdditional($this->extraPrefix . $key, $val);
|
117 |
-
}
|
118 |
-
|
119 |
-
foreach ($record['context'] as $key => $val) {
|
120 |
-
$val = is_scalar($val) || null === $val ? $val : $this->toJson($val);
|
121 |
-
$len = strlen($this->contextPrefix . $key . $val);
|
122 |
-
if ($len > $this->maxLength) {
|
123 |
-
$message->setAdditional($this->contextPrefix . $key, substr($val, 0, $this->maxLength));
|
124 |
-
break;
|
125 |
-
}
|
126 |
-
$message->setAdditional($this->contextPrefix . $key, $val);
|
127 |
-
}
|
128 |
-
|
129 |
-
if (null === $message->getFile() && isset($record['context']['exception']['file'])) {
|
130 |
-
if (preg_match("/^(.+):([0-9]+)$/", $record['context']['exception']['file'], $matches)) {
|
131 |
-
$message->setFile($matches[1]);
|
132 |
-
$message->setLine($matches[2]);
|
133 |
-
}
|
134 |
-
}
|
135 |
-
|
136 |
-
return $message;
|
137 |
-
}
|
138 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php
DELETED
@@ -1,141 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* This file is part of the Monolog package.
|
4 |
-
*
|
5 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
6 |
-
*
|
7 |
-
* For the full copyright and license information, please view the LICENSE
|
8 |
-
* file that was distributed with this source code.
|
9 |
-
*/
|
10 |
-
|
11 |
-
namespace Monolog\Formatter;
|
12 |
-
|
13 |
-
use Monolog\Logger;
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Formats incoming records into an HTML table
|
17 |
-
*
|
18 |
-
* This is especially useful for html email logging
|
19 |
-
*
|
20 |
-
* @author Tiago Brito <tlfbrito@gmail.com>
|
21 |
-
*/
|
22 |
-
class HtmlFormatter extends NormalizerFormatter
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* Translates Monolog log levels to html color priorities.
|
26 |
-
*/
|
27 |
-
protected $logLevels = array(
|
28 |
-
Logger::DEBUG => '#cccccc',
|
29 |
-
Logger::INFO => '#468847',
|
30 |
-
Logger::NOTICE => '#3a87ad',
|
31 |
-
Logger::WARNING => '#c09853',
|
32 |
-
Logger::ERROR => '#f0ad4e',
|
33 |
-
Logger::CRITICAL => '#FF7708',
|
34 |
-
Logger::ALERT => '#C12A19',
|
35 |
-
Logger::EMERGENCY => '#000000',
|
36 |
-
);
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @param string $dateFormat The format of the timestamp: one supported by DateTime::format
|
40 |
-
*/
|
41 |
-
public function __construct($dateFormat = null)
|
42 |
-
{
|
43 |
-
parent::__construct($dateFormat);
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Creates an HTML table row
|
48 |
-
*
|
49 |
-
* @param string $th Row header content
|
50 |
-
* @param string $td Row standard cell content
|
51 |
-
* @param bool $escapeTd false if td content must not be html escaped
|
52 |
-
* @return string
|
53 |
-
*/
|
54 |
-
protected function addRow($th, $td = ' ', $escapeTd = true)
|
55 |
-
{
|
56 |
-
$th = htmlspecialchars($th, ENT_NOQUOTES, 'UTF-8');
|
57 |
-
if ($escapeTd) {
|
58 |
-
$td = '<pre>'.htmlspecialchars($td, ENT_NOQUOTES, 'UTF-8').'</pre>';
|
59 |
-
}
|
60 |
-
|
61 |
-
return "<tr style=\"padding: 4px;text-align: left;\">\n<th style=\"vertical-align: top;background: #ccc;color: #000\" width=\"100\">$th:</th>\n<td style=\"padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000\">".$td."</td>\n</tr>";
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Create a HTML h1 tag
|
66 |
-
*
|
67 |
-
* @param string $title Text to be in the h1
|
68 |
-
* @param int $level Error level
|
69 |
-
* @return string
|
70 |
-
*/
|
71 |
-
protected function addTitle($title, $level)
|
72 |
-
{
|
73 |
-
$title = htmlspecialchars($title, ENT_NOQUOTES, 'UTF-8');
|
74 |
-
|
75 |
-
return '<h1 style="background: '.$this->logLevels[$level].';color: #ffffff;padding: 5px;" class="monolog-output">'.$title.'</h1>';
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Formats a log record.
|
80 |
-
*
|
81 |
-
* @param array $record A record to format
|
82 |
-
* @return mixed The formatted record
|
83 |
-
*/
|
84 |
-
public function format(array $record)
|
85 |
-
{
|
86 |
-
$output = $this->addTitle($record['level_name'], $record['level']);
|
87 |
-
$output .= '<table cellspacing="1" width="100%" class="monolog-output">';
|
88 |
-
|
89 |
-
$output .= $this->addRow('Message', (string) $record['message']);
|
90 |
-
$output .= $this->addRow('Time', $record['datetime']->format($this->dateFormat));
|
91 |
-
$output .= $this->addRow('Channel', $record['channel']);
|
92 |
-
if ($record['context']) {
|
93 |
-
$embeddedTable = '<table cellspacing="1" width="100%">';
|
94 |
-
foreach ($record['context'] as $key => $value) {
|
95 |
-
$embeddedTable .= $this->addRow($key, $this->convertToString($value));
|
96 |
-
}
|
97 |
-
$embeddedTable .= '</table>';
|
98 |
-
$output .= $this->addRow('Context', $embeddedTable, false);
|
99 |
-
}
|
100 |
-
if ($record['extra']) {
|
101 |
-
$embeddedTable = '<table cellspacing="1" width="100%">';
|
102 |
-
foreach ($record['extra'] as $key => $value) {
|
103 |
-
$embeddedTable .= $this->addRow($key, $this->convertToString($value));
|
104 |
-
}
|
105 |
-
$embeddedTable .= '</table>';
|
106 |
-
$output .= $this->addRow('Extra', $embeddedTable, false);
|
107 |
-
}
|
108 |
-
|
109 |
-
return $output.'</table>';
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Formats a set of log records.
|
114 |
-
*
|
115 |
-
* @param array $records A set of records to format
|
116 |
-
* @return mixed The formatted set of records
|
117 |
-
*/
|
118 |
-
public function formatBatch(array $records)
|
119 |
-
{
|
120 |
-
$message = '';
|
121 |
-
foreach ($records as $record) {
|
122 |
-
$message .= $this->format($record);
|
123 |
-
}
|
124 |
-
|
125 |
-
return $message;
|
126 |
-
}
|
127 |
-
|
128 |
-
protected function convertToString($data)
|
129 |
-
{
|
130 |
-
if (null === $data || is_scalar($data)) {
|
131 |
-
return (string) $data;
|
132 |
-
}
|
133 |
-
|
134 |
-
$data = $this->normalize($data);
|
135 |
-
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
|
136 |
-
return json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
137 |
-
}
|
138 |
-
|
139 |
-
return str_replace('\\/', '/', json_encode($data));
|
140 |
-
}
|
141 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php
DELETED
@@ -1,208 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Exception;
|
15 |
-
use Monolog\Utils;
|
16 |
-
use Throwable;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Encodes whatever record data is passed to it as json
|
20 |
-
*
|
21 |
-
* This can be useful to log to databases or remote APIs
|
22 |
-
*
|
23 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
24 |
-
*/
|
25 |
-
class JsonFormatter extends NormalizerFormatter
|
26 |
-
{
|
27 |
-
const BATCH_MODE_JSON = 1;
|
28 |
-
const BATCH_MODE_NEWLINES = 2;
|
29 |
-
|
30 |
-
protected $batchMode;
|
31 |
-
protected $appendNewline;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* @var bool
|
35 |
-
*/
|
36 |
-
protected $includeStacktraces = false;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @param int $batchMode
|
40 |
-
* @param bool $appendNewline
|
41 |
-
*/
|
42 |
-
public function __construct($batchMode = self::BATCH_MODE_JSON, $appendNewline = true)
|
43 |
-
{
|
44 |
-
$this->batchMode = $batchMode;
|
45 |
-
$this->appendNewline = $appendNewline;
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* The batch mode option configures the formatting style for
|
50 |
-
* multiple records. By default, multiple records will be
|
51 |
-
* formatted as a JSON-encoded array. However, for
|
52 |
-
* compatibility with some API endpoints, alternative styles
|
53 |
-
* are available.
|
54 |
-
*
|
55 |
-
* @return int
|
56 |
-
*/
|
57 |
-
public function getBatchMode()
|
58 |
-
{
|
59 |
-
return $this->batchMode;
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* True if newlines are appended to every formatted record
|
64 |
-
*
|
65 |
-
* @return bool
|
66 |
-
*/
|
67 |
-
public function isAppendingNewlines()
|
68 |
-
{
|
69 |
-
return $this->appendNewline;
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* {@inheritdoc}
|
74 |
-
*/
|
75 |
-
public function format(array $record)
|
76 |
-
{
|
77 |
-
return $this->toJson($this->normalize($record), true) . ($this->appendNewline ? "\n" : '');
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* {@inheritdoc}
|
82 |
-
*/
|
83 |
-
public function formatBatch(array $records)
|
84 |
-
{
|
85 |
-
switch ($this->batchMode) {
|
86 |
-
case static::BATCH_MODE_NEWLINES:
|
87 |
-
return $this->formatBatchNewlines($records);
|
88 |
-
|
89 |
-
case static::BATCH_MODE_JSON:
|
90 |
-
default:
|
91 |
-
return $this->formatBatchJson($records);
|
92 |
-
}
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* @param bool $include
|
97 |
-
*/
|
98 |
-
public function includeStacktraces($include = true)
|
99 |
-
{
|
100 |
-
$this->includeStacktraces = $include;
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Return a JSON-encoded array of records.
|
105 |
-
*
|
106 |
-
* @param array $records
|
107 |
-
* @return string
|
108 |
-
*/
|
109 |
-
protected function formatBatchJson(array $records)
|
110 |
-
{
|
111 |
-
return $this->toJson($this->normalize($records), true);
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* Use new lines to separate records instead of a
|
116 |
-
* JSON-encoded array.
|
117 |
-
*
|
118 |
-
* @param array $records
|
119 |
-
* @return string
|
120 |
-
*/
|
121 |
-
protected function formatBatchNewlines(array $records)
|
122 |
-
{
|
123 |
-
$instance = $this;
|
124 |
-
|
125 |
-
$oldNewline = $this->appendNewline;
|
126 |
-
$this->appendNewline = false;
|
127 |
-
array_walk($records, function (&$value, $key) use ($instance) {
|
128 |
-
$value = $instance->format($value);
|
129 |
-
});
|
130 |
-
$this->appendNewline = $oldNewline;
|
131 |
-
|
132 |
-
return implode("\n", $records);
|
133 |
-
}
|
134 |
-
|
135 |
-
/**
|
136 |
-
* Normalizes given $data.
|
137 |
-
*
|
138 |
-
* @param mixed $data
|
139 |
-
*
|
140 |
-
* @return mixed
|
141 |
-
*/
|
142 |
-
protected function normalize($data, $depth = 0)
|
143 |
-
{
|
144 |
-
if ($depth > 9) {
|
145 |
-
return 'Over 9 levels deep, aborting normalization';
|
146 |
-
}
|
147 |
-
|
148 |
-
if (is_array($data) || $data instanceof \Traversable) {
|
149 |
-
$normalized = array();
|
150 |
-
|
151 |
-
$count = 1;
|
152 |
-
foreach ($data as $key => $value) {
|
153 |
-
if ($count++ > 1000) {
|
154 |
-
$normalized['...'] = 'Over 1000 items ('.count($data).' total), aborting normalization';
|
155 |
-
break;
|
156 |
-
}
|
157 |
-
|
158 |
-
$normalized[$key] = $this->normalize($value, $depth+1);
|
159 |
-
}
|
160 |
-
|
161 |
-
return $normalized;
|
162 |
-
}
|
163 |
-
|
164 |
-
if ($data instanceof Exception || $data instanceof Throwable) {
|
165 |
-
return $this->normalizeException($data);
|
166 |
-
}
|
167 |
-
|
168 |
-
return $data;
|
169 |
-
}
|
170 |
-
|
171 |
-
/**
|
172 |
-
* Normalizes given exception with or without its own stack trace based on
|
173 |
-
* `includeStacktraces` property.
|
174 |
-
*
|
175 |
-
* @param Exception|Throwable $e
|
176 |
-
*
|
177 |
-
* @return array
|
178 |
-
*/
|
179 |
-
protected function normalizeException($e)
|
180 |
-
{
|
181 |
-
// TODO 2.0 only check for Throwable
|
182 |
-
if (!$e instanceof Exception && !$e instanceof Throwable) {
|
183 |
-
throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.Utils::getClass($e));
|
184 |
-
}
|
185 |
-
|
186 |
-
$data = array(
|
187 |
-
'class' => Utils::getClass($e),
|
188 |
-
'message' => $e->getMessage(),
|
189 |
-
'code' => $e->getCode(),
|
190 |
-
'file' => $e->getFile().':'.$e->getLine(),
|
191 |
-
);
|
192 |
-
|
193 |
-
if ($this->includeStacktraces) {
|
194 |
-
$trace = $e->getTrace();
|
195 |
-
foreach ($trace as $frame) {
|
196 |
-
if (isset($frame['file'])) {
|
197 |
-
$data['trace'][] = $frame['file'].':'.$frame['line'];
|
198 |
-
}
|
199 |
-
}
|
200 |
-
}
|
201 |
-
|
202 |
-
if ($previous = $e->getPrevious()) {
|
203 |
-
$data['previous'] = $this->normalizeException($previous);
|
204 |
-
}
|
205 |
-
|
206 |
-
return $data;
|
207 |
-
}
|
208 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php
DELETED
@@ -1,181 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Monolog\Utils;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Formats incoming records into a one-line string
|
18 |
-
*
|
19 |
-
* This is especially useful for logging to files
|
20 |
-
*
|
21 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
22 |
-
* @author Christophe Coevoet <stof@notk.org>
|
23 |
-
*/
|
24 |
-
class LineFormatter extends NormalizerFormatter
|
25 |
-
{
|
26 |
-
const SIMPLE_FORMAT = "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n";
|
27 |
-
|
28 |
-
protected $format;
|
29 |
-
protected $allowInlineLineBreaks;
|
30 |
-
protected $ignoreEmptyContextAndExtra;
|
31 |
-
protected $includeStacktraces;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* @param string $format The format of the message
|
35 |
-
* @param string $dateFormat The format of the timestamp: one supported by DateTime::format
|
36 |
-
* @param bool $allowInlineLineBreaks Whether to allow inline line breaks in log entries
|
37 |
-
* @param bool $ignoreEmptyContextAndExtra
|
38 |
-
*/
|
39 |
-
public function __construct($format = null, $dateFormat = null, $allowInlineLineBreaks = false, $ignoreEmptyContextAndExtra = false)
|
40 |
-
{
|
41 |
-
$this->format = $format ?: static::SIMPLE_FORMAT;
|
42 |
-
$this->allowInlineLineBreaks = $allowInlineLineBreaks;
|
43 |
-
$this->ignoreEmptyContextAndExtra = $ignoreEmptyContextAndExtra;
|
44 |
-
parent::__construct($dateFormat);
|
45 |
-
}
|
46 |
-
|
47 |
-
public function includeStacktraces($include = true)
|
48 |
-
{
|
49 |
-
$this->includeStacktraces = $include;
|
50 |
-
if ($this->includeStacktraces) {
|
51 |
-
$this->allowInlineLineBreaks = true;
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
public function allowInlineLineBreaks($allow = true)
|
56 |
-
{
|
57 |
-
$this->allowInlineLineBreaks = $allow;
|
58 |
-
}
|
59 |
-
|
60 |
-
public function ignoreEmptyContextAndExtra($ignore = true)
|
61 |
-
{
|
62 |
-
$this->ignoreEmptyContextAndExtra = $ignore;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* {@inheritdoc}
|
67 |
-
*/
|
68 |
-
public function format(array $record)
|
69 |
-
{
|
70 |
-
$vars = parent::format($record);
|
71 |
-
|
72 |
-
$output = $this->format;
|
73 |
-
|
74 |
-
foreach ($vars['extra'] as $var => $val) {
|
75 |
-
if (false !== strpos($output, '%extra.'.$var.'%')) {
|
76 |
-
$output = str_replace('%extra.'.$var.'%', $this->stringify($val), $output);
|
77 |
-
unset($vars['extra'][$var]);
|
78 |
-
}
|
79 |
-
}
|
80 |
-
|
81 |
-
|
82 |
-
foreach ($vars['context'] as $var => $val) {
|
83 |
-
if (false !== strpos($output, '%context.'.$var.'%')) {
|
84 |
-
$output = str_replace('%context.'.$var.'%', $this->stringify($val), $output);
|
85 |
-
unset($vars['context'][$var]);
|
86 |
-
}
|
87 |
-
}
|
88 |
-
|
89 |
-
if ($this->ignoreEmptyContextAndExtra) {
|
90 |
-
if (empty($vars['context'])) {
|
91 |
-
unset($vars['context']);
|
92 |
-
$output = str_replace('%context%', '', $output);
|
93 |
-
}
|
94 |
-
|
95 |
-
if (empty($vars['extra'])) {
|
96 |
-
unset($vars['extra']);
|
97 |
-
$output = str_replace('%extra%', '', $output);
|
98 |
-
}
|
99 |
-
}
|
100 |
-
|
101 |
-
foreach ($vars as $var => $val) {
|
102 |
-
if (false !== strpos($output, '%'.$var.'%')) {
|
103 |
-
$output = str_replace('%'.$var.'%', $this->stringify($val), $output);
|
104 |
-
}
|
105 |
-
}
|
106 |
-
|
107 |
-
// remove leftover %extra.xxx% and %context.xxx% if any
|
108 |
-
if (false !== strpos($output, '%')) {
|
109 |
-
$output = preg_replace('/%(?:extra|context)\..+?%/', '', $output);
|
110 |
-
}
|
111 |
-
|
112 |
-
return $output;
|
113 |
-
}
|
114 |
-
|
115 |
-
public function formatBatch(array $records)
|
116 |
-
{
|
117 |
-
$message = '';
|
118 |
-
foreach ($records as $record) {
|
119 |
-
$message .= $this->format($record);
|
120 |
-
}
|
121 |
-
|
122 |
-
return $message;
|
123 |
-
}
|
124 |
-
|
125 |
-
public function stringify($value)
|
126 |
-
{
|
127 |
-
return $this->replaceNewlines($this->convertToString($value));
|
128 |
-
}
|
129 |
-
|
130 |
-
protected function normalizeException($e)
|
131 |
-
{
|
132 |
-
// TODO 2.0 only check for Throwable
|
133 |
-
if (!$e instanceof \Exception && !$e instanceof \Throwable) {
|
134 |
-
throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.Utils::getClass($e));
|
135 |
-
}
|
136 |
-
|
137 |
-
$previousText = '';
|
138 |
-
if ($previous = $e->getPrevious()) {
|
139 |
-
do {
|
140 |
-
$previousText .= ', '.Utils::getClass($previous).'(code: '.$previous->getCode().'): '.$previous->getMessage().' at '.$previous->getFile().':'.$previous->getLine();
|
141 |
-
} while ($previous = $previous->getPrevious());
|
142 |
-
}
|
143 |
-
|
144 |
-
$str = '[object] ('.Utils::getClass($e).'(code: '.$e->getCode().'): '.$e->getMessage().' at '.$e->getFile().':'.$e->getLine().$previousText.')';
|
145 |
-
if ($this->includeStacktraces) {
|
146 |
-
$str .= "\n[stacktrace]\n".$e->getTraceAsString()."\n";
|
147 |
-
}
|
148 |
-
|
149 |
-
return $str;
|
150 |
-
}
|
151 |
-
|
152 |
-
protected function convertToString($data)
|
153 |
-
{
|
154 |
-
if (null === $data || is_bool($data)) {
|
155 |
-
return var_export($data, true);
|
156 |
-
}
|
157 |
-
|
158 |
-
if (is_scalar($data)) {
|
159 |
-
return (string) $data;
|
160 |
-
}
|
161 |
-
|
162 |
-
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
|
163 |
-
return $this->toJson($data, true);
|
164 |
-
}
|
165 |
-
|
166 |
-
return str_replace('\\/', '/', @json_encode($data));
|
167 |
-
}
|
168 |
-
|
169 |
-
protected function replaceNewlines($str)
|
170 |
-
{
|
171 |
-
if ($this->allowInlineLineBreaks) {
|
172 |
-
if (0 === strpos($str, '{')) {
|
173 |
-
return str_replace(array('\r', '\n'), array("\r", "\n"), $str);
|
174 |
-
}
|
175 |
-
|
176 |
-
return $str;
|
177 |
-
}
|
178 |
-
|
179 |
-
return str_replace(array("\r\n", "\r", "\n"), ' ', $str);
|
180 |
-
}
|
181 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Encodes message information into JSON in a format compatible with Loggly.
|
16 |
-
*
|
17 |
-
* @author Adam Pancutt <adam@pancutt.com>
|
18 |
-
*/
|
19 |
-
class LogglyFormatter extends JsonFormatter
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* Overrides the default batch mode to new lines for compatibility with the
|
23 |
-
* Loggly bulk API.
|
24 |
-
*
|
25 |
-
* @param int $batchMode
|
26 |
-
*/
|
27 |
-
public function __construct($batchMode = self::BATCH_MODE_NEWLINES, $appendNewline = false)
|
28 |
-
{
|
29 |
-
parent::__construct($batchMode, $appendNewline);
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Appends the 'timestamp' parameter for indexing by Loggly.
|
34 |
-
*
|
35 |
-
* @see https://www.loggly.com/docs/automated-parsing/#json
|
36 |
-
* @see \Monolog\Formatter\JsonFormatter::format()
|
37 |
-
*/
|
38 |
-
public function format(array $record)
|
39 |
-
{
|
40 |
-
if (isset($record["datetime"]) && ($record["datetime"] instanceof \DateTime)) {
|
41 |
-
$record["timestamp"] = $record["datetime"]->format("Y-m-d\TH:i:s.uO");
|
42 |
-
// TODO 2.0 unset the 'datetime' parameter, retained for BC
|
43 |
-
}
|
44 |
-
|
45 |
-
return parent::format($record);
|
46 |
-
}
|
47 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php
DELETED
@@ -1,166 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Serializes a log message to Logstash Event Format
|
16 |
-
*
|
17 |
-
* @see http://logstash.net/
|
18 |
-
* @see https://github.com/logstash/logstash/blob/master/lib/logstash/event.rb
|
19 |
-
*
|
20 |
-
* @author Tim Mower <timothy.mower@gmail.com>
|
21 |
-
*/
|
22 |
-
class LogstashFormatter extends NormalizerFormatter
|
23 |
-
{
|
24 |
-
const V0 = 0;
|
25 |
-
const V1 = 1;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* @var string the name of the system for the Logstash log message, used to fill the @source field
|
29 |
-
*/
|
30 |
-
protected $systemName;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @var string an application name for the Logstash log message, used to fill the @type field
|
34 |
-
*/
|
35 |
-
protected $applicationName;
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @var string a prefix for 'extra' fields from the Monolog record (optional)
|
39 |
-
*/
|
40 |
-
protected $extraPrefix;
|
41 |
-
|
42 |
-
/**
|
43 |
-
* @var string a prefix for 'context' fields from the Monolog record (optional)
|
44 |
-
*/
|
45 |
-
protected $contextPrefix;
|
46 |
-
|
47 |
-
/**
|
48 |
-
* @var int logstash format version to use
|
49 |
-
*/
|
50 |
-
protected $version;
|
51 |
-
|
52 |
-
/**
|
53 |
-
* @param string $applicationName the application that sends the data, used as the "type" field of logstash
|
54 |
-
* @param string $systemName the system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine
|
55 |
-
* @param string $extraPrefix prefix for extra keys inside logstash "fields"
|
56 |
-
* @param string $contextPrefix prefix for context keys inside logstash "fields", defaults to ctxt_
|
57 |
-
* @param int $version the logstash format version to use, defaults to 0
|
58 |
-
*/
|
59 |
-
public function __construct($applicationName, $systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_', $version = self::V0)
|
60 |
-
{
|
61 |
-
// logstash requires a ISO 8601 format date with optional millisecond precision.
|
62 |
-
parent::__construct('Y-m-d\TH:i:s.uP');
|
63 |
-
|
64 |
-
$this->systemName = $systemName ?: gethostname();
|
65 |
-
$this->applicationName = $applicationName;
|
66 |
-
$this->extraPrefix = $extraPrefix;
|
67 |
-
$this->contextPrefix = $contextPrefix;
|
68 |
-
$this->version = $version;
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* {@inheritdoc}
|
73 |
-
*/
|
74 |
-
public function format(array $record)
|
75 |
-
{
|
76 |
-
$record = parent::format($record);
|
77 |
-
|
78 |
-
if ($this->version === self::V1) {
|
79 |
-
$message = $this->formatV1($record);
|
80 |
-
} else {
|
81 |
-
$message = $this->formatV0($record);
|
82 |
-
}
|
83 |
-
|
84 |
-
return $this->toJson($message) . "\n";
|
85 |
-
}
|
86 |
-
|
87 |
-
protected function formatV0(array $record)
|
88 |
-
{
|
89 |
-
if (empty($record['datetime'])) {
|
90 |
-
$record['datetime'] = gmdate('c');
|
91 |
-
}
|
92 |
-
$message = array(
|
93 |
-
'@timestamp' => $record['datetime'],
|
94 |
-
'@source' => $this->systemName,
|
95 |
-
'@fields' => array(),
|
96 |
-
);
|
97 |
-
if (isset($record['message'])) {
|
98 |
-
$message['@message'] = $record['message'];
|
99 |
-
}
|
100 |
-
if (isset($record['channel'])) {
|
101 |
-
$message['@tags'] = array($record['channel']);
|
102 |
-
$message['@fields']['channel'] = $record['channel'];
|
103 |
-
}
|
104 |
-
if (isset($record['level'])) {
|
105 |
-
$message['@fields']['level'] = $record['level'];
|
106 |
-
}
|
107 |
-
if ($this->applicationName) {
|
108 |
-
$message['@type'] = $this->applicationName;
|
109 |
-
}
|
110 |
-
if (isset($record['extra']['server'])) {
|
111 |
-
$message['@source_host'] = $record['extra']['server'];
|
112 |
-
}
|
113 |
-
if (isset($record['extra']['url'])) {
|
114 |
-
$message['@source_path'] = $record['extra']['url'];
|
115 |
-
}
|
116 |
-
if (!empty($record['extra'])) {
|
117 |
-
foreach ($record['extra'] as $key => $val) {
|
118 |
-
$message['@fields'][$this->extraPrefix . $key] = $val;
|
119 |
-
}
|
120 |
-
}
|
121 |
-
if (!empty($record['context'])) {
|
122 |
-
foreach ($record['context'] as $key => $val) {
|
123 |
-
$message['@fields'][$this->contextPrefix . $key] = $val;
|
124 |
-
}
|
125 |
-
}
|
126 |
-
|
127 |
-
return $message;
|
128 |
-
}
|
129 |
-
|
130 |
-
protected function formatV1(array $record)
|
131 |
-
{
|
132 |
-
if (empty($record['datetime'])) {
|
133 |
-
$record['datetime'] = gmdate('c');
|
134 |
-
}
|
135 |
-
$message = array(
|
136 |
-
'@timestamp' => $record['datetime'],
|
137 |
-
'@version' => 1,
|
138 |
-
'host' => $this->systemName,
|
139 |
-
);
|
140 |
-
if (isset($record['message'])) {
|
141 |
-
$message['message'] = $record['message'];
|
142 |
-
}
|
143 |
-
if (isset($record['channel'])) {
|
144 |
-
$message['type'] = $record['channel'];
|
145 |
-
$message['channel'] = $record['channel'];
|
146 |
-
}
|
147 |
-
if (isset($record['level_name'])) {
|
148 |
-
$message['level'] = $record['level_name'];
|
149 |
-
}
|
150 |
-
if ($this->applicationName) {
|
151 |
-
$message['type'] = $this->applicationName;
|
152 |
-
}
|
153 |
-
if (!empty($record['extra'])) {
|
154 |
-
foreach ($record['extra'] as $key => $val) {
|
155 |
-
$message[$this->extraPrefix . $key] = $val;
|
156 |
-
}
|
157 |
-
}
|
158 |
-
if (!empty($record['context'])) {
|
159 |
-
foreach ($record['context'] as $key => $val) {
|
160 |
-
$message[$this->contextPrefix . $key] = $val;
|
161 |
-
}
|
162 |
-
}
|
163 |
-
|
164 |
-
return $message;
|
165 |
-
}
|
166 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php
DELETED
@@ -1,107 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Monolog\Utils;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Formats a record for use with the MongoDBHandler.
|
18 |
-
*
|
19 |
-
* @author Florian Plattner <me@florianplattner.de>
|
20 |
-
*/
|
21 |
-
class MongoDBFormatter implements FormatterInterface
|
22 |
-
{
|
23 |
-
private $exceptionTraceAsString;
|
24 |
-
private $maxNestingLevel;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @param int $maxNestingLevel 0 means infinite nesting, the $record itself is level 1, $record['context'] is 2
|
28 |
-
* @param bool $exceptionTraceAsString set to false to log exception traces as a sub documents instead of strings
|
29 |
-
*/
|
30 |
-
public function __construct($maxNestingLevel = 3, $exceptionTraceAsString = true)
|
31 |
-
{
|
32 |
-
$this->maxNestingLevel = max($maxNestingLevel, 0);
|
33 |
-
$this->exceptionTraceAsString = (bool) $exceptionTraceAsString;
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* {@inheritDoc}
|
38 |
-
*/
|
39 |
-
public function format(array $record)
|
40 |
-
{
|
41 |
-
return $this->formatArray($record);
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* {@inheritDoc}
|
46 |
-
*/
|
47 |
-
public function formatBatch(array $records)
|
48 |
-
{
|
49 |
-
foreach ($records as $key => $record) {
|
50 |
-
$records[$key] = $this->format($record);
|
51 |
-
}
|
52 |
-
|
53 |
-
return $records;
|
54 |
-
}
|
55 |
-
|
56 |
-
protected function formatArray(array $record, $nestingLevel = 0)
|
57 |
-
{
|
58 |
-
if ($this->maxNestingLevel == 0 || $nestingLevel <= $this->maxNestingLevel) {
|
59 |
-
foreach ($record as $name => $value) {
|
60 |
-
if ($value instanceof \DateTime) {
|
61 |
-
$record[$name] = $this->formatDate($value, $nestingLevel + 1);
|
62 |
-
} elseif ($value instanceof \Exception) {
|
63 |
-
$record[$name] = $this->formatException($value, $nestingLevel + 1);
|
64 |
-
} elseif (is_array($value)) {
|
65 |
-
$record[$name] = $this->formatArray($value, $nestingLevel + 1);
|
66 |
-
} elseif (is_object($value)) {
|
67 |
-
$record[$name] = $this->formatObject($value, $nestingLevel + 1);
|
68 |
-
}
|
69 |
-
}
|
70 |
-
} else {
|
71 |
-
$record = '[...]';
|
72 |
-
}
|
73 |
-
|
74 |
-
return $record;
|
75 |
-
}
|
76 |
-
|
77 |
-
protected function formatObject($value, $nestingLevel)
|
78 |
-
{
|
79 |
-
$objectVars = get_object_vars($value);
|
80 |
-
$objectVars['class'] = Utils::getClass($value);
|
81 |
-
|
82 |
-
return $this->formatArray($objectVars, $nestingLevel);
|
83 |
-
}
|
84 |
-
|
85 |
-
protected function formatException(\Exception $exception, $nestingLevel)
|
86 |
-
{
|
87 |
-
$formattedException = array(
|
88 |
-
'class' => Utils::getClass($exception),
|
89 |
-
'message' => $exception->getMessage(),
|
90 |
-
'code' => $exception->getCode(),
|
91 |
-
'file' => $exception->getFile() . ':' . $exception->getLine(),
|
92 |
-
);
|
93 |
-
|
94 |
-
if ($this->exceptionTraceAsString === true) {
|
95 |
-
$formattedException['trace'] = $exception->getTraceAsString();
|
96 |
-
} else {
|
97 |
-
$formattedException['trace'] = $exception->getTrace();
|
98 |
-
}
|
99 |
-
|
100 |
-
return $this->formatArray($formattedException, $nestingLevel);
|
101 |
-
}
|
102 |
-
|
103 |
-
protected function formatDate(\DateTime $value, $nestingLevel)
|
104 |
-
{
|
105 |
-
return new \MongoDate($value->getTimestamp());
|
106 |
-
}
|
107 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php
DELETED
@@ -1,297 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Exception;
|
15 |
-
use Monolog\Utils;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Normalizes incoming records to remove objects/resources so it's easier to dump to various targets
|
19 |
-
*
|
20 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
21 |
-
*/
|
22 |
-
class NormalizerFormatter implements FormatterInterface
|
23 |
-
{
|
24 |
-
const SIMPLE_DATE = "Y-m-d H:i:s";
|
25 |
-
|
26 |
-
protected $dateFormat;
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @param string $dateFormat The format of the timestamp: one supported by DateTime::format
|
30 |
-
*/
|
31 |
-
public function __construct($dateFormat = null)
|
32 |
-
{
|
33 |
-
$this->dateFormat = $dateFormat ?: static::SIMPLE_DATE;
|
34 |
-
if (!function_exists('json_encode')) {
|
35 |
-
throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s NormalizerFormatter');
|
36 |
-
}
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* {@inheritdoc}
|
41 |
-
*/
|
42 |
-
public function format(array $record)
|
43 |
-
{
|
44 |
-
return $this->normalize($record);
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* {@inheritdoc}
|
49 |
-
*/
|
50 |
-
public function formatBatch(array $records)
|
51 |
-
{
|
52 |
-
foreach ($records as $key => $record) {
|
53 |
-
$records[$key] = $this->format($record);
|
54 |
-
}
|
55 |
-
|
56 |
-
return $records;
|
57 |
-
}
|
58 |
-
|
59 |
-
protected function normalize($data, $depth = 0)
|
60 |
-
{
|
61 |
-
if ($depth > 9) {
|
62 |
-
return 'Over 9 levels deep, aborting normalization';
|
63 |
-
}
|
64 |
-
|
65 |
-
if (null === $data || is_scalar($data)) {
|
66 |
-
if (is_float($data)) {
|
67 |
-
if (is_infinite($data)) {
|
68 |
-
return ($data > 0 ? '' : '-') . 'INF';
|
69 |
-
}
|
70 |
-
if (is_nan($data)) {
|
71 |
-
return 'NaN';
|
72 |
-
}
|
73 |
-
}
|
74 |
-
|
75 |
-
return $data;
|
76 |
-
}
|
77 |
-
|
78 |
-
if (is_array($data)) {
|
79 |
-
$normalized = array();
|
80 |
-
|
81 |
-
$count = 1;
|
82 |
-
foreach ($data as $key => $value) {
|
83 |
-
if ($count++ > 1000) {
|
84 |
-
$normalized['...'] = 'Over 1000 items ('.count($data).' total), aborting normalization';
|
85 |
-
break;
|
86 |
-
}
|
87 |
-
|
88 |
-
$normalized[$key] = $this->normalize($value, $depth+1);
|
89 |
-
}
|
90 |
-
|
91 |
-
return $normalized;
|
92 |
-
}
|
93 |
-
|
94 |
-
if ($data instanceof \DateTime) {
|
95 |
-
return $data->format($this->dateFormat);
|
96 |
-
}
|
97 |
-
|
98 |
-
if (is_object($data)) {
|
99 |
-
// TODO 2.0 only check for Throwable
|
100 |
-
if ($data instanceof Exception || (PHP_VERSION_ID > 70000 && $data instanceof \Throwable)) {
|
101 |
-
return $this->normalizeException($data);
|
102 |
-
}
|
103 |
-
|
104 |
-
// non-serializable objects that implement __toString stringified
|
105 |
-
if (method_exists($data, '__toString') && !$data instanceof \JsonSerializable) {
|
106 |
-
$value = $data->__toString();
|
107 |
-
} else {
|
108 |
-
// the rest is json-serialized in some way
|
109 |
-
$value = $this->toJson($data, true);
|
110 |
-
}
|
111 |
-
|
112 |
-
return sprintf("[object] (%s: %s)", Utils::getClass($data), $value);
|
113 |
-
}
|
114 |
-
|
115 |
-
if (is_resource($data)) {
|
116 |
-
return sprintf('[resource] (%s)', get_resource_type($data));
|
117 |
-
}
|
118 |
-
|
119 |
-
return '[unknown('.gettype($data).')]';
|
120 |
-
}
|
121 |
-
|
122 |
-
protected function normalizeException($e)
|
123 |
-
{
|
124 |
-
// TODO 2.0 only check for Throwable
|
125 |
-
if (!$e instanceof Exception && !$e instanceof \Throwable) {
|
126 |
-
throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.Utils::getClass($e));
|
127 |
-
}
|
128 |
-
|
129 |
-
$data = array(
|
130 |
-
'class' => Utils::getClass($e),
|
131 |
-
'message' => $e->getMessage(),
|
132 |
-
'code' => $e->getCode(),
|
133 |
-
'file' => $e->getFile().':'.$e->getLine(),
|
134 |
-
);
|
135 |
-
|
136 |
-
if ($e instanceof \SoapFault) {
|
137 |
-
if (isset($e->faultcode)) {
|
138 |
-
$data['faultcode'] = $e->faultcode;
|
139 |
-
}
|
140 |
-
|
141 |
-
if (isset($e->faultactor)) {
|
142 |
-
$data['faultactor'] = $e->faultactor;
|
143 |
-
}
|
144 |
-
|
145 |
-
if (isset($e->detail)) {
|
146 |
-
$data['detail'] = $e->detail;
|
147 |
-
}
|
148 |
-
}
|
149 |
-
|
150 |
-
$trace = $e->getTrace();
|
151 |
-
foreach ($trace as $frame) {
|
152 |
-
if (isset($frame['file'])) {
|
153 |
-
$data['trace'][] = $frame['file'].':'.$frame['line'];
|
154 |
-
}
|
155 |
-
}
|
156 |
-
|
157 |
-
if ($previous = $e->getPrevious()) {
|
158 |
-
$data['previous'] = $this->normalizeException($previous);
|
159 |
-
}
|
160 |
-
|
161 |
-
return $data;
|
162 |
-
}
|
163 |
-
|
164 |
-
/**
|
165 |
-
* Return the JSON representation of a value
|
166 |
-
*
|
167 |
-
* @param mixed $data
|
168 |
-
* @param bool $ignoreErrors
|
169 |
-
* @throws \RuntimeException if encoding fails and errors are not ignored
|
170 |
-
* @return string
|
171 |
-
*/
|
172 |
-
protected function toJson($data, $ignoreErrors = false)
|
173 |
-
{
|
174 |
-
// suppress json_encode errors since it's twitchy with some inputs
|
175 |
-
if ($ignoreErrors) {
|
176 |
-
return @$this->jsonEncode($data);
|
177 |
-
}
|
178 |
-
|
179 |
-
$json = $this->jsonEncode($data);
|
180 |
-
|
181 |
-
if ($json === false) {
|
182 |
-
$json = $this->handleJsonError(json_last_error(), $data);
|
183 |
-
}
|
184 |
-
|
185 |
-
return $json;
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* @param mixed $data
|
190 |
-
* @return string JSON encoded data or null on failure
|
191 |
-
*/
|
192 |
-
private function jsonEncode($data)
|
193 |
-
{
|
194 |
-
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
|
195 |
-
return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
196 |
-
}
|
197 |
-
|
198 |
-
return json_encode($data);
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* Handle a json_encode failure.
|
203 |
-
*
|
204 |
-
* If the failure is due to invalid string encoding, try to clean the
|
205 |
-
* input and encode again. If the second encoding attempt fails, the
|
206 |
-
* inital error is not encoding related or the input can't be cleaned then
|
207 |
-
* raise a descriptive exception.
|
208 |
-
*
|
209 |
-
* @param int $code return code of json_last_error function
|
210 |
-
* @param mixed $data data that was meant to be encoded
|
211 |
-
* @throws \RuntimeException if failure can't be corrected
|
212 |
-
* @return string JSON encoded data after error correction
|
213 |
-
*/
|
214 |
-
private function handleJsonError($code, $data)
|
215 |
-
{
|
216 |
-
if ($code !== JSON_ERROR_UTF8) {
|
217 |
-
$this->throwEncodeError($code, $data);
|
218 |
-
}
|
219 |
-
|
220 |
-
if (is_string($data)) {
|
221 |
-
$this->detectAndCleanUtf8($data);
|
222 |
-
} elseif (is_array($data)) {
|
223 |
-
array_walk_recursive($data, array($this, 'detectAndCleanUtf8'));
|
224 |
-
} else {
|
225 |
-
$this->throwEncodeError($code, $data);
|
226 |
-
}
|
227 |
-
|
228 |
-
$json = $this->jsonEncode($data);
|
229 |
-
|
230 |
-
if ($json === false) {
|
231 |
-
$this->throwEncodeError(json_last_error(), $data);
|
232 |
-
}
|
233 |
-
|
234 |
-
return $json;
|
235 |
-
}
|
236 |
-
|
237 |
-
/**
|
238 |
-
* Throws an exception according to a given code with a customized message
|
239 |
-
*
|
240 |
-
* @param int $code return code of json_last_error function
|
241 |
-
* @param mixed $data data that was meant to be encoded
|
242 |
-
* @throws \RuntimeException
|
243 |
-
*/
|
244 |
-
private function throwEncodeError($code, $data)
|
245 |
-
{
|
246 |
-
switch ($code) {
|
247 |
-
case JSON_ERROR_DEPTH:
|
248 |
-
$msg = 'Maximum stack depth exceeded';
|
249 |
-
break;
|
250 |
-
case JSON_ERROR_STATE_MISMATCH:
|
251 |
-
$msg = 'Underflow or the modes mismatch';
|
252 |
-
break;
|
253 |
-
case JSON_ERROR_CTRL_CHAR:
|
254 |
-
$msg = 'Unexpected control character found';
|
255 |
-
break;
|
256 |
-
case JSON_ERROR_UTF8:
|
257 |
-
$msg = 'Malformed UTF-8 characters, possibly incorrectly encoded';
|
258 |
-
break;
|
259 |
-
default:
|
260 |
-
$msg = 'Unknown error';
|
261 |
-
}
|
262 |
-
|
263 |
-
throw new \RuntimeException('JSON encoding failed: '.$msg.'. Encoding: '.var_export($data, true));
|
264 |
-
}
|
265 |
-
|
266 |
-
/**
|
267 |
-
* Detect invalid UTF-8 string characters and convert to valid UTF-8.
|
268 |
-
*
|
269 |
-
* Valid UTF-8 input will be left unmodified, but strings containing
|
270 |
-
* invalid UTF-8 codepoints will be reencoded as UTF-8 with an assumed
|
271 |
-
* original encoding of ISO-8859-15. This conversion may result in
|
272 |
-
* incorrect output if the actual encoding was not ISO-8859-15, but it
|
273 |
-
* will be clean UTF-8 output and will not rely on expensive and fragile
|
274 |
-
* detection algorithms.
|
275 |
-
*
|
276 |
-
* Function converts the input in place in the passed variable so that it
|
277 |
-
* can be used as a callback for array_walk_recursive.
|
278 |
-
*
|
279 |
-
* @param mixed &$data Input to check and convert if needed
|
280 |
-
* @private
|
281 |
-
*/
|
282 |
-
public function detectAndCleanUtf8(&$data)
|
283 |
-
{
|
284 |
-
if (is_string($data) && !preg_match('//u', $data)) {
|
285 |
-
$data = preg_replace_callback(
|
286 |
-
'/[\x80-\xFF]+/',
|
287 |
-
function ($m) { return utf8_encode($m[0]); },
|
288 |
-
$data
|
289 |
-
);
|
290 |
-
$data = str_replace(
|
291 |
-
array('¤', '¦', '¨', '´', '¸', '¼', '½', '¾'),
|
292 |
-
array('€', 'Š', 'š', 'Ž', 'ž', 'Œ', 'œ', 'Ÿ'),
|
293 |
-
$data
|
294 |
-
);
|
295 |
-
}
|
296 |
-
}
|
297 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php
DELETED
@@ -1,48 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Formats data into an associative array of scalar values.
|
16 |
-
* Objects and arrays will be JSON encoded.
|
17 |
-
*
|
18 |
-
* @author Andrew Lawson <adlawson@gmail.com>
|
19 |
-
*/
|
20 |
-
class ScalarFormatter extends NormalizerFormatter
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* {@inheritdoc}
|
24 |
-
*/
|
25 |
-
public function format(array $record)
|
26 |
-
{
|
27 |
-
foreach ($record as $key => $value) {
|
28 |
-
$record[$key] = $this->normalizeValue($value);
|
29 |
-
}
|
30 |
-
|
31 |
-
return $record;
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* @param mixed $value
|
36 |
-
* @return mixed
|
37 |
-
*/
|
38 |
-
protected function normalizeValue($value)
|
39 |
-
{
|
40 |
-
$normalized = $this->normalize($value);
|
41 |
-
|
42 |
-
if (is_array($normalized) || is_object($normalized)) {
|
43 |
-
return $this->toJson($normalized, true);
|
44 |
-
}
|
45 |
-
|
46 |
-
return $normalized;
|
47 |
-
}
|
48 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php
DELETED
@@ -1,113 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Formatter;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Serializes a log message according to Wildfire's header requirements
|
18 |
-
*
|
19 |
-
* @author Eric Clemmons (@ericclemmons) <eric@uxdriven.com>
|
20 |
-
* @author Christophe Coevoet <stof@notk.org>
|
21 |
-
* @author Kirill chEbba Chebunin <iam@chebba.org>
|
22 |
-
*/
|
23 |
-
class WildfireFormatter extends NormalizerFormatter
|
24 |
-
{
|
25 |
-
const TABLE = 'table';
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Translates Monolog log levels to Wildfire levels.
|
29 |
-
*/
|
30 |
-
private $logLevels = array(
|
31 |
-
Logger::DEBUG => 'LOG',
|
32 |
-
Logger::INFO => 'INFO',
|
33 |
-
Logger::NOTICE => 'INFO',
|
34 |
-
Logger::WARNING => 'WARN',
|
35 |
-
Logger::ERROR => 'ERROR',
|
36 |
-
Logger::CRITICAL => 'ERROR',
|
37 |
-
Logger::ALERT => 'ERROR',
|
38 |
-
Logger::EMERGENCY => 'ERROR',
|
39 |
-
);
|
40 |
-
|
41 |
-
/**
|
42 |
-
* {@inheritdoc}
|
43 |
-
*/
|
44 |
-
public function format(array $record)
|
45 |
-
{
|
46 |
-
// Retrieve the line and file if set and remove them from the formatted extra
|
47 |
-
$file = $line = '';
|
48 |
-
if (isset($record['extra']['file'])) {
|
49 |
-
$file = $record['extra']['file'];
|
50 |
-
unset($record['extra']['file']);
|
51 |
-
}
|
52 |
-
if (isset($record['extra']['line'])) {
|
53 |
-
$line = $record['extra']['line'];
|
54 |
-
unset($record['extra']['line']);
|
55 |
-
}
|
56 |
-
|
57 |
-
$record = $this->normalize($record);
|
58 |
-
$message = array('message' => $record['message']);
|
59 |
-
$handleError = false;
|
60 |
-
if ($record['context']) {
|
61 |
-
$message['context'] = $record['context'];
|
62 |
-
$handleError = true;
|
63 |
-
}
|
64 |
-
if ($record['extra']) {
|
65 |
-
$message['extra'] = $record['extra'];
|
66 |
-
$handleError = true;
|
67 |
-
}
|
68 |
-
if (count($message) === 1) {
|
69 |
-
$message = reset($message);
|
70 |
-
}
|
71 |
-
|
72 |
-
if (isset($record['context'][self::TABLE])) {
|
73 |
-
$type = 'TABLE';
|
74 |
-
$label = $record['channel'] .': '. $record['message'];
|
75 |
-
$message = $record['context'][self::TABLE];
|
76 |
-
} else {
|
77 |
-
$type = $this->logLevels[$record['level']];
|
78 |
-
$label = $record['channel'];
|
79 |
-
}
|
80 |
-
|
81 |
-
// Create JSON object describing the appearance of the message in the console
|
82 |
-
$json = $this->toJson(array(
|
83 |
-
array(
|
84 |
-
'Type' => $type,
|
85 |
-
'File' => $file,
|
86 |
-
'Line' => $line,
|
87 |
-
'Label' => $label,
|
88 |
-
),
|
89 |
-
$message,
|
90 |
-
), $handleError);
|
91 |
-
|
92 |
-
// The message itself is a serialization of the above JSON object + it's length
|
93 |
-
return sprintf(
|
94 |
-
'%s|%s|',
|
95 |
-
strlen($json),
|
96 |
-
$json
|
97 |
-
);
|
98 |
-
}
|
99 |
-
|
100 |
-
public function formatBatch(array $records)
|
101 |
-
{
|
102 |
-
throw new \BadMethodCallException('Batch formatting does not make sense for the WildfireFormatter');
|
103 |
-
}
|
104 |
-
|
105 |
-
protected function normalize($data, $depth = 0)
|
106 |
-
{
|
107 |
-
if (is_object($data) && !$data instanceof \DateTime) {
|
108 |
-
return $data;
|
109 |
-
}
|
110 |
-
|
111 |
-
return parent::normalize($data, $depth);
|
112 |
-
}
|
113 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php
DELETED
@@ -1,196 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\FormatterInterface;
|
15 |
-
use Monolog\Formatter\LineFormatter;
|
16 |
-
use Monolog\Logger;
|
17 |
-
use Monolog\ResettableInterface;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Base Handler class providing the Handler structure
|
21 |
-
*
|
22 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
23 |
-
*/
|
24 |
-
abstract class AbstractHandler implements HandlerInterface, ResettableInterface
|
25 |
-
{
|
26 |
-
protected $level = Logger::DEBUG;
|
27 |
-
protected $bubble = true;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @var FormatterInterface
|
31 |
-
*/
|
32 |
-
protected $formatter;
|
33 |
-
protected $processors = array();
|
34 |
-
|
35 |
-
/**
|
36 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
37 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
38 |
-
*/
|
39 |
-
public function __construct($level = Logger::DEBUG, $bubble = true)
|
40 |
-
{
|
41 |
-
$this->setLevel($level);
|
42 |
-
$this->bubble = $bubble;
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* {@inheritdoc}
|
47 |
-
*/
|
48 |
-
public function isHandling(array $record)
|
49 |
-
{
|
50 |
-
return $record['level'] >= $this->level;
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* {@inheritdoc}
|
55 |
-
*/
|
56 |
-
public function handleBatch(array $records)
|
57 |
-
{
|
58 |
-
foreach ($records as $record) {
|
59 |
-
$this->handle($record);
|
60 |
-
}
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Closes the handler.
|
65 |
-
*
|
66 |
-
* This will be called automatically when the object is destroyed
|
67 |
-
*/
|
68 |
-
public function close()
|
69 |
-
{
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* {@inheritdoc}
|
74 |
-
*/
|
75 |
-
public function pushProcessor($callback)
|
76 |
-
{
|
77 |
-
if (!is_callable($callback)) {
|
78 |
-
throw new \InvalidArgumentException('Processors must be valid callables (callback or object with an __invoke method), '.var_export($callback, true).' given');
|
79 |
-
}
|
80 |
-
array_unshift($this->processors, $callback);
|
81 |
-
|
82 |
-
return $this;
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* {@inheritdoc}
|
87 |
-
*/
|
88 |
-
public function popProcessor()
|
89 |
-
{
|
90 |
-
if (!$this->processors) {
|
91 |
-
throw new \LogicException('You tried to pop from an empty processor stack.');
|
92 |
-
}
|
93 |
-
|
94 |
-
return array_shift($this->processors);
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* {@inheritdoc}
|
99 |
-
*/
|
100 |
-
public function setFormatter(FormatterInterface $formatter)
|
101 |
-
{
|
102 |
-
$this->formatter = $formatter;
|
103 |
-
|
104 |
-
return $this;
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* {@inheritdoc}
|
109 |
-
*/
|
110 |
-
public function getFormatter()
|
111 |
-
{
|
112 |
-
if (!$this->formatter) {
|
113 |
-
$this->formatter = $this->getDefaultFormatter();
|
114 |
-
}
|
115 |
-
|
116 |
-
return $this->formatter;
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Sets minimum logging level at which this handler will be triggered.
|
121 |
-
*
|
122 |
-
* @param int|string $level Level or level name
|
123 |
-
* @return self
|
124 |
-
*/
|
125 |
-
public function setLevel($level)
|
126 |
-
{
|
127 |
-
$this->level = Logger::toMonologLevel($level);
|
128 |
-
|
129 |
-
return $this;
|
130 |
-
}
|
131 |
-
|
132 |
-
/**
|
133 |
-
* Gets minimum logging level at which this handler will be triggered.
|
134 |
-
*
|
135 |
-
* @return int
|
136 |
-
*/
|
137 |
-
public function getLevel()
|
138 |
-
{
|
139 |
-
return $this->level;
|
140 |
-
}
|
141 |
-
|
142 |
-
/**
|
143 |
-
* Sets the bubbling behavior.
|
144 |
-
*
|
145 |
-
* @param bool $bubble true means that this handler allows bubbling.
|
146 |
-
* false means that bubbling is not permitted.
|
147 |
-
* @return self
|
148 |
-
*/
|
149 |
-
public function setBubble($bubble)
|
150 |
-
{
|
151 |
-
$this->bubble = $bubble;
|
152 |
-
|
153 |
-
return $this;
|
154 |
-
}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Gets the bubbling behavior.
|
158 |
-
*
|
159 |
-
* @return bool true means that this handler allows bubbling.
|
160 |
-
* false means that bubbling is not permitted.
|
161 |
-
*/
|
162 |
-
public function getBubble()
|
163 |
-
{
|
164 |
-
return $this->bubble;
|
165 |
-
}
|
166 |
-
|
167 |
-
public function __destruct()
|
168 |
-
{
|
169 |
-
try {
|
170 |
-
$this->close();
|
171 |
-
} catch (\Exception $e) {
|
172 |
-
// do nothing
|
173 |
-
} catch (\Throwable $e) {
|
174 |
-
// do nothing
|
175 |
-
}
|
176 |
-
}
|
177 |
-
|
178 |
-
public function reset()
|
179 |
-
{
|
180 |
-
foreach ($this->processors as $processor) {
|
181 |
-
if ($processor instanceof ResettableInterface) {
|
182 |
-
$processor->reset();
|
183 |
-
}
|
184 |
-
}
|
185 |
-
}
|
186 |
-
|
187 |
-
/**
|
188 |
-
* Gets the default formatter.
|
189 |
-
*
|
190 |
-
* @return FormatterInterface
|
191 |
-
*/
|
192 |
-
protected function getDefaultFormatter()
|
193 |
-
{
|
194 |
-
return new LineFormatter();
|
195 |
-
}
|
196 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php
DELETED
@@ -1,68 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\ResettableInterface;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Base Handler class providing the Handler structure
|
18 |
-
*
|
19 |
-
* Classes extending it should (in most cases) only implement write($record)
|
20 |
-
*
|
21 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
22 |
-
* @author Christophe Coevoet <stof@notk.org>
|
23 |
-
*/
|
24 |
-
abstract class AbstractProcessingHandler extends AbstractHandler
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* {@inheritdoc}
|
28 |
-
*/
|
29 |
-
public function handle(array $record)
|
30 |
-
{
|
31 |
-
if (!$this->isHandling($record)) {
|
32 |
-
return false;
|
33 |
-
}
|
34 |
-
|
35 |
-
$record = $this->processRecord($record);
|
36 |
-
|
37 |
-
$record['formatted'] = $this->getFormatter()->format($record);
|
38 |
-
|
39 |
-
$this->write($record);
|
40 |
-
|
41 |
-
return false === $this->bubble;
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Writes the record down to the log of the implementing handler
|
46 |
-
*
|
47 |
-
* @param array $record
|
48 |
-
* @return void
|
49 |
-
*/
|
50 |
-
abstract protected function write(array $record);
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Processes a record.
|
54 |
-
*
|
55 |
-
* @param array $record
|
56 |
-
* @return array
|
57 |
-
*/
|
58 |
-
protected function processRecord(array $record)
|
59 |
-
{
|
60 |
-
if ($this->processors) {
|
61 |
-
foreach ($this->processors as $processor) {
|
62 |
-
$record = call_user_func($processor, $record);
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
return $record;
|
67 |
-
}
|
68 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php
DELETED
@@ -1,101 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\Formatter\LineFormatter;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Common syslog functionality
|
19 |
-
*/
|
20 |
-
abstract class AbstractSyslogHandler extends AbstractProcessingHandler
|
21 |
-
{
|
22 |
-
protected $facility;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Translates Monolog log levels to syslog log priorities.
|
26 |
-
*/
|
27 |
-
protected $logLevels = array(
|
28 |
-
Logger::DEBUG => LOG_DEBUG,
|
29 |
-
Logger::INFO => LOG_INFO,
|
30 |
-
Logger::NOTICE => LOG_NOTICE,
|
31 |
-
Logger::WARNING => LOG_WARNING,
|
32 |
-
Logger::ERROR => LOG_ERR,
|
33 |
-
Logger::CRITICAL => LOG_CRIT,
|
34 |
-
Logger::ALERT => LOG_ALERT,
|
35 |
-
Logger::EMERGENCY => LOG_EMERG,
|
36 |
-
);
|
37 |
-
|
38 |
-
/**
|
39 |
-
* List of valid log facility names.
|
40 |
-
*/
|
41 |
-
protected $facilities = array(
|
42 |
-
'auth' => LOG_AUTH,
|
43 |
-
'authpriv' => LOG_AUTHPRIV,
|
44 |
-
'cron' => LOG_CRON,
|
45 |
-
'daemon' => LOG_DAEMON,
|
46 |
-
'kern' => LOG_KERN,
|
47 |
-
'lpr' => LOG_LPR,
|
48 |
-
'mail' => LOG_MAIL,
|
49 |
-
'news' => LOG_NEWS,
|
50 |
-
'syslog' => LOG_SYSLOG,
|
51 |
-
'user' => LOG_USER,
|
52 |
-
'uucp' => LOG_UUCP,
|
53 |
-
);
|
54 |
-
|
55 |
-
/**
|
56 |
-
* @param mixed $facility
|
57 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
58 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
59 |
-
*/
|
60 |
-
public function __construct($facility = LOG_USER, $level = Logger::DEBUG, $bubble = true)
|
61 |
-
{
|
62 |
-
parent::__construct($level, $bubble);
|
63 |
-
|
64 |
-
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
|
65 |
-
$this->facilities['local0'] = LOG_LOCAL0;
|
66 |
-
$this->facilities['local1'] = LOG_LOCAL1;
|
67 |
-
$this->facilities['local2'] = LOG_LOCAL2;
|
68 |
-
$this->facilities['local3'] = LOG_LOCAL3;
|
69 |
-
$this->facilities['local4'] = LOG_LOCAL4;
|
70 |
-
$this->facilities['local5'] = LOG_LOCAL5;
|
71 |
-
$this->facilities['local6'] = LOG_LOCAL6;
|
72 |
-
$this->facilities['local7'] = LOG_LOCAL7;
|
73 |
-
} else {
|
74 |
-
$this->facilities['local0'] = 128; // LOG_LOCAL0
|
75 |
-
$this->facilities['local1'] = 136; // LOG_LOCAL1
|
76 |
-
$this->facilities['local2'] = 144; // LOG_LOCAL2
|
77 |
-
$this->facilities['local3'] = 152; // LOG_LOCAL3
|
78 |
-
$this->facilities['local4'] = 160; // LOG_LOCAL4
|
79 |
-
$this->facilities['local5'] = 168; // LOG_LOCAL5
|
80 |
-
$this->facilities['local6'] = 176; // LOG_LOCAL6
|
81 |
-
$this->facilities['local7'] = 184; // LOG_LOCAL7
|
82 |
-
}
|
83 |
-
|
84 |
-
// convert textual description of facility to syslog constant
|
85 |
-
if (array_key_exists(strtolower($facility), $this->facilities)) {
|
86 |
-
$facility = $this->facilities[strtolower($facility)];
|
87 |
-
} elseif (!in_array($facility, array_values($this->facilities), true)) {
|
88 |
-
throw new \UnexpectedValueException('Unknown facility value "'.$facility.'" given');
|
89 |
-
}
|
90 |
-
|
91 |
-
$this->facility = $facility;
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* {@inheritdoc}
|
96 |
-
*/
|
97 |
-
protected function getDefaultFormatter()
|
98 |
-
{
|
99 |
-
return new LineFormatter('%channel%.%level_name%: %message% %context% %extra%');
|
100 |
-
}
|
101 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php
DELETED
@@ -1,148 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\Formatter\JsonFormatter;
|
16 |
-
use PhpAmqpLib\Message\AMQPMessage;
|
17 |
-
use PhpAmqpLib\Channel\AMQPChannel;
|
18 |
-
use AMQPExchange;
|
19 |
-
|
20 |
-
class AmqpHandler extends AbstractProcessingHandler
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* @var AMQPExchange|AMQPChannel $exchange
|
24 |
-
*/
|
25 |
-
protected $exchange;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* @var string
|
29 |
-
*/
|
30 |
-
protected $exchangeName;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @param AMQPExchange|AMQPChannel $exchange AMQPExchange (php AMQP ext) or PHP AMQP lib channel, ready for use
|
34 |
-
* @param string $exchangeName
|
35 |
-
* @param int $level
|
36 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
37 |
-
*/
|
38 |
-
public function __construct($exchange, $exchangeName = 'log', $level = Logger::DEBUG, $bubble = true)
|
39 |
-
{
|
40 |
-
if ($exchange instanceof AMQPExchange) {
|
41 |
-
$exchange->setName($exchangeName);
|
42 |
-
} elseif ($exchange instanceof AMQPChannel) {
|
43 |
-
$this->exchangeName = $exchangeName;
|
44 |
-
} else {
|
45 |
-
throw new \InvalidArgumentException('PhpAmqpLib\Channel\AMQPChannel or AMQPExchange instance required');
|
46 |
-
}
|
47 |
-
$this->exchange = $exchange;
|
48 |
-
|
49 |
-
parent::__construct($level, $bubble);
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* {@inheritDoc}
|
54 |
-
*/
|
55 |
-
protected function write(array $record)
|
56 |
-
{
|
57 |
-
$data = $record["formatted"];
|
58 |
-
$routingKey = $this->getRoutingKey($record);
|
59 |
-
|
60 |
-
if ($this->exchange instanceof AMQPExchange) {
|
61 |
-
$this->exchange->publish(
|
62 |
-
$data,
|
63 |
-
$routingKey,
|
64 |
-
0,
|
65 |
-
array(
|
66 |
-
'delivery_mode' => 2,
|
67 |
-
'content_type' => 'application/json',
|
68 |
-
)
|
69 |
-
);
|
70 |
-
} else {
|
71 |
-
$this->exchange->basic_publish(
|
72 |
-
$this->createAmqpMessage($data),
|
73 |
-
$this->exchangeName,
|
74 |
-
$routingKey
|
75 |
-
);
|
76 |
-
}
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* {@inheritDoc}
|
81 |
-
*/
|
82 |
-
public function handleBatch(array $records)
|
83 |
-
{
|
84 |
-
if ($this->exchange instanceof AMQPExchange) {
|
85 |
-
parent::handleBatch($records);
|
86 |
-
|
87 |
-
return;
|
88 |
-
}
|
89 |
-
|
90 |
-
foreach ($records as $record) {
|
91 |
-
if (!$this->isHandling($record)) {
|
92 |
-
continue;
|
93 |
-
}
|
94 |
-
|
95 |
-
$record = $this->processRecord($record);
|
96 |
-
$data = $this->getFormatter()->format($record);
|
97 |
-
|
98 |
-
$this->exchange->batch_basic_publish(
|
99 |
-
$this->createAmqpMessage($data),
|
100 |
-
$this->exchangeName,
|
101 |
-
$this->getRoutingKey($record)
|
102 |
-
);
|
103 |
-
}
|
104 |
-
|
105 |
-
$this->exchange->publish_batch();
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Gets the routing key for the AMQP exchange
|
110 |
-
*
|
111 |
-
* @param array $record
|
112 |
-
* @return string
|
113 |
-
*/
|
114 |
-
protected function getRoutingKey(array $record)
|
115 |
-
{
|
116 |
-
$routingKey = sprintf(
|
117 |
-
'%s.%s',
|
118 |
-
// TODO 2.0 remove substr call
|
119 |
-
substr($record['level_name'], 0, 4),
|
120 |
-
$record['channel']
|
121 |
-
);
|
122 |
-
|
123 |
-
return strtolower($routingKey);
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* @param string $data
|
128 |
-
* @return AMQPMessage
|
129 |
-
*/
|
130 |
-
private function createAmqpMessage($data)
|
131 |
-
{
|
132 |
-
return new AMQPMessage(
|
133 |
-
(string) $data,
|
134 |
-
array(
|
135 |
-
'delivery_mode' => 2,
|
136 |
-
'content_type' => 'application/json',
|
137 |
-
)
|
138 |
-
);
|
139 |
-
}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* {@inheritDoc}
|
143 |
-
*/
|
144 |
-
protected function getDefaultFormatter()
|
145 |
-
{
|
146 |
-
return new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false);
|
147 |
-
}
|
148 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php
DELETED
@@ -1,240 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\LineFormatter;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Handler sending logs to browser's javascript console with no browser extension required
|
18 |
-
*
|
19 |
-
* @author Olivier Poitrey <rs@dailymotion.com>
|
20 |
-
*/
|
21 |
-
class BrowserConsoleHandler extends AbstractProcessingHandler
|
22 |
-
{
|
23 |
-
protected static $initialized = false;
|
24 |
-
protected static $records = array();
|
25 |
-
|
26 |
-
/**
|
27 |
-
* {@inheritDoc}
|
28 |
-
*
|
29 |
-
* Formatted output may contain some formatting markers to be transferred to `console.log` using the %c format.
|
30 |
-
*
|
31 |
-
* Example of formatted string:
|
32 |
-
*
|
33 |
-
* You can do [[blue text]]{color: blue} or [[green background]]{background-color: green; color: white}
|
34 |
-
*/
|
35 |
-
protected function getDefaultFormatter()
|
36 |
-
{
|
37 |
-
return new LineFormatter('[[%channel%]]{macro: autolabel} [[%level_name%]]{font-weight: bold} %message%');
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* {@inheritDoc}
|
42 |
-
*/
|
43 |
-
protected function write(array $record)
|
44 |
-
{
|
45 |
-
// Accumulate records
|
46 |
-
static::$records[] = $record;
|
47 |
-
|
48 |
-
// Register shutdown handler if not already done
|
49 |
-
if (!static::$initialized) {
|
50 |
-
static::$initialized = true;
|
51 |
-
$this->registerShutdownFunction();
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Convert records to javascript console commands and send it to the browser.
|
57 |
-
* This method is automatically called on PHP shutdown if output is HTML or Javascript.
|
58 |
-
*/
|
59 |
-
public static function send()
|
60 |
-
{
|
61 |
-
$format = static::getResponseFormat();
|
62 |
-
if ($format === 'unknown') {
|
63 |
-
return;
|
64 |
-
}
|
65 |
-
|
66 |
-
if (count(static::$records)) {
|
67 |
-
if ($format === 'html') {
|
68 |
-
static::writeOutput('<script>' . static::generateScript() . '</script>');
|
69 |
-
} elseif ($format === 'js') {
|
70 |
-
static::writeOutput(static::generateScript());
|
71 |
-
}
|
72 |
-
static::resetStatic();
|
73 |
-
}
|
74 |
-
}
|
75 |
-
|
76 |
-
public function close()
|
77 |
-
{
|
78 |
-
self::resetStatic();
|
79 |
-
}
|
80 |
-
|
81 |
-
public function reset()
|
82 |
-
{
|
83 |
-
self::resetStatic();
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Forget all logged records
|
88 |
-
*/
|
89 |
-
public static function resetStatic()
|
90 |
-
{
|
91 |
-
static::$records = array();
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Wrapper for register_shutdown_function to allow overriding
|
96 |
-
*/
|
97 |
-
protected function registerShutdownFunction()
|
98 |
-
{
|
99 |
-
if (PHP_SAPI !== 'cli') {
|
100 |
-
register_shutdown_function(array('Monolog\Handler\BrowserConsoleHandler', 'send'));
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Wrapper for echo to allow overriding
|
106 |
-
*
|
107 |
-
* @param string $str
|
108 |
-
*/
|
109 |
-
protected static function writeOutput($str)
|
110 |
-
{
|
111 |
-
echo $str;
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* Checks the format of the response
|
116 |
-
*
|
117 |
-
* If Content-Type is set to application/javascript or text/javascript -> js
|
118 |
-
* If Content-Type is set to text/html, or is unset -> html
|
119 |
-
* If Content-Type is anything else -> unknown
|
120 |
-
*
|
121 |
-
* @return string One of 'js', 'html' or 'unknown'
|
122 |
-
*/
|
123 |
-
protected static function getResponseFormat()
|
124 |
-
{
|
125 |
-
// Check content type
|
126 |
-
foreach (headers_list() as $header) {
|
127 |
-
if (stripos($header, 'content-type:') === 0) {
|
128 |
-
// This handler only works with HTML and javascript outputs
|
129 |
-
// text/javascript is obsolete in favour of application/javascript, but still used
|
130 |
-
if (stripos($header, 'application/javascript') !== false || stripos($header, 'text/javascript') !== false) {
|
131 |
-
return 'js';
|
132 |
-
}
|
133 |
-
if (stripos($header, 'text/html') === false) {
|
134 |
-
return 'unknown';
|
135 |
-
}
|
136 |
-
break;
|
137 |
-
}
|
138 |
-
}
|
139 |
-
|
140 |
-
return 'html';
|
141 |
-
}
|
142 |
-
|
143 |
-
private static function generateScript()
|
144 |
-
{
|
145 |
-
$script = array();
|
146 |
-
foreach (static::$records as $record) {
|
147 |
-
$context = static::dump('Context', $record['context']);
|
148 |
-
$extra = static::dump('Extra', $record['extra']);
|
149 |
-
|
150 |
-
if (empty($context) && empty($extra)) {
|
151 |
-
$script[] = static::call_array('log', static::handleStyles($record['formatted']));
|
152 |
-
} else {
|
153 |
-
$script = array_merge($script,
|
154 |
-
array(static::call_array('groupCollapsed', static::handleStyles($record['formatted']))),
|
155 |
-
$context,
|
156 |
-
$extra,
|
157 |
-
array(static::call('groupEnd'))
|
158 |
-
);
|
159 |
-
}
|
160 |
-
}
|
161 |
-
|
162 |
-
return "(function (c) {if (c && c.groupCollapsed) {\n" . implode("\n", $script) . "\n}})(console);";
|
163 |
-
}
|
164 |
-
|
165 |
-
private static function handleStyles($formatted)
|
166 |
-
{
|
167 |
-
$args = array(static::quote('font-weight: normal'));
|
168 |
-
$format = '%c' . $formatted;
|
169 |
-
preg_match_all('/\[\[(.*?)\]\]\{([^}]*)\}/s', $format, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
|
170 |
-
|
171 |
-
foreach (array_reverse($matches) as $match) {
|
172 |
-
$args[] = static::quote(static::handleCustomStyles($match[2][0], $match[1][0]));
|
173 |
-
$args[] = '"font-weight: normal"';
|
174 |
-
|
175 |
-
$pos = $match[0][1];
|
176 |
-
$format = substr($format, 0, $pos) . '%c' . $match[1][0] . '%c' . substr($format, $pos + strlen($match[0][0]));
|
177 |
-
}
|
178 |
-
|
179 |
-
array_unshift($args, static::quote($format));
|
180 |
-
|
181 |
-
return $args;
|
182 |
-
}
|
183 |
-
|
184 |
-
private static function handleCustomStyles($style, $string)
|
185 |
-
{
|
186 |
-
static $colors = array('blue', 'green', 'red', 'magenta', 'orange', 'black', 'grey');
|
187 |
-
static $labels = array();
|
188 |
-
|
189 |
-
return preg_replace_callback('/macro\s*:(.*?)(?:;|$)/', function ($m) use ($string, &$colors, &$labels) {
|
190 |
-
if (trim($m[1]) === 'autolabel') {
|
191 |
-
// Format the string as a label with consistent auto assigned background color
|
192 |
-
if (!isset($labels[$string])) {
|
193 |
-
$labels[$string] = $colors[count($labels) % count($colors)];
|
194 |
-
}
|
195 |
-
$color = $labels[$string];
|
196 |
-
|
197 |
-
return "background-color: $color; color: white; border-radius: 3px; padding: 0 2px 0 2px";
|
198 |
-
}
|
199 |
-
|
200 |
-
return $m[1];
|
201 |
-
}, $style);
|
202 |
-
}
|
203 |
-
|
204 |
-
private static function dump($title, array $dict)
|
205 |
-
{
|
206 |
-
$script = array();
|
207 |
-
$dict = array_filter($dict);
|
208 |
-
if (empty($dict)) {
|
209 |
-
return $script;
|
210 |
-
}
|
211 |
-
$script[] = static::call('log', static::quote('%c%s'), static::quote('font-weight: bold'), static::quote($title));
|
212 |
-
foreach ($dict as $key => $value) {
|
213 |
-
$value = json_encode($value);
|
214 |
-
if (empty($value)) {
|
215 |
-
$value = static::quote('');
|
216 |
-
}
|
217 |
-
$script[] = static::call('log', static::quote('%s: %o'), static::quote($key), $value);
|
218 |
-
}
|
219 |
-
|
220 |
-
return $script;
|
221 |
-
}
|
222 |
-
|
223 |
-
private static function quote($arg)
|
224 |
-
{
|
225 |
-
return '"' . addcslashes($arg, "\"\n\\") . '"';
|
226 |
-
}
|
227 |
-
|
228 |
-
private static function call()
|
229 |
-
{
|
230 |
-
$args = func_get_args();
|
231 |
-
$method = array_shift($args);
|
232 |
-
|
233 |
-
return static::call_array($method, $args);
|
234 |
-
}
|
235 |
-
|
236 |
-
private static function call_array($method, array $args)
|
237 |
-
{
|
238 |
-
return 'c.' . $method . '(' . implode(', ', $args) . ');';
|
239 |
-
}
|
240 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php
DELETED
@@ -1,129 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\ResettableInterface;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Buffers all records until closing the handler and then pass them as batch.
|
19 |
-
*
|
20 |
-
* This is useful for a MailHandler to send only one mail per request instead of
|
21 |
-
* sending one per log message.
|
22 |
-
*
|
23 |
-
* @author Christophe Coevoet <stof@notk.org>
|
24 |
-
*/
|
25 |
-
class BufferHandler extends AbstractHandler
|
26 |
-
{
|
27 |
-
protected $handler;
|
28 |
-
protected $bufferSize = 0;
|
29 |
-
protected $bufferLimit;
|
30 |
-
protected $flushOnOverflow;
|
31 |
-
protected $buffer = array();
|
32 |
-
protected $initialized = false;
|
33 |
-
|
34 |
-
/**
|
35 |
-
* @param HandlerInterface $handler Handler.
|
36 |
-
* @param int $bufferLimit How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
|
37 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
38 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
39 |
-
* @param bool $flushOnOverflow If true, the buffer is flushed when the max size has been reached, by default oldest entries are discarded
|
40 |
-
*/
|
41 |
-
public function __construct(HandlerInterface $handler, $bufferLimit = 0, $level = Logger::DEBUG, $bubble = true, $flushOnOverflow = false)
|
42 |
-
{
|
43 |
-
parent::__construct($level, $bubble);
|
44 |
-
$this->handler = $handler;
|
45 |
-
$this->bufferLimit = (int) $bufferLimit;
|
46 |
-
$this->flushOnOverflow = $flushOnOverflow;
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* {@inheritdoc}
|
51 |
-
*/
|
52 |
-
public function handle(array $record)
|
53 |
-
{
|
54 |
-
if ($record['level'] < $this->level) {
|
55 |
-
return false;
|
56 |
-
}
|
57 |
-
|
58 |
-
if (!$this->initialized) {
|
59 |
-
// __destructor() doesn't get called on Fatal errors
|
60 |
-
register_shutdown_function(array($this, 'close'));
|
61 |
-
$this->initialized = true;
|
62 |
-
}
|
63 |
-
|
64 |
-
if ($this->bufferLimit > 0 && $this->bufferSize === $this->bufferLimit) {
|
65 |
-
if ($this->flushOnOverflow) {
|
66 |
-
$this->flush();
|
67 |
-
} else {
|
68 |
-
array_shift($this->buffer);
|
69 |
-
$this->bufferSize--;
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
if ($this->processors) {
|
74 |
-
foreach ($this->processors as $processor) {
|
75 |
-
$record = call_user_func($processor, $record);
|
76 |
-
}
|
77 |
-
}
|
78 |
-
|
79 |
-
$this->buffer[] = $record;
|
80 |
-
$this->bufferSize++;
|
81 |
-
|
82 |
-
return false === $this->bubble;
|
83 |
-
}
|
84 |
-
|
85 |
-
public function flush()
|
86 |
-
{
|
87 |
-
if ($this->bufferSize === 0) {
|
88 |
-
return;
|
89 |
-
}
|
90 |
-
|
91 |
-
$this->handler->handleBatch($this->buffer);
|
92 |
-
$this->clear();
|
93 |
-
}
|
94 |
-
|
95 |
-
public function __destruct()
|
96 |
-
{
|
97 |
-
// suppress the parent behavior since we already have register_shutdown_function()
|
98 |
-
// to call close(), and the reference contained there will prevent this from being
|
99 |
-
// GC'd until the end of the request
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* {@inheritdoc}
|
104 |
-
*/
|
105 |
-
public function close()
|
106 |
-
{
|
107 |
-
$this->flush();
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Clears the buffer without flushing any messages down to the wrapped handler.
|
112 |
-
*/
|
113 |
-
public function clear()
|
114 |
-
{
|
115 |
-
$this->bufferSize = 0;
|
116 |
-
$this->buffer = array();
|
117 |
-
}
|
118 |
-
|
119 |
-
public function reset()
|
120 |
-
{
|
121 |
-
$this->flush();
|
122 |
-
|
123 |
-
parent::reset();
|
124 |
-
|
125 |
-
if ($this->handler instanceof ResettableInterface) {
|
126 |
-
$this->handler->reset();
|
127 |
-
}
|
128 |
-
}
|
129 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php
DELETED
@@ -1,211 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\ChromePHPFormatter;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Handler sending logs to the ChromePHP extension (http://www.chromephp.com/)
|
19 |
-
*
|
20 |
-
* This also works out of the box with Firefox 43+
|
21 |
-
*
|
22 |
-
* @author Christophe Coevoet <stof@notk.org>
|
23 |
-
*/
|
24 |
-
class ChromePHPHandler extends AbstractProcessingHandler
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Version of the extension
|
28 |
-
*/
|
29 |
-
const VERSION = '4.0';
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Header name
|
33 |
-
*/
|
34 |
-
const HEADER_NAME = 'X-ChromeLogger-Data';
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Regular expression to detect supported browsers (matches any Chrome, or Firefox 43+)
|
38 |
-
*/
|
39 |
-
const USER_AGENT_REGEX = '{\b(?:Chrome/\d+(?:\.\d+)*|HeadlessChrome|Firefox/(?:4[3-9]|[5-9]\d|\d{3,})(?:\.\d)*)\b}';
|
40 |
-
|
41 |
-
protected static $initialized = false;
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Tracks whether we sent too much data
|
45 |
-
*
|
46 |
-
* Chrome limits the headers to 4KB, so when we sent 3KB we stop sending
|
47 |
-
*
|
48 |
-
* @var bool
|
49 |
-
*/
|
50 |
-
protected static $overflowed = false;
|
51 |
-
|
52 |
-
protected static $json = array(
|
53 |
-
'version' => self::VERSION,
|
54 |
-
'columns' => array('label', 'log', 'backtrace', 'type'),
|
55 |
-
'rows' => array(),
|
56 |
-
);
|
57 |
-
|
58 |
-
protected static $sendHeaders = true;
|
59 |
-
|
60 |
-
/**
|
61 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
62 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
63 |
-
*/
|
64 |
-
public function __construct($level = Logger::DEBUG, $bubble = true)
|
65 |
-
{
|
66 |
-
parent::__construct($level, $bubble);
|
67 |
-
if (!function_exists('json_encode')) {
|
68 |
-
throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s ChromePHPHandler');
|
69 |
-
}
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* {@inheritdoc}
|
74 |
-
*/
|
75 |
-
public function handleBatch(array $records)
|
76 |
-
{
|
77 |
-
$messages = array();
|
78 |
-
|
79 |
-
foreach ($records as $record) {
|
80 |
-
if ($record['level'] < $this->level) {
|
81 |
-
continue;
|
82 |
-
}
|
83 |
-
$messages[] = $this->processRecord($record);
|
84 |
-
}
|
85 |
-
|
86 |
-
if (!empty($messages)) {
|
87 |
-
$messages = $this->getFormatter()->formatBatch($messages);
|
88 |
-
self::$json['rows'] = array_merge(self::$json['rows'], $messages);
|
89 |
-
$this->send();
|
90 |
-
}
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* {@inheritDoc}
|
95 |
-
*/
|
96 |
-
protected function getDefaultFormatter()
|
97 |
-
{
|
98 |
-
return new ChromePHPFormatter();
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Creates & sends header for a record
|
103 |
-
*
|
104 |
-
* @see sendHeader()
|
105 |
-
* @see send()
|
106 |
-
* @param array $record
|
107 |
-
*/
|
108 |
-
protected function write(array $record)
|
109 |
-
{
|
110 |
-
self::$json['rows'][] = $record['formatted'];
|
111 |
-
|
112 |
-
$this->send();
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* Sends the log header
|
117 |
-
*
|
118 |
-
* @see sendHeader()
|
119 |
-
*/
|
120 |
-
protected function send()
|
121 |
-
{
|
122 |
-
if (self::$overflowed || !self::$sendHeaders) {
|
123 |
-
return;
|
124 |
-
}
|
125 |
-
|
126 |
-
if (!self::$initialized) {
|
127 |
-
self::$initialized = true;
|
128 |
-
|
129 |
-
self::$sendHeaders = $this->headersAccepted();
|
130 |
-
if (!self::$sendHeaders) {
|
131 |
-
return;
|
132 |
-
}
|
133 |
-
|
134 |
-
self::$json['request_uri'] = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
|
135 |
-
}
|
136 |
-
|
137 |
-
$json = @json_encode(self::$json);
|
138 |
-
$data = base64_encode(utf8_encode($json));
|
139 |
-
if (strlen($data) > 3 * 1024) {
|
140 |
-
self::$overflowed = true;
|
141 |
-
|
142 |
-
$record = array(
|
143 |
-
'message' => 'Incomplete logs, chrome header size limit reached',
|
144 |
-
'context' => array(),
|
145 |
-
'level' => Logger::WARNING,
|
146 |
-
'level_name' => Logger::getLevelName(Logger::WARNING),
|
147 |
-
'channel' => 'monolog',
|
148 |
-
'datetime' => new \DateTime(),
|
149 |
-
'extra' => array(),
|
150 |
-
);
|
151 |
-
self::$json['rows'][count(self::$json['rows']) - 1] = $this->getFormatter()->format($record);
|
152 |
-
$json = @json_encode(self::$json);
|
153 |
-
$data = base64_encode(utf8_encode($json));
|
154 |
-
}
|
155 |
-
|
156 |
-
if (trim($data) !== '') {
|
157 |
-
$this->sendHeader(self::HEADER_NAME, $data);
|
158 |
-
}
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Send header string to the client
|
163 |
-
*
|
164 |
-
* @param string $header
|
165 |
-
* @param string $content
|
166 |
-
*/
|
167 |
-
protected function sendHeader($header, $content)
|
168 |
-
{
|
169 |
-
if (!headers_sent() && self::$sendHeaders) {
|
170 |
-
header(sprintf('%s: %s', $header, $content));
|
171 |
-
}
|
172 |
-
}
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Verifies if the headers are accepted by the current user agent
|
176 |
-
*
|
177 |
-
* @return bool
|
178 |
-
*/
|
179 |
-
protected function headersAccepted()
|
180 |
-
{
|
181 |
-
if (empty($_SERVER['HTTP_USER_AGENT'])) {
|
182 |
-
return false;
|
183 |
-
}
|
184 |
-
|
185 |
-
return preg_match(self::USER_AGENT_REGEX, $_SERVER['HTTP_USER_AGENT']);
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* BC getter for the sendHeaders property that has been made static
|
190 |
-
*/
|
191 |
-
public function __get($property)
|
192 |
-
{
|
193 |
-
if ('sendHeaders' !== $property) {
|
194 |
-
throw new \InvalidArgumentException('Undefined property '.$property);
|
195 |
-
}
|
196 |
-
|
197 |
-
return static::$sendHeaders;
|
198 |
-
}
|
199 |
-
|
200 |
-
/**
|
201 |
-
* BC setter for the sendHeaders property that has been made static
|
202 |
-
*/
|
203 |
-
public function __set($property, $value)
|
204 |
-
{
|
205 |
-
if ('sendHeaders' !== $property) {
|
206 |
-
throw new \InvalidArgumentException('Undefined property '.$property);
|
207 |
-
}
|
208 |
-
|
209 |
-
static::$sendHeaders = $value;
|
210 |
-
}
|
211 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\JsonFormatter;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* CouchDB handler
|
19 |
-
*
|
20 |
-
* @author Markus Bachmann <markus.bachmann@bachi.biz>
|
21 |
-
*/
|
22 |
-
class CouchDBHandler extends AbstractProcessingHandler
|
23 |
-
{
|
24 |
-
private $options;
|
25 |
-
|
26 |
-
public function __construct(array $options = array(), $level = Logger::DEBUG, $bubble = true)
|
27 |
-
{
|
28 |
-
$this->options = array_merge(array(
|
29 |
-
'host' => 'localhost',
|
30 |
-
'port' => 5984,
|
31 |
-
'dbname' => 'logger',
|
32 |
-
'username' => null,
|
33 |
-
'password' => null,
|
34 |
-
), $options);
|
35 |
-
|
36 |
-
parent::__construct($level, $bubble);
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* {@inheritDoc}
|
41 |
-
*/
|
42 |
-
protected function write(array $record)
|
43 |
-
{
|
44 |
-
$basicAuth = null;
|
45 |
-
if ($this->options['username']) {
|
46 |
-
$basicAuth = sprintf('%s:%s@', $this->options['username'], $this->options['password']);
|
47 |
-
}
|
48 |
-
|
49 |
-
$url = 'http://'.$basicAuth.$this->options['host'].':'.$this->options['port'].'/'.$this->options['dbname'];
|
50 |
-
$context = stream_context_create(array(
|
51 |
-
'http' => array(
|
52 |
-
'method' => 'POST',
|
53 |
-
'content' => $record['formatted'],
|
54 |
-
'ignore_errors' => true,
|
55 |
-
'max_redirects' => 0,
|
56 |
-
'header' => 'Content-type: application/json',
|
57 |
-
),
|
58 |
-
));
|
59 |
-
|
60 |
-
if (false === @file_get_contents($url, null, $context)) {
|
61 |
-
throw new \RuntimeException(sprintf('Could not connect to %s', $url));
|
62 |
-
}
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* {@inheritDoc}
|
67 |
-
*/
|
68 |
-
protected function getDefaultFormatter()
|
69 |
-
{
|
70 |
-
return new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false);
|
71 |
-
}
|
72 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php
DELETED
@@ -1,151 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Logs to Cube.
|
18 |
-
*
|
19 |
-
* @link http://square.github.com/cube/
|
20 |
-
* @author Wan Chen <kami@kamisama.me>
|
21 |
-
*/
|
22 |
-
class CubeHandler extends AbstractProcessingHandler
|
23 |
-
{
|
24 |
-
private $udpConnection;
|
25 |
-
private $httpConnection;
|
26 |
-
private $scheme;
|
27 |
-
private $host;
|
28 |
-
private $port;
|
29 |
-
private $acceptedSchemes = array('http', 'udp');
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Create a Cube handler
|
33 |
-
*
|
34 |
-
* @throws \UnexpectedValueException when given url is not a valid url.
|
35 |
-
* A valid url must consist of three parts : protocol://host:port
|
36 |
-
* Only valid protocols used by Cube are http and udp
|
37 |
-
*/
|
38 |
-
public function __construct($url, $level = Logger::DEBUG, $bubble = true)
|
39 |
-
{
|
40 |
-
$urlInfo = parse_url($url);
|
41 |
-
|
42 |
-
if (!isset($urlInfo['scheme'], $urlInfo['host'], $urlInfo['port'])) {
|
43 |
-
throw new \UnexpectedValueException('URL "'.$url.'" is not valid');
|
44 |
-
}
|
45 |
-
|
46 |
-
if (!in_array($urlInfo['scheme'], $this->acceptedSchemes)) {
|
47 |
-
throw new \UnexpectedValueException(
|
48 |
-
'Invalid protocol (' . $urlInfo['scheme'] . ').'
|
49 |
-
. ' Valid options are ' . implode(', ', $this->acceptedSchemes));
|
50 |
-
}
|
51 |
-
|
52 |
-
$this->scheme = $urlInfo['scheme'];
|
53 |
-
$this->host = $urlInfo['host'];
|
54 |
-
$this->port = $urlInfo['port'];
|
55 |
-
|
56 |
-
parent::__construct($level, $bubble);
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Establish a connection to an UDP socket
|
61 |
-
*
|
62 |
-
* @throws \LogicException when unable to connect to the socket
|
63 |
-
* @throws MissingExtensionException when there is no socket extension
|
64 |
-
*/
|
65 |
-
protected function connectUdp()
|
66 |
-
{
|
67 |
-
if (!extension_loaded('sockets')) {
|
68 |
-
throw new MissingExtensionException('The sockets extension is required to use udp URLs with the CubeHandler');
|
69 |
-
}
|
70 |
-
|
71 |
-
$this->udpConnection = socket_create(AF_INET, SOCK_DGRAM, 0);
|
72 |
-
if (!$this->udpConnection) {
|
73 |
-
throw new \LogicException('Unable to create a socket');
|
74 |
-
}
|
75 |
-
|
76 |
-
if (!socket_connect($this->udpConnection, $this->host, $this->port)) {
|
77 |
-
throw new \LogicException('Unable to connect to the socket at ' . $this->host . ':' . $this->port);
|
78 |
-
}
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Establish a connection to a http server
|
83 |
-
* @throws \LogicException when no curl extension
|
84 |
-
*/
|
85 |
-
protected function connectHttp()
|
86 |
-
{
|
87 |
-
if (!extension_loaded('curl')) {
|
88 |
-
throw new \LogicException('The curl extension is needed to use http URLs with the CubeHandler');
|
89 |
-
}
|
90 |
-
|
91 |
-
$this->httpConnection = curl_init('http://'.$this->host.':'.$this->port.'/1.0/event/put');
|
92 |
-
|
93 |
-
if (!$this->httpConnection) {
|
94 |
-
throw new \LogicException('Unable to connect to ' . $this->host . ':' . $this->port);
|
95 |
-
}
|
96 |
-
|
97 |
-
curl_setopt($this->httpConnection, CURLOPT_CUSTOMREQUEST, "POST");
|
98 |
-
curl_setopt($this->httpConnection, CURLOPT_RETURNTRANSFER, true);
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* {@inheritdoc}
|
103 |
-
*/
|
104 |
-
protected function write(array $record)
|
105 |
-
{
|
106 |
-
$date = $record['datetime'];
|
107 |
-
|
108 |
-
$data = array('time' => $date->format('Y-m-d\TH:i:s.uO'));
|
109 |
-
unset($record['datetime']);
|
110 |
-
|
111 |
-
if (isset($record['context']['type'])) {
|
112 |
-
$data['type'] = $record['context']['type'];
|
113 |
-
unset($record['context']['type']);
|
114 |
-
} else {
|
115 |
-
$data['type'] = $record['channel'];
|
116 |
-
}
|
117 |
-
|
118 |
-
$data['data'] = $record['context'];
|
119 |
-
$data['data']['level'] = $record['level'];
|
120 |
-
|
121 |
-
if ($this->scheme === 'http') {
|
122 |
-
$this->writeHttp(json_encode($data));
|
123 |
-
} else {
|
124 |
-
$this->writeUdp(json_encode($data));
|
125 |
-
}
|
126 |
-
}
|
127 |
-
|
128 |
-
private function writeUdp($data)
|
129 |
-
{
|
130 |
-
if (!$this->udpConnection) {
|
131 |
-
$this->connectUdp();
|
132 |
-
}
|
133 |
-
|
134 |
-
socket_send($this->udpConnection, $data, strlen($data), 0);
|
135 |
-
}
|
136 |
-
|
137 |
-
private function writeHttp($data)
|
138 |
-
{
|
139 |
-
if (!$this->httpConnection) {
|
140 |
-
$this->connectHttp();
|
141 |
-
}
|
142 |
-
|
143 |
-
curl_setopt($this->httpConnection, CURLOPT_POSTFIELDS, '['.$data.']');
|
144 |
-
curl_setopt($this->httpConnection, CURLOPT_HTTPHEADER, array(
|
145 |
-
'Content-Type: application/json',
|
146 |
-
'Content-Length: ' . strlen('['.$data.']'),
|
147 |
-
));
|
148 |
-
|
149 |
-
Curl\Util::execute($this->httpConnection, 5, false);
|
150 |
-
}
|
151 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/Curl/Util.php
DELETED
@@ -1,57 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler\Curl;
|
13 |
-
|
14 |
-
class Util
|
15 |
-
{
|
16 |
-
private static $retriableErrorCodes = array(
|
17 |
-
CURLE_COULDNT_RESOLVE_HOST,
|
18 |
-
CURLE_COULDNT_CONNECT,
|
19 |
-
CURLE_HTTP_NOT_FOUND,
|
20 |
-
CURLE_READ_ERROR,
|
21 |
-
CURLE_OPERATION_TIMEOUTED,
|
22 |
-
CURLE_HTTP_POST_ERROR,
|
23 |
-
CURLE_SSL_CONNECT_ERROR,
|
24 |
-
);
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Executes a CURL request with optional retries and exception on failure
|
28 |
-
*
|
29 |
-
* @param resource $ch curl handler
|
30 |
-
* @throws \RuntimeException
|
31 |
-
*/
|
32 |
-
public static function execute($ch, $retries = 5, $closeAfterDone = true)
|
33 |
-
{
|
34 |
-
while ($retries--) {
|
35 |
-
if (curl_exec($ch) === false) {
|
36 |
-
$curlErrno = curl_errno($ch);
|
37 |
-
|
38 |
-
if (false === in_array($curlErrno, self::$retriableErrorCodes, true) || !$retries) {
|
39 |
-
$curlError = curl_error($ch);
|
40 |
-
|
41 |
-
if ($closeAfterDone) {
|
42 |
-
curl_close($ch);
|
43 |
-
}
|
44 |
-
|
45 |
-
throw new \RuntimeException(sprintf('Curl error (code %s): %s', $curlErrno, $curlError));
|
46 |
-
}
|
47 |
-
|
48 |
-
continue;
|
49 |
-
}
|
50 |
-
|
51 |
-
if ($closeAfterDone) {
|
52 |
-
curl_close($ch);
|
53 |
-
}
|
54 |
-
break;
|
55 |
-
}
|
56 |
-
}
|
57 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php
DELETED
@@ -1,169 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Simple handler wrapper that deduplicates log records across multiple requests
|
18 |
-
*
|
19 |
-
* It also includes the BufferHandler functionality and will buffer
|
20 |
-
* all messages until the end of the request or flush() is called.
|
21 |
-
*
|
22 |
-
* This works by storing all log records' messages above $deduplicationLevel
|
23 |
-
* to the file specified by $deduplicationStore. When further logs come in at the end of the
|
24 |
-
* request (or when flush() is called), all those above $deduplicationLevel are checked
|
25 |
-
* against the existing stored logs. If they match and the timestamps in the stored log is
|
26 |
-
* not older than $time seconds, the new log record is discarded. If no log record is new, the
|
27 |
-
* whole data set is discarded.
|
28 |
-
*
|
29 |
-
* This is mainly useful in combination with Mail handlers or things like Slack or HipChat handlers
|
30 |
-
* that send messages to people, to avoid spamming with the same message over and over in case of
|
31 |
-
* a major component failure like a database server being down which makes all requests fail in the
|
32 |
-
* same way.
|
33 |
-
*
|
34 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
35 |
-
*/
|
36 |
-
class DeduplicationHandler extends BufferHandler
|
37 |
-
{
|
38 |
-
/**
|
39 |
-
* @var string
|
40 |
-
*/
|
41 |
-
protected $deduplicationStore;
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @var int
|
45 |
-
*/
|
46 |
-
protected $deduplicationLevel;
|
47 |
-
|
48 |
-
/**
|
49 |
-
* @var int
|
50 |
-
*/
|
51 |
-
protected $time;
|
52 |
-
|
53 |
-
/**
|
54 |
-
* @var bool
|
55 |
-
*/
|
56 |
-
private $gc = false;
|
57 |
-
|
58 |
-
/**
|
59 |
-
* @param HandlerInterface $handler Handler.
|
60 |
-
* @param string $deduplicationStore The file/path where the deduplication log should be kept
|
61 |
-
* @param int $deduplicationLevel The minimum logging level for log records to be looked at for deduplication purposes
|
62 |
-
* @param int $time The period (in seconds) during which duplicate entries should be suppressed after a given log is sent through
|
63 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
64 |
-
*/
|
65 |
-
public function __construct(HandlerInterface $handler, $deduplicationStore = null, $deduplicationLevel = Logger::ERROR, $time = 60, $bubble = true)
|
66 |
-
{
|
67 |
-
parent::__construct($handler, 0, Logger::DEBUG, $bubble, false);
|
68 |
-
|
69 |
-
$this->deduplicationStore = $deduplicationStore === null ? sys_get_temp_dir() . '/monolog-dedup-' . substr(md5(__FILE__), 0, 20) .'.log' : $deduplicationStore;
|
70 |
-
$this->deduplicationLevel = Logger::toMonologLevel($deduplicationLevel);
|
71 |
-
$this->time = $time;
|
72 |
-
}
|
73 |
-
|
74 |
-
public function flush()
|
75 |
-
{
|
76 |
-
if ($this->bufferSize === 0) {
|
77 |
-
return;
|
78 |
-
}
|
79 |
-
|
80 |
-
$passthru = null;
|
81 |
-
|
82 |
-
foreach ($this->buffer as $record) {
|
83 |
-
if ($record['level'] >= $this->deduplicationLevel) {
|
84 |
-
|
85 |
-
$passthru = $passthru || !$this->isDuplicate($record);
|
86 |
-
if ($passthru) {
|
87 |
-
$this->appendRecord($record);
|
88 |
-
}
|
89 |
-
}
|
90 |
-
}
|
91 |
-
|
92 |
-
// default of null is valid as well as if no record matches duplicationLevel we just pass through
|
93 |
-
if ($passthru === true || $passthru === null) {
|
94 |
-
$this->handler->handleBatch($this->buffer);
|
95 |
-
}
|
96 |
-
|
97 |
-
$this->clear();
|
98 |
-
|
99 |
-
if ($this->gc) {
|
100 |
-
$this->collectLogs();
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
private function isDuplicate(array $record)
|
105 |
-
{
|
106 |
-
if (!file_exists($this->deduplicationStore)) {
|
107 |
-
return false;
|
108 |
-
}
|
109 |
-
|
110 |
-
$store = file($this->deduplicationStore, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
111 |
-
if (!is_array($store)) {
|
112 |
-
return false;
|
113 |
-
}
|
114 |
-
|
115 |
-
$yesterday = time() - 86400;
|
116 |
-
$timestampValidity = $record['datetime']->getTimestamp() - $this->time;
|
117 |
-
$expectedMessage = preg_replace('{[\r\n].*}', '', $record['message']);
|
118 |
-
|
119 |
-
for ($i = count($store) - 1; $i >= 0; $i--) {
|
120 |
-
list($timestamp, $level, $message) = explode(':', $store[$i], 3);
|
121 |
-
|
122 |
-
if ($level === $record['level_name'] && $message === $expectedMessage && $timestamp > $timestampValidity) {
|
123 |
-
return true;
|
124 |
-
}
|
125 |
-
|
126 |
-
if ($timestamp < $yesterday) {
|
127 |
-
$this->gc = true;
|
128 |
-
}
|
129 |
-
}
|
130 |
-
|
131 |
-
return false;
|
132 |
-
}
|
133 |
-
|
134 |
-
private function collectLogs()
|
135 |
-
{
|
136 |
-
if (!file_exists($this->deduplicationStore)) {
|
137 |
-
return false;
|
138 |
-
}
|
139 |
-
|
140 |
-
$handle = fopen($this->deduplicationStore, 'rw+');
|
141 |
-
flock($handle, LOCK_EX);
|
142 |
-
$validLogs = array();
|
143 |
-
|
144 |
-
$timestampValidity = time() - $this->time;
|
145 |
-
|
146 |
-
while (!feof($handle)) {
|
147 |
-
$log = fgets($handle);
|
148 |
-
if (substr($log, 0, 10) >= $timestampValidity) {
|
149 |
-
$validLogs[] = $log;
|
150 |
-
}
|
151 |
-
}
|
152 |
-
|
153 |
-
ftruncate($handle, 0);
|
154 |
-
rewind($handle);
|
155 |
-
foreach ($validLogs as $log) {
|
156 |
-
fwrite($handle, $log);
|
157 |
-
}
|
158 |
-
|
159 |
-
flock($handle, LOCK_UN);
|
160 |
-
fclose($handle);
|
161 |
-
|
162 |
-
$this->gc = false;
|
163 |
-
}
|
164 |
-
|
165 |
-
private function appendRecord(array $record)
|
166 |
-
{
|
167 |
-
file_put_contents($this->deduplicationStore, $record['datetime']->getTimestamp() . ':' . $record['level_name'] . ':' . preg_replace('{[\r\n].*}', '', $record['message']) . "\n", FILE_APPEND);
|
168 |
-
}
|
169 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php
DELETED
@@ -1,45 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\Formatter\NormalizerFormatter;
|
16 |
-
use Doctrine\CouchDB\CouchDBClient;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* CouchDB handler for Doctrine CouchDB ODM
|
20 |
-
*
|
21 |
-
* @author Markus Bachmann <markus.bachmann@bachi.biz>
|
22 |
-
*/
|
23 |
-
class DoctrineCouchDBHandler extends AbstractProcessingHandler
|
24 |
-
{
|
25 |
-
private $client;
|
26 |
-
|
27 |
-
public function __construct(CouchDBClient $client, $level = Logger::DEBUG, $bubble = true)
|
28 |
-
{
|
29 |
-
$this->client = $client;
|
30 |
-
parent::__construct($level, $bubble);
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* {@inheritDoc}
|
35 |
-
*/
|
36 |
-
protected function write(array $record)
|
37 |
-
{
|
38 |
-
$this->client->postDocument($record['formatted']);
|
39 |
-
}
|
40 |
-
|
41 |
-
protected function getDefaultFormatter()
|
42 |
-
{
|
43 |
-
return new NormalizerFormatter;
|
44 |
-
}
|
45 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php
DELETED
@@ -1,107 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Aws\Sdk;
|
15 |
-
use Aws\DynamoDb\DynamoDbClient;
|
16 |
-
use Aws\DynamoDb\Marshaler;
|
17 |
-
use Monolog\Formatter\ScalarFormatter;
|
18 |
-
use Monolog\Logger;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Amazon DynamoDB handler (http://aws.amazon.com/dynamodb/)
|
22 |
-
*
|
23 |
-
* @link https://github.com/aws/aws-sdk-php/
|
24 |
-
* @author Andrew Lawson <adlawson@gmail.com>
|
25 |
-
*/
|
26 |
-
class DynamoDbHandler extends AbstractProcessingHandler
|
27 |
-
{
|
28 |
-
const DATE_FORMAT = 'Y-m-d\TH:i:s.uO';
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @var DynamoDbClient
|
32 |
-
*/
|
33 |
-
protected $client;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* @var string
|
37 |
-
*/
|
38 |
-
protected $table;
|
39 |
-
|
40 |
-
/**
|
41 |
-
* @var int
|
42 |
-
*/
|
43 |
-
protected $version;
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @var Marshaler
|
47 |
-
*/
|
48 |
-
protected $marshaler;
|
49 |
-
|
50 |
-
/**
|
51 |
-
* @param DynamoDbClient $client
|
52 |
-
* @param string $table
|
53 |
-
* @param int $level
|
54 |
-
* @param bool $bubble
|
55 |
-
*/
|
56 |
-
public function __construct(DynamoDbClient $client, $table, $level = Logger::DEBUG, $bubble = true)
|
57 |
-
{
|
58 |
-
if (defined('Aws\Sdk::VERSION') && version_compare(Sdk::VERSION, '3.0', '>=')) {
|
59 |
-
$this->version = 3;
|
60 |
-
$this->marshaler = new Marshaler;
|
61 |
-
} else {
|
62 |
-
$this->version = 2;
|
63 |
-
}
|
64 |
-
|
65 |
-
$this->client = $client;
|
66 |
-
$this->table = $table;
|
67 |
-
|
68 |
-
parent::__construct($level, $bubble);
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* {@inheritdoc}
|
73 |
-
*/
|
74 |
-
protected function write(array $record)
|
75 |
-
{
|
76 |
-
$filtered = $this->filterEmptyFields($record['formatted']);
|
77 |
-
if ($this->version === 3) {
|
78 |
-
$formatted = $this->marshaler->marshalItem($filtered);
|
79 |
-
} else {
|
80 |
-
$formatted = $this->client->formatAttributes($filtered);
|
81 |
-
}
|
82 |
-
|
83 |
-
$this->client->putItem(array(
|
84 |
-
'TableName' => $this->table,
|
85 |
-
'Item' => $formatted,
|
86 |
-
));
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* @param array $record
|
91 |
-
* @return array
|
92 |
-
*/
|
93 |
-
protected function filterEmptyFields(array $record)
|
94 |
-
{
|
95 |
-
return array_filter($record, function ($value) {
|
96 |
-
return !empty($value) || false === $value || 0 === $value;
|
97 |
-
});
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* {@inheritdoc}
|
102 |
-
*/
|
103 |
-
protected function getDefaultFormatter()
|
104 |
-
{
|
105 |
-
return new ScalarFormatter(self::DATE_FORMAT);
|
106 |
-
}
|
107 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php
DELETED
@@ -1,128 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\FormatterInterface;
|
15 |
-
use Monolog\Formatter\ElasticaFormatter;
|
16 |
-
use Monolog\Logger;
|
17 |
-
use Elastica\Client;
|
18 |
-
use Elastica\Exception\ExceptionInterface;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Elastic Search handler
|
22 |
-
*
|
23 |
-
* Usage example:
|
24 |
-
*
|
25 |
-
* $client = new \Elastica\Client();
|
26 |
-
* $options = array(
|
27 |
-
* 'index' => 'elastic_index_name',
|
28 |
-
* 'type' => 'elastic_doc_type',
|
29 |
-
* );
|
30 |
-
* $handler = new ElasticSearchHandler($client, $options);
|
31 |
-
* $log = new Logger('application');
|
32 |
-
* $log->pushHandler($handler);
|
33 |
-
*
|
34 |
-
* @author Jelle Vink <jelle.vink@gmail.com>
|
35 |
-
*/
|
36 |
-
class ElasticSearchHandler extends AbstractProcessingHandler
|
37 |
-
{
|
38 |
-
/**
|
39 |
-
* @var Client
|
40 |
-
*/
|
41 |
-
protected $client;
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @var array Handler config options
|
45 |
-
*/
|
46 |
-
protected $options = array();
|
47 |
-
|
48 |
-
/**
|
49 |
-
* @param Client $client Elastica Client object
|
50 |
-
* @param array $options Handler configuration
|
51 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
52 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
53 |
-
*/
|
54 |
-
public function __construct(Client $client, array $options = array(), $level = Logger::DEBUG, $bubble = true)
|
55 |
-
{
|
56 |
-
parent::__construct($level, $bubble);
|
57 |
-
$this->client = $client;
|
58 |
-
$this->options = array_merge(
|
59 |
-
array(
|
60 |
-
'index' => 'monolog', // Elastic index name
|
61 |
-
'type' => 'record', // Elastic document type
|
62 |
-
'ignore_error' => false, // Suppress Elastica exceptions
|
63 |
-
),
|
64 |
-
$options
|
65 |
-
);
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* {@inheritDoc}
|
70 |
-
*/
|
71 |
-
protected function write(array $record)
|
72 |
-
{
|
73 |
-
$this->bulkSend(array($record['formatted']));
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* {@inheritdoc}
|
78 |
-
*/
|
79 |
-
public function setFormatter(FormatterInterface $formatter)
|
80 |
-
{
|
81 |
-
if ($formatter instanceof ElasticaFormatter) {
|
82 |
-
return parent::setFormatter($formatter);
|
83 |
-
}
|
84 |
-
throw new \InvalidArgumentException('ElasticSearchHandler is only compatible with ElasticaFormatter');
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Getter options
|
89 |
-
* @return array
|
90 |
-
*/
|
91 |
-
public function getOptions()
|
92 |
-
{
|
93 |
-
return $this->options;
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* {@inheritDoc}
|
98 |
-
*/
|
99 |
-
protected function getDefaultFormatter()
|
100 |
-
{
|
101 |
-
return new ElasticaFormatter($this->options['index'], $this->options['type']);
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* {@inheritdoc}
|
106 |
-
*/
|
107 |
-
public function handleBatch(array $records)
|
108 |
-
{
|
109 |
-
$documents = $this->getFormatter()->formatBatch($records);
|
110 |
-
$this->bulkSend($documents);
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Use Elasticsearch bulk API to send list of documents
|
115 |
-
* @param array $documents
|
116 |
-
* @throws \RuntimeException
|
117 |
-
*/
|
118 |
-
protected function bulkSend(array $documents)
|
119 |
-
{
|
120 |
-
try {
|
121 |
-
$this->client->addDocuments($documents);
|
122 |
-
} catch (ExceptionInterface $e) {
|
123 |
-
if (!$this->options['ignore_error']) {
|
124 |
-
throw new \RuntimeException("Error sending messages to Elasticsearch", 0, $e);
|
125 |
-
}
|
126 |
-
}
|
127 |
-
}
|
128 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php
DELETED
@@ -1,82 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\LineFormatter;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Stores to PHP error_log() handler.
|
19 |
-
*
|
20 |
-
* @author Elan Ruusamäe <glen@delfi.ee>
|
21 |
-
*/
|
22 |
-
class ErrorLogHandler extends AbstractProcessingHandler
|
23 |
-
{
|
24 |
-
const OPERATING_SYSTEM = 0;
|
25 |
-
const SAPI = 4;
|
26 |
-
|
27 |
-
protected $messageType;
|
28 |
-
protected $expandNewlines;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @param int $messageType Says where the error should go.
|
32 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
33 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
34 |
-
* @param bool $expandNewlines If set to true, newlines in the message will be expanded to be take multiple log entries
|
35 |
-
*/
|
36 |
-
public function __construct($messageType = self::OPERATING_SYSTEM, $level = Logger::DEBUG, $bubble = true, $expandNewlines = false)
|
37 |
-
{
|
38 |
-
parent::__construct($level, $bubble);
|
39 |
-
|
40 |
-
if (false === in_array($messageType, self::getAvailableTypes())) {
|
41 |
-
$message = sprintf('The given message type "%s" is not supported', print_r($messageType, true));
|
42 |
-
throw new \InvalidArgumentException($message);
|
43 |
-
}
|
44 |
-
|
45 |
-
$this->messageType = $messageType;
|
46 |
-
$this->expandNewlines = $expandNewlines;
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* @return array With all available types
|
51 |
-
*/
|
52 |
-
public static function getAvailableTypes()
|
53 |
-
{
|
54 |
-
return array(
|
55 |
-
self::OPERATING_SYSTEM,
|
56 |
-
self::SAPI,
|
57 |
-
);
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* {@inheritDoc}
|
62 |
-
*/
|
63 |
-
protected function getDefaultFormatter()
|
64 |
-
{
|
65 |
-
return new LineFormatter('[%datetime%] %channel%.%level_name%: %message% %context% %extra%');
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* {@inheritdoc}
|
70 |
-
*/
|
71 |
-
protected function write(array $record)
|
72 |
-
{
|
73 |
-
if ($this->expandNewlines) {
|
74 |
-
$lines = preg_split('{[\r\n]+}', (string) $record['formatted']);
|
75 |
-
foreach ($lines as $line) {
|
76 |
-
error_log($line, $this->messageType);
|
77 |
-
}
|
78 |
-
} else {
|
79 |
-
error_log((string) $record['formatted'], $this->messageType);
|
80 |
-
}
|
81 |
-
}
|
82 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php
DELETED
@@ -1,140 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Simple handler wrapper that filters records based on a list of levels
|
18 |
-
*
|
19 |
-
* It can be configured with an exact list of levels to allow, or a min/max level.
|
20 |
-
*
|
21 |
-
* @author Hennadiy Verkh
|
22 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
23 |
-
*/
|
24 |
-
class FilterHandler extends AbstractHandler
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Handler or factory callable($record, $this)
|
28 |
-
*
|
29 |
-
* @var callable|\Monolog\Handler\HandlerInterface
|
30 |
-
*/
|
31 |
-
protected $handler;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Minimum level for logs that are passed to handler
|
35 |
-
*
|
36 |
-
* @var int[]
|
37 |
-
*/
|
38 |
-
protected $acceptedLevels;
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Whether the messages that are handled can bubble up the stack or not
|
42 |
-
*
|
43 |
-
* @var bool
|
44 |
-
*/
|
45 |
-
protected $bubble;
|
46 |
-
|
47 |
-
/**
|
48 |
-
* @param callable|HandlerInterface $handler Handler or factory callable($record, $this).
|
49 |
-
* @param int|array $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided
|
50 |
-
* @param int $maxLevel Maximum level to accept, only used if $minLevelOrList is not an array
|
51 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
52 |
-
*/
|
53 |
-
public function __construct($handler, $minLevelOrList = Logger::DEBUG, $maxLevel = Logger::EMERGENCY, $bubble = true)
|
54 |
-
{
|
55 |
-
$this->handler = $handler;
|
56 |
-
$this->bubble = $bubble;
|
57 |
-
$this->setAcceptedLevels($minLevelOrList, $maxLevel);
|
58 |
-
|
59 |
-
if (!$this->handler instanceof HandlerInterface && !is_callable($this->handler)) {
|
60 |
-
throw new \RuntimeException("The given handler (".json_encode($this->handler).") is not a callable nor a Monolog\Handler\HandlerInterface object");
|
61 |
-
}
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* @return array
|
66 |
-
*/
|
67 |
-
public function getAcceptedLevels()
|
68 |
-
{
|
69 |
-
return array_flip($this->acceptedLevels);
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* @param int|string|array $minLevelOrList A list of levels to accept or a minimum level or level name if maxLevel is provided
|
74 |
-
* @param int|string $maxLevel Maximum level or level name to accept, only used if $minLevelOrList is not an array
|
75 |
-
*/
|
76 |
-
public function setAcceptedLevels($minLevelOrList = Logger::DEBUG, $maxLevel = Logger::EMERGENCY)
|
77 |
-
{
|
78 |
-
if (is_array($minLevelOrList)) {
|
79 |
-
$acceptedLevels = array_map('Monolog\Logger::toMonologLevel', $minLevelOrList);
|
80 |
-
} else {
|
81 |
-
$minLevelOrList = Logger::toMonologLevel($minLevelOrList);
|
82 |
-
$maxLevel = Logger::toMonologLevel($maxLevel);
|
83 |
-
$acceptedLevels = array_values(array_filter(Logger::getLevels(), function ($level) use ($minLevelOrList, $maxLevel) {
|
84 |
-
return $level >= $minLevelOrList && $level <= $maxLevel;
|
85 |
-
}));
|
86 |
-
}
|
87 |
-
$this->acceptedLevels = array_flip($acceptedLevels);
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* {@inheritdoc}
|
92 |
-
*/
|
93 |
-
public function isHandling(array $record)
|
94 |
-
{
|
95 |
-
return isset($this->acceptedLevels[$record['level']]);
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* {@inheritdoc}
|
100 |
-
*/
|
101 |
-
public function handle(array $record)
|
102 |
-
{
|
103 |
-
if (!$this->isHandling($record)) {
|
104 |
-
return false;
|
105 |
-
}
|
106 |
-
|
107 |
-
// The same logic as in FingersCrossedHandler
|
108 |
-
if (!$this->handler instanceof HandlerInterface) {
|
109 |
-
$this->handler = call_user_func($this->handler, $record, $this);
|
110 |
-
if (!$this->handler instanceof HandlerInterface) {
|
111 |
-
throw new \RuntimeException("The factory callable should return a HandlerInterface");
|
112 |
-
}
|
113 |
-
}
|
114 |
-
|
115 |
-
if ($this->processors) {
|
116 |
-
foreach ($this->processors as $processor) {
|
117 |
-
$record = call_user_func($processor, $record);
|
118 |
-
}
|
119 |
-
}
|
120 |
-
|
121 |
-
$this->handler->handle($record);
|
122 |
-
|
123 |
-
return false === $this->bubble;
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* {@inheritdoc}
|
128 |
-
*/
|
129 |
-
public function handleBatch(array $records)
|
130 |
-
{
|
131 |
-
$filtered = array();
|
132 |
-
foreach ($records as $record) {
|
133 |
-
if ($this->isHandling($record)) {
|
134 |
-
$filtered[] = $record;
|
135 |
-
}
|
136 |
-
}
|
137 |
-
|
138 |
-
$this->handler->handleBatch($filtered);
|
139 |
-
}
|
140 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler\FingersCrossed;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Interface for activation strategies for the FingersCrossedHandler.
|
16 |
-
*
|
17 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
18 |
-
*/
|
19 |
-
interface ActivationStrategyInterface
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* Returns whether the given record activates the handler.
|
23 |
-
*
|
24 |
-
* @param array $record
|
25 |
-
* @return bool
|
26 |
-
*/
|
27 |
-
public function isHandlerActivated(array $record);
|
28 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php
DELETED
@@ -1,59 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler\FingersCrossed;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Channel and Error level based monolog activation strategy. Allows to trigger activation
|
18 |
-
* based on level per channel. e.g. trigger activation on level 'ERROR' by default, except
|
19 |
-
* for records of the 'sql' channel; those should trigger activation on level 'WARN'.
|
20 |
-
*
|
21 |
-
* Example:
|
22 |
-
*
|
23 |
-
* <code>
|
24 |
-
* $activationStrategy = new ChannelLevelActivationStrategy(
|
25 |
-
* Logger::CRITICAL,
|
26 |
-
* array(
|
27 |
-
* 'request' => Logger::ALERT,
|
28 |
-
* 'sensitive' => Logger::ERROR,
|
29 |
-
* )
|
30 |
-
* );
|
31 |
-
* $handler = new FingersCrossedHandler(new StreamHandler('php://stderr'), $activationStrategy);
|
32 |
-
* </code>
|
33 |
-
*
|
34 |
-
* @author Mike Meessen <netmikey@gmail.com>
|
35 |
-
*/
|
36 |
-
class ChannelLevelActivationStrategy implements ActivationStrategyInterface
|
37 |
-
{
|
38 |
-
private $defaultActionLevel;
|
39 |
-
private $channelToActionLevel;
|
40 |
-
|
41 |
-
/**
|
42 |
-
* @param int $defaultActionLevel The default action level to be used if the record's category doesn't match any
|
43 |
-
* @param array $channelToActionLevel An array that maps channel names to action levels.
|
44 |
-
*/
|
45 |
-
public function __construct($defaultActionLevel, $channelToActionLevel = array())
|
46 |
-
{
|
47 |
-
$this->defaultActionLevel = Logger::toMonologLevel($defaultActionLevel);
|
48 |
-
$this->channelToActionLevel = array_map('Monolog\Logger::toMonologLevel', $channelToActionLevel);
|
49 |
-
}
|
50 |
-
|
51 |
-
public function isHandlerActivated(array $record)
|
52 |
-
{
|
53 |
-
if (isset($this->channelToActionLevel[$record['channel']])) {
|
54 |
-
return $record['level'] >= $this->channelToActionLevel[$record['channel']];
|
55 |
-
}
|
56 |
-
|
57 |
-
return $record['level'] >= $this->defaultActionLevel;
|
58 |
-
}
|
59 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler\FingersCrossed;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Error level based activation strategy.
|
18 |
-
*
|
19 |
-
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
20 |
-
*/
|
21 |
-
class ErrorLevelActivationStrategy implements ActivationStrategyInterface
|
22 |
-
{
|
23 |
-
private $actionLevel;
|
24 |
-
|
25 |
-
public function __construct($actionLevel)
|
26 |
-
{
|
27 |
-
$this->actionLevel = Logger::toMonologLevel($actionLevel);
|
28 |
-
}
|
29 |
-
|
30 |
-
public function isHandlerActivated(array $record)
|
31 |
-
{
|
32 |
-
return $record['level'] >= $this->actionLevel;
|
33 |
-
}
|
34 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php
DELETED
@@ -1,177 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
|
15 |
-
use Monolog\Handler\FingersCrossed\ActivationStrategyInterface;
|
16 |
-
use Monolog\Logger;
|
17 |
-
use Monolog\ResettableInterface;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Buffers all records until a certain level is reached
|
21 |
-
*
|
22 |
-
* The advantage of this approach is that you don't get any clutter in your log files.
|
23 |
-
* Only requests which actually trigger an error (or whatever your actionLevel is) will be
|
24 |
-
* in the logs, but they will contain all records, not only those above the level threshold.
|
25 |
-
*
|
26 |
-
* You can find the various activation strategies in the
|
27 |
-
* Monolog\Handler\FingersCrossed\ namespace.
|
28 |
-
*
|
29 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
30 |
-
*/
|
31 |
-
class FingersCrossedHandler extends AbstractHandler
|
32 |
-
{
|
33 |
-
protected $handler;
|
34 |
-
protected $activationStrategy;
|
35 |
-
protected $buffering = true;
|
36 |
-
protected $bufferSize;
|
37 |
-
protected $buffer = array();
|
38 |
-
protected $stopBuffering;
|
39 |
-
protected $passthruLevel;
|
40 |
-
|
41 |
-
/**
|
42 |
-
* @param callable|HandlerInterface $handler Handler or factory callable($record, $fingersCrossedHandler).
|
43 |
-
* @param int|ActivationStrategyInterface $activationStrategy Strategy which determines when this handler takes action
|
44 |
-
* @param int $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
|
45 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
46 |
-
* @param bool $stopBuffering Whether the handler should stop buffering after being triggered (default true)
|
47 |
-
* @param int $passthruLevel Minimum level to always flush to handler on close, even if strategy not triggered
|
48 |
-
*/
|
49 |
-
public function __construct($handler, $activationStrategy = null, $bufferSize = 0, $bubble = true, $stopBuffering = true, $passthruLevel = null)
|
50 |
-
{
|
51 |
-
if (null === $activationStrategy) {
|
52 |
-
$activationStrategy = new ErrorLevelActivationStrategy(Logger::WARNING);
|
53 |
-
}
|
54 |
-
|
55 |
-
// convert simple int activationStrategy to an object
|
56 |
-
if (!$activationStrategy instanceof ActivationStrategyInterface) {
|
57 |
-
$activationStrategy = new ErrorLevelActivationStrategy($activationStrategy);
|
58 |
-
}
|
59 |
-
|
60 |
-
$this->handler = $handler;
|
61 |
-
$this->activationStrategy = $activationStrategy;
|
62 |
-
$this->bufferSize = $bufferSize;
|
63 |
-
$this->bubble = $bubble;
|
64 |
-
$this->stopBuffering = $stopBuffering;
|
65 |
-
|
66 |
-
if ($passthruLevel !== null) {
|
67 |
-
$this->passthruLevel = Logger::toMonologLevel($passthruLevel);
|
68 |
-
}
|
69 |
-
|
70 |
-
if (!$this->handler instanceof HandlerInterface && !is_callable($this->handler)) {
|
71 |
-
throw new \RuntimeException("The given handler (".json_encode($this->handler).") is not a callable nor a Monolog\Handler\HandlerInterface object");
|
72 |
-
}
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* {@inheritdoc}
|
77 |
-
*/
|
78 |
-
public function isHandling(array $record)
|
79 |
-
{
|
80 |
-
return true;
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Manually activate this logger regardless of the activation strategy
|
85 |
-
*/
|
86 |
-
public function activate()
|
87 |
-
{
|
88 |
-
if ($this->stopBuffering) {
|
89 |
-
$this->buffering = false;
|
90 |
-
}
|
91 |
-
if (!$this->handler instanceof HandlerInterface) {
|
92 |
-
$record = end($this->buffer) ?: null;
|
93 |
-
|
94 |
-
$this->handler = call_user_func($this->handler, $record, $this);
|
95 |
-
if (!$this->handler instanceof HandlerInterface) {
|
96 |
-
throw new \RuntimeException("The factory callable should return a HandlerInterface");
|
97 |
-
}
|
98 |
-
}
|
99 |
-
$this->handler->handleBatch($this->buffer);
|
100 |
-
$this->buffer = array();
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* {@inheritdoc}
|
105 |
-
*/
|
106 |
-
public function handle(array $record)
|
107 |
-
{
|
108 |
-
if ($this->processors) {
|
109 |
-
foreach ($this->processors as $processor) {
|
110 |
-
$record = call_user_func($processor, $record);
|
111 |
-
}
|
112 |
-
}
|
113 |
-
|
114 |
-
if ($this->buffering) {
|
115 |
-
$this->buffer[] = $record;
|
116 |
-
if ($this->bufferSize > 0 && count($this->buffer) > $this->bufferSize) {
|
117 |
-
array_shift($this->buffer);
|
118 |
-
}
|
119 |
-
if ($this->activationStrategy->isHandlerActivated($record)) {
|
120 |
-
$this->activate();
|
121 |
-
}
|
122 |
-
} else {
|
123 |
-
$this->handler->handle($record);
|
124 |
-
}
|
125 |
-
|
126 |
-
return false === $this->bubble;
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* {@inheritdoc}
|
131 |
-
*/
|
132 |
-
public function close()
|
133 |
-
{
|
134 |
-
$this->flushBuffer();
|
135 |
-
}
|
136 |
-
|
137 |
-
public function reset()
|
138 |
-
{
|
139 |
-
$this->flushBuffer();
|
140 |
-
|
141 |
-
parent::reset();
|
142 |
-
|
143 |
-
if ($this->handler instanceof ResettableInterface) {
|
144 |
-
$this->handler->reset();
|
145 |
-
}
|
146 |
-
}
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Clears the buffer without flushing any messages down to the wrapped handler.
|
150 |
-
*
|
151 |
-
* It also resets the handler to its initial buffering state.
|
152 |
-
*/
|
153 |
-
public function clear()
|
154 |
-
{
|
155 |
-
$this->buffer = array();
|
156 |
-
$this->reset();
|
157 |
-
}
|
158 |
-
|
159 |
-
/**
|
160 |
-
* Resets the state of the handler. Stops forwarding records to the wrapped handler.
|
161 |
-
*/
|
162 |
-
private function flushBuffer()
|
163 |
-
{
|
164 |
-
if (null !== $this->passthruLevel) {
|
165 |
-
$level = $this->passthruLevel;
|
166 |
-
$this->buffer = array_filter($this->buffer, function ($record) use ($level) {
|
167 |
-
return $record['level'] >= $level;
|
168 |
-
});
|
169 |
-
if (count($this->buffer) > 0) {
|
170 |
-
$this->handler->handleBatch($this->buffer);
|
171 |
-
}
|
172 |
-
}
|
173 |
-
|
174 |
-
$this->buffer = array();
|
175 |
-
$this->buffering = true;
|
176 |
-
}
|
177 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php
DELETED
@@ -1,195 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\WildfireFormatter;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Simple FirePHP Handler (http://www.firephp.org/), which uses the Wildfire protocol.
|
18 |
-
*
|
19 |
-
* @author Eric Clemmons (@ericclemmons) <eric@uxdriven.com>
|
20 |
-
*/
|
21 |
-
class FirePHPHandler extends AbstractProcessingHandler
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* WildFire JSON header message format
|
25 |
-
*/
|
26 |
-
const PROTOCOL_URI = 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2';
|
27 |
-
|
28 |
-
/**
|
29 |
-
* FirePHP structure for parsing messages & their presentation
|
30 |
-
*/
|
31 |
-
const STRUCTURE_URI = 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1';
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Must reference a "known" plugin, otherwise headers won't display in FirePHP
|
35 |
-
*/
|
36 |
-
const PLUGIN_URI = 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3';
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Header prefix for Wildfire to recognize & parse headers
|
40 |
-
*/
|
41 |
-
const HEADER_PREFIX = 'X-Wf';
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Whether or not Wildfire vendor-specific headers have been generated & sent yet
|
45 |
-
*/
|
46 |
-
protected static $initialized = false;
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Shared static message index between potentially multiple handlers
|
50 |
-
* @var int
|
51 |
-
*/
|
52 |
-
protected static $messageIndex = 1;
|
53 |
-
|
54 |
-
protected static $sendHeaders = true;
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Base header creation function used by init headers & record headers
|
58 |
-
*
|
59 |
-
* @param array $meta Wildfire Plugin, Protocol & Structure Indexes
|
60 |
-
* @param string $message Log message
|
61 |
-
* @return array Complete header string ready for the client as key and message as value
|
62 |
-
*/
|
63 |
-
protected function createHeader(array $meta, $message)
|
64 |
-
{
|
65 |
-
$header = sprintf('%s-%s', self::HEADER_PREFIX, join('-', $meta));
|
66 |
-
|
67 |
-
return array($header => $message);
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Creates message header from record
|
72 |
-
*
|
73 |
-
* @see createHeader()
|
74 |
-
* @param array $record
|
75 |
-
* @return string
|
76 |
-
*/
|
77 |
-
protected function createRecordHeader(array $record)
|
78 |
-
{
|
79 |
-
// Wildfire is extensible to support multiple protocols & plugins in a single request,
|
80 |
-
// but we're not taking advantage of that (yet), so we're using "1" for simplicity's sake.
|
81 |
-
return $this->createHeader(
|
82 |
-
array(1, 1, 1, self::$messageIndex++),
|
83 |
-
$record['formatted']
|
84 |
-
);
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* {@inheritDoc}
|
89 |
-
*/
|
90 |
-
protected function getDefaultFormatter()
|
91 |
-
{
|
92 |
-
return new WildfireFormatter();
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Wildfire initialization headers to enable message parsing
|
97 |
-
*
|
98 |
-
* @see createHeader()
|
99 |
-
* @see sendHeader()
|
100 |
-
* @return array
|
101 |
-
*/
|
102 |
-
protected function getInitHeaders()
|
103 |
-
{
|
104 |
-
// Initial payload consists of required headers for Wildfire
|
105 |
-
return array_merge(
|
106 |
-
$this->createHeader(array('Protocol', 1), self::PROTOCOL_URI),
|
107 |
-
$this->createHeader(array(1, 'Structure', 1), self::STRUCTURE_URI),
|
108 |
-
$this->createHeader(array(1, 'Plugin', 1), self::PLUGIN_URI)
|
109 |
-
);
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Send header string to the client
|
114 |
-
*
|
115 |
-
* @param string $header
|
116 |
-
* @param string $content
|
117 |
-
*/
|
118 |
-
protected function sendHeader($header, $content)
|
119 |
-
{
|
120 |
-
if (!headers_sent() && self::$sendHeaders) {
|
121 |
-
header(sprintf('%s: %s', $header, $content));
|
122 |
-
}
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* Creates & sends header for a record, ensuring init headers have been sent prior
|
127 |
-
*
|
128 |
-
* @see sendHeader()
|
129 |
-
* @see sendInitHeaders()
|
130 |
-
* @param array $record
|
131 |
-
*/
|
132 |
-
protected function write(array $record)
|
133 |
-
{
|
134 |
-
if (!self::$sendHeaders) {
|
135 |
-
return;
|
136 |
-
}
|
137 |
-
|
138 |
-
// WildFire-specific headers must be sent prior to any messages
|
139 |
-
if (!self::$initialized) {
|
140 |
-
self::$initialized = true;
|
141 |
-
|
142 |
-
self::$sendHeaders = $this->headersAccepted();
|
143 |
-
if (!self::$sendHeaders) {
|
144 |
-
return;
|
145 |
-
}
|
146 |
-
|
147 |
-
foreach ($this->getInitHeaders() as $header => $content) {
|
148 |
-
$this->sendHeader($header, $content);
|
149 |
-
}
|
150 |
-
}
|
151 |
-
|
152 |
-
$header = $this->createRecordHeader($record);
|
153 |
-
if (trim(current($header)) !== '') {
|
154 |
-
$this->sendHeader(key($header), current($header));
|
155 |
-
}
|
156 |
-
}
|
157 |
-
|
158 |
-
/**
|
159 |
-
* Verifies if the headers are accepted by the current user agent
|
160 |
-
*
|
161 |
-
* @return bool
|
162 |
-
*/
|
163 |
-
protected function headersAccepted()
|
164 |
-
{
|
165 |
-
if (!empty($_SERVER['HTTP_USER_AGENT']) && preg_match('{\bFirePHP/\d+\.\d+\b}', $_SERVER['HTTP_USER_AGENT'])) {
|
166 |
-
return true;
|
167 |
-
}
|
168 |
-
|
169 |
-
return isset($_SERVER['HTTP_X_FIREPHP_VERSION']);
|
170 |
-
}
|
171 |
-
|
172 |
-
/**
|
173 |
-
* BC getter for the sendHeaders property that has been made static
|
174 |
-
*/
|
175 |
-
public function __get($property)
|
176 |
-
{
|
177 |
-
if ('sendHeaders' !== $property) {
|
178 |
-
throw new \InvalidArgumentException('Undefined property '.$property);
|
179 |
-
}
|
180 |
-
|
181 |
-
return static::$sendHeaders;
|
182 |
-
}
|
183 |
-
|
184 |
-
/**
|
185 |
-
* BC setter for the sendHeaders property that has been made static
|
186 |
-
*/
|
187 |
-
public function __set($property, $value)
|
188 |
-
{
|
189 |
-
if ('sendHeaders' !== $property) {
|
190 |
-
throw new \InvalidArgumentException('Undefined property '.$property);
|
191 |
-
}
|
192 |
-
|
193 |
-
static::$sendHeaders = $value;
|
194 |
-
}
|
195 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/FleepHookHandler.php
DELETED
@@ -1,126 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\LineFormatter;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Sends logs to Fleep.io using Webhook integrations
|
19 |
-
*
|
20 |
-
* You'll need a Fleep.io account to use this handler.
|
21 |
-
*
|
22 |
-
* @see https://fleep.io/integrations/webhooks/ Fleep Webhooks Documentation
|
23 |
-
* @author Ando Roots <ando@sqroot.eu>
|
24 |
-
*/
|
25 |
-
class FleepHookHandler extends SocketHandler
|
26 |
-
{
|
27 |
-
const FLEEP_HOST = 'fleep.io';
|
28 |
-
|
29 |
-
const FLEEP_HOOK_URI = '/hook/';
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @var string Webhook token (specifies the conversation where logs are sent)
|
33 |
-
*/
|
34 |
-
protected $token;
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Construct a new Fleep.io Handler.
|
38 |
-
*
|
39 |
-
* For instructions on how to create a new web hook in your conversations
|
40 |
-
* see https://fleep.io/integrations/webhooks/
|
41 |
-
*
|
42 |
-
* @param string $token Webhook token
|
43 |
-
* @param bool|int $level The minimum logging level at which this handler will be triggered
|
44 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
45 |
-
* @throws MissingExtensionException
|
46 |
-
*/
|
47 |
-
public function __construct($token, $level = Logger::DEBUG, $bubble = true)
|
48 |
-
{
|
49 |
-
if (!extension_loaded('openssl')) {
|
50 |
-
throw new MissingExtensionException('The OpenSSL PHP extension is required to use the FleepHookHandler');
|
51 |
-
}
|
52 |
-
|
53 |
-
$this->token = $token;
|
54 |
-
|
55 |
-
$connectionString = 'ssl://' . self::FLEEP_HOST . ':443';
|
56 |
-
parent::__construct($connectionString, $level, $bubble);
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Returns the default formatter to use with this handler
|
61 |
-
*
|
62 |
-
* Overloaded to remove empty context and extra arrays from the end of the log message.
|
63 |
-
*
|
64 |
-
* @return LineFormatter
|
65 |
-
*/
|
66 |
-
protected function getDefaultFormatter()
|
67 |
-
{
|
68 |
-
return new LineFormatter(null, null, true, true);
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Handles a log record
|
73 |
-
*
|
74 |
-
* @param array $record
|
75 |
-
*/
|
76 |
-
public function write(array $record)
|
77 |
-
{
|
78 |
-
parent::write($record);
|
79 |
-
$this->closeSocket();
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* {@inheritdoc}
|
84 |
-
*
|
85 |
-
* @param array $record
|
86 |
-
* @return string
|
87 |
-
*/
|
88 |
-
protected function generateDataStream($record)
|
89 |
-
{
|
90 |
-
$content = $this->buildContent($record);
|
91 |
-
|
92 |
-
return $this->buildHeader($content) . $content;
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Builds the header of the API Call
|
97 |
-
*
|
98 |
-
* @param string $content
|
99 |
-
* @return string
|
100 |
-
*/
|
101 |
-
private function buildHeader($content)
|
102 |
-
{
|
103 |
-
$header = "POST " . self::FLEEP_HOOK_URI . $this->token . " HTTP/1.1\r\n";
|
104 |
-
$header .= "Host: " . self::FLEEP_HOST . "\r\n";
|
105 |
-
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
106 |
-
$header .= "Content-Length: " . strlen($content) . "\r\n";
|
107 |
-
$header .= "\r\n";
|
108 |
-
|
109 |
-
return $header;
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Builds the body of API call
|
114 |
-
*
|
115 |
-
* @param array $record
|
116 |
-
* @return string
|
117 |
-
*/
|
118 |
-
private function buildContent($record)
|
119 |
-
{
|
120 |
-
$dataArray = array(
|
121 |
-
'message' => $record['formatted'],
|
122 |
-
);
|
123 |
-
|
124 |
-
return http_build_query($dataArray);
|
125 |
-
}
|
126 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php
DELETED
@@ -1,127 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\Formatter\FlowdockFormatter;
|
16 |
-
use Monolog\Formatter\FormatterInterface;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Sends notifications through the Flowdock push API
|
20 |
-
*
|
21 |
-
* This must be configured with a FlowdockFormatter instance via setFormatter()
|
22 |
-
*
|
23 |
-
* Notes:
|
24 |
-
* API token - Flowdock API token
|
25 |
-
*
|
26 |
-
* @author Dominik Liebler <liebler.dominik@gmail.com>
|
27 |
-
* @see https://www.flowdock.com/api/push
|
28 |
-
*/
|
29 |
-
class FlowdockHandler extends SocketHandler
|
30 |
-
{
|
31 |
-
/**
|
32 |
-
* @var string
|
33 |
-
*/
|
34 |
-
protected $apiToken;
|
35 |
-
|
36 |
-
/**
|
37 |
-
* @param string $apiToken
|
38 |
-
* @param bool|int $level The minimum logging level at which this handler will be triggered
|
39 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
40 |
-
*
|
41 |
-
* @throws MissingExtensionException if OpenSSL is missing
|
42 |
-
*/
|
43 |
-
public function __construct($apiToken, $level = Logger::DEBUG, $bubble = true)
|
44 |
-
{
|
45 |
-
if (!extension_loaded('openssl')) {
|
46 |
-
throw new MissingExtensionException('The OpenSSL PHP extension is required to use the FlowdockHandler');
|
47 |
-
}
|
48 |
-
|
49 |
-
parent::__construct('ssl://api.flowdock.com:443', $level, $bubble);
|
50 |
-
$this->apiToken = $apiToken;
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* {@inheritdoc}
|
55 |
-
*/
|
56 |
-
public function setFormatter(FormatterInterface $formatter)
|
57 |
-
{
|
58 |
-
if (!$formatter instanceof FlowdockFormatter) {
|
59 |
-
throw new \InvalidArgumentException('The FlowdockHandler requires an instance of Monolog\Formatter\FlowdockFormatter to function correctly');
|
60 |
-
}
|
61 |
-
|
62 |
-
return parent::setFormatter($formatter);
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Gets the default formatter.
|
67 |
-
*
|
68 |
-
* @return FormatterInterface
|
69 |
-
*/
|
70 |
-
protected function getDefaultFormatter()
|
71 |
-
{
|
72 |
-
throw new \InvalidArgumentException('The FlowdockHandler must be configured (via setFormatter) with an instance of Monolog\Formatter\FlowdockFormatter to function correctly');
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* {@inheritdoc}
|
77 |
-
*
|
78 |
-
* @param array $record
|
79 |
-
*/
|
80 |
-
protected function write(array $record)
|
81 |
-
{
|
82 |
-
parent::write($record);
|
83 |
-
|
84 |
-
$this->closeSocket();
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* {@inheritdoc}
|
89 |
-
*
|
90 |
-
* @param array $record
|
91 |
-
* @return string
|
92 |
-
*/
|
93 |
-
protected function generateDataStream($record)
|
94 |
-
{
|
95 |
-
$content = $this->buildContent($record);
|
96 |
-
|
97 |
-
return $this->buildHeader($content) . $content;
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Builds the body of API call
|
102 |
-
*
|
103 |
-
* @param array $record
|
104 |
-
* @return string
|
105 |
-
*/
|
106 |
-
private function buildContent($record)
|
107 |
-
{
|
108 |
-
return json_encode($record['formatted']['flowdock']);
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* Builds the header of the API Call
|
113 |
-
*
|
114 |
-
* @param string $content
|
115 |
-
* @return string
|
116 |
-
*/
|
117 |
-
private function buildHeader($content)
|
118 |
-
{
|
119 |
-
$header = "POST /v1/messages/team_inbox/" . $this->apiToken . " HTTP/1.1\r\n";
|
120 |
-
$header .= "Host: api.flowdock.com\r\n";
|
121 |
-
$header .= "Content-Type: application/json\r\n";
|
122 |
-
$header .= "Content-Length: " . strlen($content) . "\r\n";
|
123 |
-
$header .= "\r\n";
|
124 |
-
|
125 |
-
return $header;
|
126 |
-
}
|
127 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerInterface.php
DELETED
@@ -1,39 +0,0 @@
|
|
1 |
-
<?php declare(strict_types=1);
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\FormatterInterface;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Interface to describe loggers that have a formatter
|
18 |
-
*
|
19 |
-
* This interface is present in monolog 1.x to ease forward compatibility.
|
20 |
-
*
|
21 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
22 |
-
*/
|
23 |
-
interface FormattableHandlerInterface
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* Sets the formatter.
|
27 |
-
*
|
28 |
-
* @param FormatterInterface $formatter
|
29 |
-
* @return HandlerInterface self
|
30 |
-
*/
|
31 |
-
public function setFormatter(FormatterInterface $formatter): HandlerInterface;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Gets the formatter.
|
35 |
-
*
|
36 |
-
* @return FormatterInterface
|
37 |
-
*/
|
38 |
-
public function getFormatter(): FormatterInterface;
|
39 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerTrait.php
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
<?php declare(strict_types=1);
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\FormatterInterface;
|
15 |
-
use Monolog\Formatter\LineFormatter;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Helper trait for implementing FormattableInterface
|
19 |
-
*
|
20 |
-
* This trait is present in monolog 1.x to ease forward compatibility.
|
21 |
-
*
|
22 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
23 |
-
*/
|
24 |
-
trait FormattableHandlerTrait
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* @var FormatterInterface
|
28 |
-
*/
|
29 |
-
protected $formatter;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* {@inheritdoc}
|
33 |
-
* @suppress PhanTypeMismatchReturn
|
34 |
-
*/
|
35 |
-
public function setFormatter(FormatterInterface $formatter): HandlerInterface
|
36 |
-
{
|
37 |
-
$this->formatter = $formatter;
|
38 |
-
|
39 |
-
return $this;
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* {@inheritdoc}
|
44 |
-
*/
|
45 |
-
public function getFormatter(): FormatterInterface
|
46 |
-
{
|
47 |
-
if (!$this->formatter) {
|
48 |
-
$this->formatter = $this->getDefaultFormatter();
|
49 |
-
}
|
50 |
-
|
51 |
-
return $this->formatter;
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Gets the default formatter.
|
56 |
-
*
|
57 |
-
* Overwrite this if the LineFormatter is not a good default for your handler.
|
58 |
-
*/
|
59 |
-
protected function getDefaultFormatter(): FormatterInterface
|
60 |
-
{
|
61 |
-
return new LineFormatter();
|
62 |
-
}
|
63 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php
DELETED
@@ -1,65 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Gelf\IMessagePublisher;
|
15 |
-
use Gelf\PublisherInterface;
|
16 |
-
use Gelf\Publisher;
|
17 |
-
use InvalidArgumentException;
|
18 |
-
use Monolog\Logger;
|
19 |
-
use Monolog\Formatter\GelfMessageFormatter;
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Handler to send messages to a Graylog2 (http://www.graylog2.org) server
|
23 |
-
*
|
24 |
-
* @author Matt Lehner <mlehner@gmail.com>
|
25 |
-
* @author Benjamin Zikarsky <benjamin@zikarsky.de>
|
26 |
-
*/
|
27 |
-
class GelfHandler extends AbstractProcessingHandler
|
28 |
-
{
|
29 |
-
/**
|
30 |
-
* @var Publisher the publisher object that sends the message to the server
|
31 |
-
*/
|
32 |
-
protected $publisher;
|
33 |
-
|
34 |
-
/**
|
35 |
-
* @param PublisherInterface|IMessagePublisher|Publisher $publisher a publisher object
|
36 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
37 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
38 |
-
*/
|
39 |
-
public function __construct($publisher, $level = Logger::DEBUG, $bubble = true)
|
40 |
-
{
|
41 |
-
parent::__construct($level, $bubble);
|
42 |
-
|
43 |
-
if (!$publisher instanceof Publisher && !$publisher instanceof IMessagePublisher && !$publisher instanceof PublisherInterface) {
|
44 |
-
throw new InvalidArgumentException('Invalid publisher, expected a Gelf\Publisher, Gelf\IMessagePublisher or Gelf\PublisherInterface instance');
|
45 |
-
}
|
46 |
-
|
47 |
-
$this->publisher = $publisher;
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* {@inheritdoc}
|
52 |
-
*/
|
53 |
-
protected function write(array $record)
|
54 |
-
{
|
55 |
-
$this->publisher->publish($record['formatted']);
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* {@inheritDoc}
|
60 |
-
*/
|
61 |
-
protected function getDefaultFormatter()
|
62 |
-
{
|
63 |
-
return new GelfMessageFormatter();
|
64 |
-
}
|
65 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php
DELETED
@@ -1,117 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\FormatterInterface;
|
15 |
-
use Monolog\ResettableInterface;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Forwards records to multiple handlers
|
19 |
-
*
|
20 |
-
* @author Lenar Lõhmus <lenar@city.ee>
|
21 |
-
*/
|
22 |
-
class GroupHandler extends AbstractHandler
|
23 |
-
{
|
24 |
-
protected $handlers;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @param array $handlers Array of Handlers.
|
28 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
29 |
-
*/
|
30 |
-
public function __construct(array $handlers, $bubble = true)
|
31 |
-
{
|
32 |
-
foreach ($handlers as $handler) {
|
33 |
-
if (!$handler instanceof HandlerInterface) {
|
34 |
-
throw new \InvalidArgumentException('The first argument of the GroupHandler must be an array of HandlerInterface instances.');
|
35 |
-
}
|
36 |
-
}
|
37 |
-
|
38 |
-
$this->handlers = $handlers;
|
39 |
-
$this->bubble = $bubble;
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* {@inheritdoc}
|
44 |
-
*/
|
45 |
-
public function isHandling(array $record)
|
46 |
-
{
|
47 |
-
foreach ($this->handlers as $handler) {
|
48 |
-
if ($handler->isHandling($record)) {
|
49 |
-
return true;
|
50 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
return false;
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* {@inheritdoc}
|
58 |
-
*/
|
59 |
-
public function handle(array $record)
|
60 |
-
{
|
61 |
-
if ($this->processors) {
|
62 |
-
foreach ($this->processors as $processor) {
|
63 |
-
$record = call_user_func($processor, $record);
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
foreach ($this->handlers as $handler) {
|
68 |
-
$handler->handle($record);
|
69 |
-
}
|
70 |
-
|
71 |
-
return false === $this->bubble;
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* {@inheritdoc}
|
76 |
-
*/
|
77 |
-
public function handleBatch(array $records)
|
78 |
-
{
|
79 |
-
if ($this->processors) {
|
80 |
-
$processed = array();
|
81 |
-
foreach ($records as $record) {
|
82 |
-
foreach ($this->processors as $processor) {
|
83 |
-
$record = call_user_func($processor, $record);
|
84 |
-
}
|
85 |
-
$processed[] = $record;
|
86 |
-
}
|
87 |
-
$records = $processed;
|
88 |
-
}
|
89 |
-
|
90 |
-
foreach ($this->handlers as $handler) {
|
91 |
-
$handler->handleBatch($records);
|
92 |
-
}
|
93 |
-
}
|
94 |
-
|
95 |
-
public function reset()
|
96 |
-
{
|
97 |
-
parent::reset();
|
98 |
-
|
99 |
-
foreach ($this->handlers as $handler) {
|
100 |
-
if ($handler instanceof ResettableInterface) {
|
101 |
-
$handler->reset();
|
102 |
-
}
|
103 |
-
}
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* {@inheritdoc}
|
108 |
-
*/
|
109 |
-
public function setFormatter(FormatterInterface $formatter)
|
110 |
-
{
|
111 |
-
foreach ($this->handlers as $handler) {
|
112 |
-
$handler->setFormatter($formatter);
|
113 |
-
}
|
114 |
-
|
115 |
-
return $this;
|
116 |
-
}
|
117 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php
DELETED
@@ -1,90 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\FormatterInterface;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Interface that all Monolog Handlers must implement
|
18 |
-
*
|
19 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
20 |
-
*/
|
21 |
-
interface HandlerInterface
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* Checks whether the given record will be handled by this handler.
|
25 |
-
*
|
26 |
-
* This is mostly done for performance reasons, to avoid calling processors for nothing.
|
27 |
-
*
|
28 |
-
* Handlers should still check the record levels within handle(), returning false in isHandling()
|
29 |
-
* is no guarantee that handle() will not be called, and isHandling() might not be called
|
30 |
-
* for a given record.
|
31 |
-
*
|
32 |
-
* @param array $record Partial log record containing only a level key
|
33 |
-
*
|
34 |
-
* @return bool
|
35 |
-
*/
|
36 |
-
public function isHandling(array $record);
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Handles a record.
|
40 |
-
*
|
41 |
-
* All records may be passed to this method, and the handler should discard
|
42 |
-
* those that it does not want to handle.
|
43 |
-
*
|
44 |
-
* The return value of this function controls the bubbling process of the handler stack.
|
45 |
-
* Unless the bubbling is interrupted (by returning true), the Logger class will keep on
|
46 |
-
* calling further handlers in the stack with a given log record.
|
47 |
-
*
|
48 |
-
* @param array $record The record to handle
|
49 |
-
* @return bool true means that this handler handled the record, and that bubbling is not permitted.
|
50 |
-
* false means the record was either not processed or that this handler allows bubbling.
|
51 |
-
*/
|
52 |
-
public function handle(array $record);
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Handles a set of records at once.
|
56 |
-
*
|
57 |
-
* @param array $records The records to handle (an array of record arrays)
|
58 |
-
*/
|
59 |
-
public function handleBatch(array $records);
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Adds a processor in the stack.
|
63 |
-
*
|
64 |
-
* @param callable $callback
|
65 |
-
* @return self
|
66 |
-
*/
|
67 |
-
public function pushProcessor($callback);
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Removes the processor on top of the stack and returns it.
|
71 |
-
*
|
72 |
-
* @return callable
|
73 |
-
*/
|
74 |
-
public function popProcessor();
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Sets the formatter.
|
78 |
-
*
|
79 |
-
* @param FormatterInterface $formatter
|
80 |
-
* @return self
|
81 |
-
*/
|
82 |
-
public function setFormatter(FormatterInterface $formatter);
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Gets the formatter.
|
86 |
-
*
|
87 |
-
* @return FormatterInterface
|
88 |
-
*/
|
89 |
-
public function getFormatter();
|
90 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php
DELETED
@@ -1,116 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\ResettableInterface;
|
15 |
-
use Monolog\Formatter\FormatterInterface;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* This simple wrapper class can be used to extend handlers functionality.
|
19 |
-
*
|
20 |
-
* Example: A custom filtering that can be applied to any handler.
|
21 |
-
*
|
22 |
-
* Inherit from this class and override handle() like this:
|
23 |
-
*
|
24 |
-
* public function handle(array $record)
|
25 |
-
* {
|
26 |
-
* if ($record meets certain conditions) {
|
27 |
-
* return false;
|
28 |
-
* }
|
29 |
-
* return $this->handler->handle($record);
|
30 |
-
* }
|
31 |
-
*
|
32 |
-
* @author Alexey Karapetov <alexey@karapetov.com>
|
33 |
-
*/
|
34 |
-
class HandlerWrapper implements HandlerInterface, ResettableInterface
|
35 |
-
{
|
36 |
-
/**
|
37 |
-
* @var HandlerInterface
|
38 |
-
*/
|
39 |
-
protected $handler;
|
40 |
-
|
41 |
-
/**
|
42 |
-
* HandlerWrapper constructor.
|
43 |
-
* @param HandlerInterface $handler
|
44 |
-
*/
|
45 |
-
public function __construct(HandlerInterface $handler)
|
46 |
-
{
|
47 |
-
$this->handler = $handler;
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* {@inheritdoc}
|
52 |
-
*/
|
53 |
-
public function isHandling(array $record)
|
54 |
-
{
|
55 |
-
return $this->handler->isHandling($record);
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* {@inheritdoc}
|
60 |
-
*/
|
61 |
-
public function handle(array $record)
|
62 |
-
{
|
63 |
-
return $this->handler->handle($record);
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* {@inheritdoc}
|
68 |
-
*/
|
69 |
-
public function handleBatch(array $records)
|
70 |
-
{
|
71 |
-
return $this->handler->handleBatch($records);
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* {@inheritdoc}
|
76 |
-
*/
|
77 |
-
public function pushProcessor($callback)
|
78 |
-
{
|
79 |
-
$this->handler->pushProcessor($callback);
|
80 |
-
|
81 |
-
return $this;
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* {@inheritdoc}
|
86 |
-
*/
|
87 |
-
public function popProcessor()
|
88 |
-
{
|
89 |
-
return $this->handler->popProcessor();
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* {@inheritdoc}
|
94 |
-
*/
|
95 |
-
public function setFormatter(FormatterInterface $formatter)
|
96 |
-
{
|
97 |
-
$this->handler->setFormatter($formatter);
|
98 |
-
|
99 |
-
return $this;
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* {@inheritdoc}
|
104 |
-
*/
|
105 |
-
public function getFormatter()
|
106 |
-
{
|
107 |
-
return $this->handler->getFormatter();
|
108 |
-
}
|
109 |
-
|
110 |
-
public function reset()
|
111 |
-
{
|
112 |
-
if ($this->handler instanceof ResettableInterface) {
|
113 |
-
return $this->handler->reset();
|
114 |
-
}
|
115 |
-
}
|
116 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php
DELETED
@@ -1,367 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Sends notifications through the hipchat api to a hipchat room
|
18 |
-
*
|
19 |
-
* Notes:
|
20 |
-
* API token - HipChat API token
|
21 |
-
* Room - HipChat Room Id or name, where messages are sent
|
22 |
-
* Name - Name used to send the message (from)
|
23 |
-
* notify - Should the message trigger a notification in the clients
|
24 |
-
* version - The API version to use (HipChatHandler::API_V1 | HipChatHandler::API_V2)
|
25 |
-
*
|
26 |
-
* @author Rafael Dohms <rafael@doh.ms>
|
27 |
-
* @see https://www.hipchat.com/docs/api
|
28 |
-
*/
|
29 |
-
class HipChatHandler extends SocketHandler
|
30 |
-
{
|
31 |
-
/**
|
32 |
-
* Use API version 1
|
33 |
-
*/
|
34 |
-
const API_V1 = 'v1';
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Use API version v2
|
38 |
-
*/
|
39 |
-
const API_V2 = 'v2';
|
40 |
-
|
41 |
-
/**
|
42 |
-
* The maximum allowed length for the name used in the "from" field.
|
43 |
-
*/
|
44 |
-
const MAXIMUM_NAME_LENGTH = 15;
|
45 |
-
|
46 |
-
/**
|
47 |
-
* The maximum allowed length for the message.
|
48 |
-
*/
|
49 |
-
const MAXIMUM_MESSAGE_LENGTH = 9500;
|
50 |
-
|
51 |
-
/**
|
52 |
-
* @var string
|
53 |
-
*/
|
54 |
-
private $token;
|
55 |
-
|
56 |
-
/**
|
57 |
-
* @var string
|
58 |
-
*/
|
59 |
-
private $room;
|
60 |
-
|
61 |
-
/**
|
62 |
-
* @var string
|
63 |
-
*/
|
64 |
-
private $name;
|
65 |
-
|
66 |
-
/**
|
67 |
-
* @var bool
|
68 |
-
*/
|
69 |
-
private $notify;
|
70 |
-
|
71 |
-
/**
|
72 |
-
* @var string
|
73 |
-
*/
|
74 |
-
private $format;
|
75 |
-
|
76 |
-
/**
|
77 |
-
* @var string
|
78 |
-
*/
|
79 |
-
private $host;
|
80 |
-
|
81 |
-
/**
|
82 |
-
* @var string
|
83 |
-
*/
|
84 |
-
private $version;
|
85 |
-
|
86 |
-
/**
|
87 |
-
* @param string $token HipChat API Token
|
88 |
-
* @param string $room The room that should be alerted of the message (Id or Name)
|
89 |
-
* @param string $name Name used in the "from" field.
|
90 |
-
* @param bool $notify Trigger a notification in clients or not
|
91 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
92 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
93 |
-
* @param bool $useSSL Whether to connect via SSL.
|
94 |
-
* @param string $format The format of the messages (default to text, can be set to html if you have html in the messages)
|
95 |
-
* @param string $host The HipChat server hostname.
|
96 |
-
* @param string $version The HipChat API version (default HipChatHandler::API_V1)
|
97 |
-
*/
|
98 |
-
public function __construct($token, $room, $name = 'Monolog', $notify = false, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $format = 'text', $host = 'api.hipchat.com', $version = self::API_V1)
|
99 |
-
{
|
100 |
-
@trigger_error('The Monolog\Handler\HipChatHandler class is deprecated. You should migrate to Slack and the SlackWebhookHandler / SlackbotHandler, see https://www.atlassian.com/partnerships/slack', E_USER_DEPRECATED);
|
101 |
-
|
102 |
-
if ($version == self::API_V1 && !$this->validateStringLength($name, static::MAXIMUM_NAME_LENGTH)) {
|
103 |
-
throw new \InvalidArgumentException('The supplied name is too long. HipChat\'s v1 API supports names up to 15 UTF-8 characters.');
|
104 |
-
}
|
105 |
-
|
106 |
-
$connectionString = $useSSL ? 'ssl://'.$host.':443' : $host.':80';
|
107 |
-
parent::__construct($connectionString, $level, $bubble);
|
108 |
-
|
109 |
-
$this->token = $token;
|
110 |
-
$this->name = $name;
|
111 |
-
$this->notify = $notify;
|
112 |
-
$this->room = $room;
|
113 |
-
$this->format = $format;
|
114 |
-
$this->host = $host;
|
115 |
-
$this->version = $version;
|
116 |
-
}
|
117 |
-
|
118 |
-
/**
|
119 |
-
* {@inheritdoc}
|
120 |
-
*
|
121 |
-
* @param array $record
|
122 |
-
* @return string
|
123 |
-
*/
|
124 |
-
protected function generateDataStream($record)
|
125 |
-
{
|
126 |
-
$content = $this->buildContent($record);
|
127 |
-
|
128 |
-
return $this->buildHeader($content) . $content;
|
129 |
-
}
|
130 |
-
|
131 |
-
/**
|
132 |
-
* Builds the body of API call
|
133 |
-
*
|
134 |
-
* @param array $record
|
135 |
-
* @return string
|
136 |
-
*/
|
137 |
-
private function buildContent($record)
|
138 |
-
{
|
139 |
-
$dataArray = array(
|
140 |
-
'notify' => $this->version == self::API_V1 ?
|
141 |
-
($this->notify ? 1 : 0) :
|
142 |
-
($this->notify ? 'true' : 'false'),
|
143 |
-
'message' => $record['formatted'],
|
144 |
-
'message_format' => $this->format,
|
145 |
-
'color' => $this->getAlertColor($record['level']),
|
146 |
-
);
|
147 |
-
|
148 |
-
if (!$this->validateStringLength($dataArray['message'], static::MAXIMUM_MESSAGE_LENGTH)) {
|
149 |
-
if (function_exists('mb_substr')) {
|
150 |
-
$dataArray['message'] = mb_substr($dataArray['message'], 0, static::MAXIMUM_MESSAGE_LENGTH).' [truncated]';
|
151 |
-
} else {
|
152 |
-
$dataArray['message'] = substr($dataArray['message'], 0, static::MAXIMUM_MESSAGE_LENGTH).' [truncated]';
|
153 |
-
}
|
154 |
-
}
|
155 |
-
|
156 |
-
// if we are using the legacy API then we need to send some additional information
|
157 |
-
if ($this->version == self::API_V1) {
|
158 |
-
$dataArray['room_id'] = $this->room;
|
159 |
-
}
|
160 |
-
|
161 |
-
// append the sender name if it is set
|
162 |
-
// always append it if we use the v1 api (it is required in v1)
|
163 |
-
if ($this->version == self::API_V1 || $this->name !== null) {
|
164 |
-
$dataArray['from'] = (string) $this->name;
|
165 |
-
}
|
166 |
-
|
167 |
-
return http_build_query($dataArray);
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Builds the header of the API Call
|
172 |
-
*
|
173 |
-
* @param string $content
|
174 |
-
* @return string
|
175 |
-
*/
|
176 |
-
private function buildHeader($content)
|
177 |
-
{
|
178 |
-
if ($this->version == self::API_V1) {
|
179 |
-
$header = "POST /v1/rooms/message?format=json&auth_token={$this->token} HTTP/1.1\r\n";
|
180 |
-
} else {
|
181 |
-
// needed for rooms with special (spaces, etc) characters in the name
|
182 |
-
$room = rawurlencode($this->room);
|
183 |
-
$header = "POST /v2/room/{$room}/notification?auth_token={$this->token} HTTP/1.1\r\n";
|
184 |
-
}
|
185 |
-
|
186 |
-
$header .= "Host: {$this->host}\r\n";
|
187 |
-
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
188 |
-
$header .= "Content-Length: " . strlen($content) . "\r\n";
|
189 |
-
$header .= "\r\n";
|
190 |
-
|
191 |
-
return $header;
|
192 |
-
}
|
193 |
-
|
194 |
-
/**
|
195 |
-
* Assigns a color to each level of log records.
|
196 |
-
*
|
197 |
-
* @param int $level
|
198 |
-
* @return string
|
199 |
-
*/
|
200 |
-
protected function getAlertColor($level)
|
201 |
-
{
|
202 |
-
switch (true) {
|
203 |
-
case $level >= Logger::ERROR:
|
204 |
-
return 'red';
|
205 |
-
case $level >= Logger::WARNING:
|
206 |
-
return 'yellow';
|
207 |
-
case $level >= Logger::INFO:
|
208 |
-
return 'green';
|
209 |
-
case $level == Logger::DEBUG:
|
210 |
-
return 'gray';
|
211 |
-
default:
|
212 |
-
return 'yellow';
|
213 |
-
}
|
214 |
-
}
|
215 |
-
|
216 |
-
/**
|
217 |
-
* {@inheritdoc}
|
218 |
-
*
|
219 |
-
* @param array $record
|
220 |
-
*/
|
221 |
-
protected function write(array $record)
|
222 |
-
{
|
223 |
-
parent::write($record);
|
224 |
-
$this->finalizeWrite();
|
225 |
-
}
|
226 |
-
|
227 |
-
/**
|
228 |
-
* Finalizes the request by reading some bytes and then closing the socket
|
229 |
-
*
|
230 |
-
* If we do not read some but close the socket too early, hipchat sometimes
|
231 |
-
* drops the request entirely.
|
232 |
-
*/
|
233 |
-
protected function finalizeWrite()
|
234 |
-
{
|
235 |
-
$res = $this->getResource();
|
236 |
-
if (is_resource($res)) {
|
237 |
-
@fread($res, 2048);
|
238 |
-
}
|
239 |
-
$this->closeSocket();
|
240 |
-
}
|
241 |
-
|
242 |
-
/**
|
243 |
-
* {@inheritdoc}
|
244 |
-
*/
|
245 |
-
public function handleBatch(array $records)
|
246 |
-
{
|
247 |
-
if (count($records) == 0) {
|
248 |
-
return true;
|
249 |
-
}
|
250 |
-
|
251 |
-
$batchRecords = $this->combineRecords($records);
|
252 |
-
|
253 |
-
$handled = false;
|
254 |
-
foreach ($batchRecords as $batchRecord) {
|
255 |
-
if ($this->isHandling($batchRecord)) {
|
256 |
-
$this->write($batchRecord);
|
257 |
-
$handled = true;
|
258 |
-
}
|
259 |
-
}
|
260 |
-
|
261 |
-
if (!$handled) {
|
262 |
-
return false;
|
263 |
-
}
|
264 |
-
|
265 |
-
return false === $this->bubble;
|
266 |
-
}
|
267 |
-
|
268 |
-
/**
|
269 |
-
* Combines multiple records into one. Error level of the combined record
|
270 |
-
* will be the highest level from the given records. Datetime will be taken
|
271 |
-
* from the first record.
|
272 |
-
*
|
273 |
-
* @param $records
|
274 |
-
* @return array
|
275 |
-
*/
|
276 |
-
private function combineRecords($records)
|
277 |
-
{
|
278 |
-
$batchRecord = null;
|
279 |
-
$batchRecords = array();
|
280 |
-
$messages = array();
|
281 |
-
$formattedMessages = array();
|
282 |
-
$level = 0;
|
283 |
-
$levelName = null;
|
284 |
-
$datetime = null;
|
285 |
-
|
286 |
-
foreach ($records as $record) {
|
287 |
-
$record = $this->processRecord($record);
|
288 |
-
|
289 |
-
if ($record['level'] > $level) {
|
290 |
-
$level = $record['level'];
|
291 |
-
$levelName = $record['level_name'];
|
292 |
-
}
|
293 |
-
|
294 |
-
if (null === $datetime) {
|
295 |
-
$datetime = $record['datetime'];
|
296 |
-
}
|
297 |
-
|
298 |
-
$messages[] = $record['message'];
|
299 |
-
$messageStr = implode(PHP_EOL, $messages);
|
300 |
-
$formattedMessages[] = $this->getFormatter()->format($record);
|
301 |
-
$formattedMessageStr = implode('', $formattedMessages);
|
302 |
-
|
303 |
-
$batchRecord = array(
|
304 |
-
'message' => $messageStr,
|
305 |
-
'formatted' => $formattedMessageStr,
|
306 |
-
'context' => array(),
|
307 |
-
'extra' => array(),
|
308 |
-
);
|
309 |
-
|
310 |
-
if (!$this->validateStringLength($batchRecord['formatted'], static::MAXIMUM_MESSAGE_LENGTH)) {
|
311 |
-
// Pop the last message and implode the remaining messages
|
312 |
-
$lastMessage = array_pop($messages);
|
313 |
-
$lastFormattedMessage = array_pop($formattedMessages);
|
314 |
-
$batchRecord['message'] = implode(PHP_EOL, $messages);
|
315 |
-
$batchRecord['formatted'] = implode('', $formattedMessages);
|
316 |
-
|
317 |
-
$batchRecords[] = $batchRecord;
|
318 |
-
$messages = array($lastMessage);
|
319 |
-
$formattedMessages = array($lastFormattedMessage);
|
320 |
-
|
321 |
-
$batchRecord = null;
|
322 |
-
}
|
323 |
-
}
|
324 |
-
|
325 |
-
if (null !== $batchRecord) {
|
326 |
-
$batchRecords[] = $batchRecord;
|
327 |
-
}
|
328 |
-
|
329 |
-
// Set the max level and datetime for all records
|
330 |
-
foreach ($batchRecords as &$batchRecord) {
|
331 |
-
$batchRecord = array_merge(
|
332 |
-
$batchRecord,
|
333 |
-
array(
|
334 |
-
'level' => $level,
|
335 |
-
'level_name' => $levelName,
|
336 |
-
'datetime' => $datetime,
|
337 |
-
)
|
338 |
-
);
|
339 |
-
}
|
340 |
-
|
341 |
-
return $batchRecords;
|
342 |
-
}
|
343 |
-
|
344 |
-
/**
|
345 |
-
* Validates the length of a string.
|
346 |
-
*
|
347 |
-
* If the `mb_strlen()` function is available, it will use that, as HipChat
|
348 |
-
* allows UTF-8 characters. Otherwise, it will fall back to `strlen()`.
|
349 |
-
*
|
350 |
-
* Note that this might cause false failures in the specific case of using
|
351 |
-
* a valid name with less than 16 characters, but 16 or more bytes, on a
|
352 |
-
* system where `mb_strlen()` is unavailable.
|
353 |
-
*
|
354 |
-
* @param string $str
|
355 |
-
* @param int $length
|
356 |
-
*
|
357 |
-
* @return bool
|
358 |
-
*/
|
359 |
-
private function validateStringLength($str, $length)
|
360 |
-
{
|
361 |
-
if (function_exists('mb_strlen')) {
|
362 |
-
return (mb_strlen($str) <= $length);
|
363 |
-
}
|
364 |
-
|
365 |
-
return (strlen($str) <= $length);
|
366 |
-
}
|
367 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php
DELETED
@@ -1,69 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* IFTTTHandler uses cURL to trigger IFTTT Maker actions
|
18 |
-
*
|
19 |
-
* Register a secret key and trigger/event name at https://ifttt.com/maker
|
20 |
-
*
|
21 |
-
* value1 will be the channel from monolog's Logger constructor,
|
22 |
-
* value2 will be the level name (ERROR, WARNING, ..)
|
23 |
-
* value3 will be the log record's message
|
24 |
-
*
|
25 |
-
* @author Nehal Patel <nehal@nehalpatel.me>
|
26 |
-
*/
|
27 |
-
class IFTTTHandler extends AbstractProcessingHandler
|
28 |
-
{
|
29 |
-
private $eventName;
|
30 |
-
private $secretKey;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @param string $eventName The name of the IFTTT Maker event that should be triggered
|
34 |
-
* @param string $secretKey A valid IFTTT secret key
|
35 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
36 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
37 |
-
*/
|
38 |
-
public function __construct($eventName, $secretKey, $level = Logger::ERROR, $bubble = true)
|
39 |
-
{
|
40 |
-
$this->eventName = $eventName;
|
41 |
-
$this->secretKey = $secretKey;
|
42 |
-
|
43 |
-
parent::__construct($level, $bubble);
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* {@inheritdoc}
|
48 |
-
*/
|
49 |
-
public function write(array $record)
|
50 |
-
{
|
51 |
-
$postData = array(
|
52 |
-
"value1" => $record["channel"],
|
53 |
-
"value2" => $record["level_name"],
|
54 |
-
"value3" => $record["message"],
|
55 |
-
);
|
56 |
-
$postString = json_encode($postData);
|
57 |
-
|
58 |
-
$ch = curl_init();
|
59 |
-
curl_setopt($ch, CURLOPT_URL, "https://maker.ifttt.com/trigger/" . $this->eventName . "/with/key/" . $this->secretKey);
|
60 |
-
curl_setopt($ch, CURLOPT_POST, true);
|
61 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
62 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
|
63 |
-
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
64 |
-
"Content-Type: application/json",
|
65 |
-
));
|
66 |
-
|
67 |
-
Curl\Util::execute($ch);
|
68 |
-
}
|
69 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/InsightOpsHandler.php
DELETED
@@ -1,62 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Inspired on LogEntriesHandler.
|
18 |
-
*
|
19 |
-
* @author Robert Kaufmann III <rok3@rok3.me>
|
20 |
-
* @author Gabriel Machado <gabriel.ms1@hotmail.com>
|
21 |
-
*/
|
22 |
-
class InsightOpsHandler extends SocketHandler
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* @var string
|
26 |
-
*/
|
27 |
-
protected $logToken;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @param string $token Log token supplied by InsightOps
|
31 |
-
* @param string $region Region where InsightOps account is hosted. Could be 'us' or 'eu'.
|
32 |
-
* @param bool $useSSL Whether or not SSL encryption should be used
|
33 |
-
* @param int $level The minimum logging level to trigger this handler
|
34 |
-
* @param bool $bubble Whether or not messages that are handled should bubble up the stack.
|
35 |
-
*
|
36 |
-
* @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing
|
37 |
-
*/
|
38 |
-
public function __construct($token, $region = 'us', $useSSL = true, $level = Logger::DEBUG, $bubble = true)
|
39 |
-
{
|
40 |
-
if ($useSSL && !extension_loaded('openssl')) {
|
41 |
-
throw new MissingExtensionException('The OpenSSL PHP plugin is required to use SSL encrypted connection for InsightOpsHandler');
|
42 |
-
}
|
43 |
-
|
44 |
-
$endpoint = $useSSL
|
45 |
-
? 'ssl://' . $region . '.data.logs.insight.rapid7.com:443'
|
46 |
-
: $region . '.data.logs.insight.rapid7.com:80';
|
47 |
-
|
48 |
-
parent::__construct($endpoint, $level, $bubble);
|
49 |
-
$this->logToken = $token;
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* {@inheritdoc}
|
54 |
-
*
|
55 |
-
* @param array $record
|
56 |
-
* @return string
|
57 |
-
*/
|
58 |
-
protected function generateDataStream($record)
|
59 |
-
{
|
60 |
-
return $this->logToken . ' ' . $record['formatted'];
|
61 |
-
}
|
62 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* @author Robert Kaufmann III <rok3@rok3.me>
|
18 |
-
*/
|
19 |
-
class LogEntriesHandler extends SocketHandler
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* @var string
|
23 |
-
*/
|
24 |
-
protected $logToken;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @param string $token Log token supplied by LogEntries
|
28 |
-
* @param bool $useSSL Whether or not SSL encryption should be used.
|
29 |
-
* @param int $level The minimum logging level to trigger this handler
|
30 |
-
* @param bool $bubble Whether or not messages that are handled should bubble up the stack.
|
31 |
-
*
|
32 |
-
* @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing
|
33 |
-
*/
|
34 |
-
public function __construct($token, $useSSL = true, $level = Logger::DEBUG, $bubble = true, $host = 'data.logentries.com')
|
35 |
-
{
|
36 |
-
if ($useSSL && !extension_loaded('openssl')) {
|
37 |
-
throw new MissingExtensionException('The OpenSSL PHP plugin is required to use SSL encrypted connection for LogEntriesHandler');
|
38 |
-
}
|
39 |
-
|
40 |
-
$endpoint = $useSSL ? 'ssl://' . $host . ':443' : $host . ':80';
|
41 |
-
parent::__construct($endpoint, $level, $bubble);
|
42 |
-
$this->logToken = $token;
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* {@inheritdoc}
|
47 |
-
*
|
48 |
-
* @param array $record
|
49 |
-
* @return string
|
50 |
-
*/
|
51 |
-
protected function generateDataStream($record)
|
52 |
-
{
|
53 |
-
return $this->logToken . ' ' . $record['formatted'];
|
54 |
-
}
|
55 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php
DELETED
@@ -1,102 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\Formatter\LogglyFormatter;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Sends errors to Loggly.
|
19 |
-
*
|
20 |
-
* @author Przemek Sobstel <przemek@sobstel.org>
|
21 |
-
* @author Adam Pancutt <adam@pancutt.com>
|
22 |
-
* @author Gregory Barchard <gregory@barchard.net>
|
23 |
-
*/
|
24 |
-
class LogglyHandler extends AbstractProcessingHandler
|
25 |
-
{
|
26 |
-
const HOST = 'logs-01.loggly.com';
|
27 |
-
const ENDPOINT_SINGLE = 'inputs';
|
28 |
-
const ENDPOINT_BATCH = 'bulk';
|
29 |
-
|
30 |
-
protected $token;
|
31 |
-
|
32 |
-
protected $tag = array();
|
33 |
-
|
34 |
-
public function __construct($token, $level = Logger::DEBUG, $bubble = true)
|
35 |
-
{
|
36 |
-
if (!extension_loaded('curl')) {
|
37 |
-
throw new \LogicException('The curl extension is needed to use the LogglyHandler');
|
38 |
-
}
|
39 |
-
|
40 |
-
$this->token = $token;
|
41 |
-
|
42 |
-
parent::__construct($level, $bubble);
|
43 |
-
}
|
44 |
-
|
45 |
-
public function setTag($tag)
|
46 |
-
{
|
47 |
-
$tag = !empty($tag) ? $tag : array();
|
48 |
-
$this->tag = is_array($tag) ? $tag : array($tag);
|
49 |
-
}
|
50 |
-
|
51 |
-
public function addTag($tag)
|
52 |
-
{
|
53 |
-
if (!empty($tag)) {
|
54 |
-
$tag = is_array($tag) ? $tag : array($tag);
|
55 |
-
$this->tag = array_unique(array_merge($this->tag, $tag));
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
protected function write(array $record)
|
60 |
-
{
|
61 |
-
$this->send($record["formatted"], self::ENDPOINT_SINGLE);
|
62 |
-
}
|
63 |
-
|
64 |
-
public function handleBatch(array $records)
|
65 |
-
{
|
66 |
-
$level = $this->level;
|
67 |
-
|
68 |
-
$records = array_filter($records, function ($record) use ($level) {
|
69 |
-
return ($record['level'] >= $level);
|
70 |
-
});
|
71 |
-
|
72 |
-
if ($records) {
|
73 |
-
$this->send($this->getFormatter()->formatBatch($records), self::ENDPOINT_BATCH);
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
protected function send($data, $endpoint)
|
78 |
-
{
|
79 |
-
$url = sprintf("https://%s/%s/%s/", self::HOST, $endpoint, $this->token);
|
80 |
-
|
81 |
-
$headers = array('Content-Type: application/json');
|
82 |
-
|
83 |
-
if (!empty($this->tag)) {
|
84 |
-
$headers[] = 'X-LOGGLY-TAG: '.implode(',', $this->tag);
|
85 |
-
}
|
86 |
-
|
87 |
-
$ch = curl_init();
|
88 |
-
|
89 |
-
curl_setopt($ch, CURLOPT_URL, $url);
|
90 |
-
curl_setopt($ch, CURLOPT_POST, true);
|
91 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
92 |
-
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
93 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
94 |
-
|
95 |
-
Curl\Util::execute($ch);
|
96 |
-
}
|
97 |
-
|
98 |
-
protected function getDefaultFormatter()
|
99 |
-
{
|
100 |
-
return new LogglyFormatter();
|
101 |
-
}
|
102 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Base class for all mail handlers
|
16 |
-
*
|
17 |
-
* @author Gyula Sallai
|
18 |
-
*/
|
19 |
-
abstract class MailHandler extends AbstractProcessingHandler
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* {@inheritdoc}
|
23 |
-
*/
|
24 |
-
public function handleBatch(array $records)
|
25 |
-
{
|
26 |
-
$messages = array();
|
27 |
-
|
28 |
-
foreach ($records as $record) {
|
29 |
-
if ($record['level'] < $this->level) {
|
30 |
-
continue;
|
31 |
-
}
|
32 |
-
$messages[] = $this->processRecord($record);
|
33 |
-
}
|
34 |
-
|
35 |
-
if (!empty($messages)) {
|
36 |
-
$this->send((string) $this->getFormatter()->formatBatch($messages), $messages);
|
37 |
-
}
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Send a mail with the given content
|
42 |
-
*
|
43 |
-
* @param string $content formatted email body to be sent
|
44 |
-
* @param array $records the array of log records that formed this content
|
45 |
-
*/
|
46 |
-
abstract protected function send($content, array $records);
|
47 |
-
|
48 |
-
/**
|
49 |
-
* {@inheritdoc}
|
50 |
-
*/
|
51 |
-
protected function write(array $record)
|
52 |
-
{
|
53 |
-
$this->send((string) $record['formatted'], array($record));
|
54 |
-
}
|
55 |
-
|
56 |
-
protected function getHighestRecord(array $records)
|
57 |
-
{
|
58 |
-
$highestRecord = null;
|
59 |
-
foreach ($records as $record) {
|
60 |
-
if ($highestRecord === null || $highestRecord['level'] < $record['level']) {
|
61 |
-
$highestRecord = $record;
|
62 |
-
}
|
63 |
-
}
|
64 |
-
|
65 |
-
return $highestRecord;
|
66 |
-
}
|
67 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php
DELETED
@@ -1,68 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* MandrillHandler uses cURL to send the emails to the Mandrill API
|
18 |
-
*
|
19 |
-
* @author Adam Nicholson <adamnicholson10@gmail.com>
|
20 |
-
*/
|
21 |
-
class MandrillHandler extends MailHandler
|
22 |
-
{
|
23 |
-
protected $message;
|
24 |
-
protected $apiKey;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @param string $apiKey A valid Mandrill API key
|
28 |
-
* @param callable|\Swift_Message $message An example message for real messages, only the body will be replaced
|
29 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
30 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
31 |
-
*/
|
32 |
-
public function __construct($apiKey, $message, $level = Logger::ERROR, $bubble = true)
|
33 |
-
{
|
34 |
-
parent::__construct($level, $bubble);
|
35 |
-
|
36 |
-
if (!$message instanceof \Swift_Message && is_callable($message)) {
|
37 |
-
$message = call_user_func($message);
|
38 |
-
}
|
39 |
-
if (!$message instanceof \Swift_Message) {
|
40 |
-
throw new \InvalidArgumentException('You must provide either a Swift_Message instance or a callable returning it');
|
41 |
-
}
|
42 |
-
$this->message = $message;
|
43 |
-
$this->apiKey = $apiKey;
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* {@inheritdoc}
|
48 |
-
*/
|
49 |
-
protected function send($content, array $records)
|
50 |
-
{
|
51 |
-
$message = clone $this->message;
|
52 |
-
$message->setBody($content);
|
53 |
-
$message->setDate(time());
|
54 |
-
|
55 |
-
$ch = curl_init();
|
56 |
-
|
57 |
-
curl_setopt($ch, CURLOPT_URL, 'https://mandrillapp.com/api/1.0/messages/send-raw.json');
|
58 |
-
curl_setopt($ch, CURLOPT_POST, 1);
|
59 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
60 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
|
61 |
-
'key' => $this->apiKey,
|
62 |
-
'raw_message' => (string) $message,
|
63 |
-
'async' => false,
|
64 |
-
)));
|
65 |
-
|
66 |
-
Curl\Util::execute($ch);
|
67 |
-
}
|
68 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/MissingExtensionException.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Exception can be thrown if an extension for an handler is missing
|
16 |
-
*
|
17 |
-
* @author Christian Bergau <cbergau86@gmail.com>
|
18 |
-
*/
|
19 |
-
class MissingExtensionException extends \Exception
|
20 |
-
{
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php
DELETED
@@ -1,59 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\Formatter\NormalizerFormatter;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Logs to a MongoDB database.
|
19 |
-
*
|
20 |
-
* usage example:
|
21 |
-
*
|
22 |
-
* $log = new Logger('application');
|
23 |
-
* $mongodb = new MongoDBHandler(new \Mongo("mongodb://localhost:27017"), "logs", "prod");
|
24 |
-
* $log->pushHandler($mongodb);
|
25 |
-
*
|
26 |
-
* @author Thomas Tourlourat <thomas@tourlourat.com>
|
27 |
-
*/
|
28 |
-
class MongoDBHandler extends AbstractProcessingHandler
|
29 |
-
{
|
30 |
-
protected $mongoCollection;
|
31 |
-
|
32 |
-
public function __construct($mongo, $database, $collection, $level = Logger::DEBUG, $bubble = true)
|
33 |
-
{
|
34 |
-
if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo || $mongo instanceof \MongoDB\Client)) {
|
35 |
-
throw new \InvalidArgumentException('MongoClient, Mongo or MongoDB\Client instance required');
|
36 |
-
}
|
37 |
-
|
38 |
-
$this->mongoCollection = $mongo->selectCollection($database, $collection);
|
39 |
-
|
40 |
-
parent::__construct($level, $bubble);
|
41 |
-
}
|
42 |
-
|
43 |
-
protected function write(array $record)
|
44 |
-
{
|
45 |
-
if ($this->mongoCollection instanceof \MongoDB\Collection) {
|
46 |
-
$this->mongoCollection->insertOne($record["formatted"]);
|
47 |
-
} else {
|
48 |
-
$this->mongoCollection->save($record["formatted"]);
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* {@inheritDoc}
|
54 |
-
*/
|
55 |
-
protected function getDefaultFormatter()
|
56 |
-
{
|
57 |
-
return new NormalizerFormatter();
|
58 |
-
}
|
59 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php
DELETED
@@ -1,185 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\Formatter\LineFormatter;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* NativeMailerHandler uses the mail() function to send the emails
|
19 |
-
*
|
20 |
-
* @author Christophe Coevoet <stof@notk.org>
|
21 |
-
* @author Mark Garrett <mark@moderndeveloperllc.com>
|
22 |
-
*/
|
23 |
-
class NativeMailerHandler extends MailHandler
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* The email addresses to which the message will be sent
|
27 |
-
* @var array
|
28 |
-
*/
|
29 |
-
protected $to;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* The subject of the email
|
33 |
-
* @var string
|
34 |
-
*/
|
35 |
-
protected $subject;
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Optional headers for the message
|
39 |
-
* @var array
|
40 |
-
*/
|
41 |
-
protected $headers = array();
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Optional parameters for the message
|
45 |
-
* @var array
|
46 |
-
*/
|
47 |
-
protected $parameters = array();
|
48 |
-
|
49 |
-
/**
|
50 |
-
* The wordwrap length for the message
|
51 |
-
* @var int
|
52 |
-
*/
|
53 |
-
protected $maxColumnWidth;
|
54 |
-
|
55 |
-
/**
|
56 |
-
* The Content-type for the message
|
57 |
-
* @var string
|
58 |
-
*/
|
59 |
-
protected $contentType = 'text/plain';
|
60 |
-
|
61 |
-
/**
|
62 |
-
* The encoding for the message
|
63 |
-
* @var string
|
64 |
-
*/
|
65 |
-
protected $encoding = 'utf-8';
|
66 |
-
|
67 |
-
/**
|
68 |
-
* @param string|array $to The receiver of the mail
|
69 |
-
* @param string $subject The subject of the mail
|
70 |
-
* @param string $from The sender of the mail
|
71 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
72 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
73 |
-
* @param int $maxColumnWidth The maximum column width that the message lines will have
|
74 |
-
*/
|
75 |
-
public function __construct($to, $subject, $from, $level = Logger::ERROR, $bubble = true, $maxColumnWidth = 70)
|
76 |
-
{
|
77 |
-
parent::__construct($level, $bubble);
|
78 |
-
$this->to = is_array($to) ? $to : array($to);
|
79 |
-
$this->subject = $subject;
|
80 |
-
$this->addHeader(sprintf('From: %s', $from));
|
81 |
-
$this->maxColumnWidth = $maxColumnWidth;
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Add headers to the message
|
86 |
-
*
|
87 |
-
* @param string|array $headers Custom added headers
|
88 |
-
* @return self
|
89 |
-
*/
|
90 |
-
public function addHeader($headers)
|
91 |
-
{
|
92 |
-
foreach ((array) $headers as $header) {
|
93 |
-
if (strpos($header, "\n") !== false || strpos($header, "\r") !== false) {
|
94 |
-
throw new \InvalidArgumentException('Headers can not contain newline characters for security reasons');
|
95 |
-
}
|
96 |
-
$this->headers[] = $header;
|
97 |
-
}
|
98 |
-
|
99 |
-
return $this;
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Add parameters to the message
|
104 |
-
*
|
105 |
-
* @param string|array $parameters Custom added parameters
|
106 |
-
* @return self
|
107 |
-
*/
|
108 |
-
public function addParameter($parameters)
|
109 |
-
{
|
110 |
-
$this->parameters = array_merge($this->parameters, (array) $parameters);
|
111 |
-
|
112 |
-
return $this;
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* {@inheritdoc}
|
117 |
-
*/
|
118 |
-
protected function send($content, array $records)
|
119 |
-
{
|
120 |
-
$content = wordwrap($content, $this->maxColumnWidth);
|
121 |
-
$headers = ltrim(implode("\r\n", $this->headers) . "\r\n", "\r\n");
|
122 |
-
$headers .= 'Content-type: ' . $this->getContentType() . '; charset=' . $this->getEncoding() . "\r\n";
|
123 |
-
if ($this->getContentType() == 'text/html' && false === strpos($headers, 'MIME-Version:')) {
|
124 |
-
$headers .= 'MIME-Version: 1.0' . "\r\n";
|
125 |
-
}
|
126 |
-
|
127 |
-
$subject = $this->subject;
|
128 |
-
if ($records) {
|
129 |
-
$subjectFormatter = new LineFormatter($this->subject);
|
130 |
-
$subject = $subjectFormatter->format($this->getHighestRecord($records));
|
131 |
-
}
|
132 |
-
|
133 |
-
$parameters = implode(' ', $this->parameters);
|
134 |
-
foreach ($this->to as $to) {
|
135 |
-
mail($to, $subject, $content, $headers, $parameters);
|
136 |
-
}
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* @return string $contentType
|
141 |
-
*/
|
142 |
-
public function getContentType()
|
143 |
-
{
|
144 |
-
return $this->contentType;
|
145 |
-
}
|
146 |
-
|
147 |
-
/**
|
148 |
-
* @return string $encoding
|
149 |
-
*/
|
150 |
-
public function getEncoding()
|
151 |
-
{
|
152 |
-
return $this->encoding;
|
153 |
-
}
|
154 |
-
|
155 |
-
/**
|
156 |
-
* @param string $contentType The content type of the email - Defaults to text/plain. Use text/html for HTML
|
157 |
-
* messages.
|
158 |
-
* @return self
|
159 |
-
*/
|
160 |
-
public function setContentType($contentType)
|
161 |
-
{
|
162 |
-
if (strpos($contentType, "\n") !== false || strpos($contentType, "\r") !== false) {
|
163 |
-
throw new \InvalidArgumentException('The content type can not contain newline characters to prevent email header injection');
|
164 |
-
}
|
165 |
-
|
166 |
-
$this->contentType = $contentType;
|
167 |
-
|
168 |
-
return $this;
|
169 |
-
}
|
170 |
-
|
171 |
-
/**
|
172 |
-
* @param string $encoding
|
173 |
-
* @return self
|
174 |
-
*/
|
175 |
-
public function setEncoding($encoding)
|
176 |
-
{
|
177 |
-
if (strpos($encoding, "\n") !== false || strpos($encoding, "\r") !== false) {
|
178 |
-
throw new \InvalidArgumentException('The encoding can not contain newline characters to prevent email header injection');
|
179 |
-
}
|
180 |
-
|
181 |
-
$this->encoding = $encoding;
|
182 |
-
|
183 |
-
return $this;
|
184 |
-
}
|
185 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php
DELETED
@@ -1,204 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\Formatter\NormalizerFormatter;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Class to record a log on a NewRelic application.
|
19 |
-
* Enabling New Relic High Security mode may prevent capture of useful information.
|
20 |
-
*
|
21 |
-
* This handler requires a NormalizerFormatter to function and expects an array in $record['formatted']
|
22 |
-
*
|
23 |
-
* @see https://docs.newrelic.com/docs/agents/php-agent
|
24 |
-
* @see https://docs.newrelic.com/docs/accounts-partnerships/accounts/security/high-security
|
25 |
-
*/
|
26 |
-
class NewRelicHandler extends AbstractProcessingHandler
|
27 |
-
{
|
28 |
-
/**
|
29 |
-
* Name of the New Relic application that will receive logs from this handler.
|
30 |
-
*
|
31 |
-
* @var string
|
32 |
-
*/
|
33 |
-
protected $appName;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Name of the current transaction
|
37 |
-
*
|
38 |
-
* @var string
|
39 |
-
*/
|
40 |
-
protected $transactionName;
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Some context and extra data is passed into the handler as arrays of values. Do we send them as is
|
44 |
-
* (useful if we are using the API), or explode them for display on the NewRelic RPM website?
|
45 |
-
*
|
46 |
-
* @var bool
|
47 |
-
*/
|
48 |
-
protected $explodeArrays;
|
49 |
-
|
50 |
-
/**
|
51 |
-
* {@inheritDoc}
|
52 |
-
*
|
53 |
-
* @param string $appName
|
54 |
-
* @param bool $explodeArrays
|
55 |
-
* @param string $transactionName
|
56 |
-
*/
|
57 |
-
public function __construct(
|
58 |
-
$level = Logger::ERROR,
|
59 |
-
$bubble = true,
|
60 |
-
$appName = null,
|
61 |
-
$explodeArrays = false,
|
62 |
-
$transactionName = null
|
63 |
-
) {
|
64 |
-
parent::__construct($level, $bubble);
|
65 |
-
|
66 |
-
$this->appName = $appName;
|
67 |
-
$this->explodeArrays = $explodeArrays;
|
68 |
-
$this->transactionName = $transactionName;
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* {@inheritDoc}
|
73 |
-
*/
|
74 |
-
protected function write(array $record)
|
75 |
-
{
|
76 |
-
if (!$this->isNewRelicEnabled()) {
|
77 |
-
throw new MissingExtensionException('The newrelic PHP extension is required to use the NewRelicHandler');
|
78 |
-
}
|
79 |
-
|
80 |
-
if ($appName = $this->getAppName($record['context'])) {
|
81 |
-
$this->setNewRelicAppName($appName);
|
82 |
-
}
|
83 |
-
|
84 |
-
if ($transactionName = $this->getTransactionName($record['context'])) {
|
85 |
-
$this->setNewRelicTransactionName($transactionName);
|
86 |
-
unset($record['formatted']['context']['transaction_name']);
|
87 |
-
}
|
88 |
-
|
89 |
-
if (isset($record['context']['exception']) && ($record['context']['exception'] instanceof \Exception || (PHP_VERSION_ID >= 70000 && $record['context']['exception'] instanceof \Throwable))) {
|
90 |
-
newrelic_notice_error($record['message'], $record['context']['exception']);
|
91 |
-
unset($record['formatted']['context']['exception']);
|
92 |
-
} else {
|
93 |
-
newrelic_notice_error($record['message']);
|
94 |
-
}
|
95 |
-
|
96 |
-
if (isset($record['formatted']['context']) && is_array($record['formatted']['context'])) {
|
97 |
-
foreach ($record['formatted']['context'] as $key => $parameter) {
|
98 |
-
if (is_array($parameter) && $this->explodeArrays) {
|
99 |
-
foreach ($parameter as $paramKey => $paramValue) {
|
100 |
-
$this->setNewRelicParameter('context_' . $key . '_' . $paramKey, $paramValue);
|
101 |
-
}
|
102 |
-
} else {
|
103 |
-
$this->setNewRelicParameter('context_' . $key, $parameter);
|
104 |
-
}
|
105 |
-
}
|
106 |
-
}
|
107 |
-
|
108 |
-
if (isset($record['formatted']['extra']) && is_array($record['formatted']['extra'])) {
|
109 |
-
foreach ($record['formatted']['extra'] as $key => $parameter) {
|
110 |
-
if (is_array($parameter) && $this->explodeArrays) {
|
111 |
-
foreach ($parameter as $paramKey => $paramValue) {
|
112 |
-
$this->setNewRelicParameter('extra_' . $key . '_' . $paramKey, $paramValue);
|
113 |
-
}
|
114 |
-
} else {
|
115 |
-
$this->setNewRelicParameter('extra_' . $key, $parameter);
|
116 |
-
}
|
117 |
-
}
|
118 |
-
}
|
119 |
-
}
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Checks whether the NewRelic extension is enabled in the system.
|
123 |
-
*
|
124 |
-
* @return bool
|
125 |
-
*/
|
126 |
-
protected function isNewRelicEnabled()
|
127 |
-
{
|
128 |
-
return extension_loaded('newrelic');
|
129 |
-
}
|
130 |
-
|
131 |
-
/**
|
132 |
-
* Returns the appname where this log should be sent. Each log can override the default appname, set in this
|
133 |
-
* handler's constructor, by providing the appname in it's context.
|
134 |
-
*
|
135 |
-
* @param array $context
|
136 |
-
* @return null|string
|
137 |
-
*/
|
138 |
-
protected function getAppName(array $context)
|
139 |
-
{
|
140 |
-
if (isset($context['appname'])) {
|
141 |
-
return $context['appname'];
|
142 |
-
}
|
143 |
-
|
144 |
-
return $this->appName;
|
145 |
-
}
|
146 |
-
|
147 |
-
/**
|
148 |
-
* Returns the name of the current transaction. Each log can override the default transaction name, set in this
|
149 |
-
* handler's constructor, by providing the transaction_name in it's context
|
150 |
-
*
|
151 |
-
* @param array $context
|
152 |
-
*
|
153 |
-
* @return null|string
|
154 |
-
*/
|
155 |
-
protected function getTransactionName(array $context)
|
156 |
-
{
|
157 |
-
if (isset($context['transaction_name'])) {
|
158 |
-
return $context['transaction_name'];
|
159 |
-
}
|
160 |
-
|
161 |
-
return $this->transactionName;
|
162 |
-
}
|
163 |
-
|
164 |
-
/**
|
165 |
-
* Sets the NewRelic application that should receive this log.
|
166 |
-
*
|
167 |
-
* @param string $appName
|
168 |
-
*/
|
169 |
-
protected function setNewRelicAppName($appName)
|
170 |
-
{
|
171 |
-
newrelic_set_appname($appName);
|
172 |
-
}
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Overwrites the name of the current transaction
|
176 |
-
*
|
177 |
-
* @param string $transactionName
|
178 |
-
*/
|
179 |
-
protected function setNewRelicTransactionName($transactionName)
|
180 |
-
{
|
181 |
-
newrelic_name_transaction($transactionName);
|
182 |
-
}
|
183 |
-
|
184 |
-
/**
|
185 |
-
* @param string $key
|
186 |
-
* @param mixed $value
|
187 |
-
*/
|
188 |
-
protected function setNewRelicParameter($key, $value)
|
189 |
-
{
|
190 |
-
if (null === $value || is_scalar($value)) {
|
191 |
-
newrelic_add_custom_parameter($key, $value);
|
192 |
-
} else {
|
193 |
-
newrelic_add_custom_parameter($key, @json_encode($value));
|
194 |
-
}
|
195 |
-
}
|
196 |
-
|
197 |
-
/**
|
198 |
-
* {@inheritDoc}
|
199 |
-
*/
|
200 |
-
protected function getDefaultFormatter()
|
201 |
-
{
|
202 |
-
return new NormalizerFormatter();
|
203 |
-
}
|
204 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php
DELETED
@@ -1,45 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Blackhole
|
18 |
-
*
|
19 |
-
* Any record it can handle will be thrown away. This can be used
|
20 |
-
* to put on top of an existing stack to override it temporarily.
|
21 |
-
*
|
22 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
23 |
-
*/
|
24 |
-
class NullHandler extends AbstractHandler
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
28 |
-
*/
|
29 |
-
public function __construct($level = Logger::DEBUG)
|
30 |
-
{
|
31 |
-
parent::__construct($level, false);
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* {@inheritdoc}
|
36 |
-
*/
|
37 |
-
public function handle(array $record)
|
38 |
-
{
|
39 |
-
if ($record['level'] < $this->level) {
|
40 |
-
return false;
|
41 |
-
}
|
42 |
-
|
43 |
-
return true;
|
44 |
-
}
|
45 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/PHPConsoleHandler.php
DELETED
@@ -1,242 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Exception;
|
15 |
-
use Monolog\Formatter\LineFormatter;
|
16 |
-
use Monolog\Logger;
|
17 |
-
use PhpConsole\Connector;
|
18 |
-
use PhpConsole\Handler;
|
19 |
-
use PhpConsole\Helper;
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Monolog handler for Google Chrome extension "PHP Console"
|
23 |
-
*
|
24 |
-
* Display PHP error/debug log messages in Google Chrome console and notification popups, executes PHP code remotely
|
25 |
-
*
|
26 |
-
* Usage:
|
27 |
-
* 1. Install Google Chrome extension https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef
|
28 |
-
* 2. See overview https://github.com/barbushin/php-console#overview
|
29 |
-
* 3. Install PHP Console library https://github.com/barbushin/php-console#installation
|
30 |
-
* 4. Example (result will looks like http://i.hizliresim.com/vg3Pz4.png)
|
31 |
-
*
|
32 |
-
* $logger = new \Monolog\Logger('all', array(new \Monolog\Handler\PHPConsoleHandler()));
|
33 |
-
* \Monolog\ErrorHandler::register($logger);
|
34 |
-
* echo $undefinedVar;
|
35 |
-
* $logger->addDebug('SELECT * FROM users', array('db', 'time' => 0.012));
|
36 |
-
* PC::debug($_SERVER); // PHP Console debugger for any type of vars
|
37 |
-
*
|
38 |
-
* @author Sergey Barbushin https://www.linkedin.com/in/barbushin
|
39 |
-
*/
|
40 |
-
class PHPConsoleHandler extends AbstractProcessingHandler
|
41 |
-
{
|
42 |
-
private $options = array(
|
43 |
-
'enabled' => true, // bool Is PHP Console server enabled
|
44 |
-
'classesPartialsTraceIgnore' => array('Monolog\\'), // array Hide calls of classes started with...
|
45 |
-
'debugTagsKeysInContext' => array(0, 'tag'), // bool Is PHP Console server enabled
|
46 |
-
'useOwnErrorsHandler' => false, // bool Enable errors handling
|
47 |
-
'useOwnExceptionsHandler' => false, // bool Enable exceptions handling
|
48 |
-
'sourcesBasePath' => null, // string Base path of all project sources to strip in errors source paths
|
49 |
-
'registerHelper' => true, // bool Register PhpConsole\Helper that allows short debug calls like PC::debug($var, 'ta.g.s')
|
50 |
-
'serverEncoding' => null, // string|null Server internal encoding
|
51 |
-
'headersLimit' => null, // int|null Set headers size limit for your web-server
|
52 |
-
'password' => null, // string|null Protect PHP Console connection by password
|
53 |
-
'enableSslOnlyMode' => false, // bool Force connection by SSL for clients with PHP Console installed
|
54 |
-
'ipMasks' => array(), // array Set IP masks of clients that will be allowed to connect to PHP Console: array('192.168.*.*', '127.0.0.1')
|
55 |
-
'enableEvalListener' => false, // bool Enable eval request to be handled by eval dispatcher(if enabled, 'password' option is also required)
|
56 |
-
'dumperDetectCallbacks' => false, // bool Convert callback items in dumper vars to (callback SomeClass::someMethod) strings
|
57 |
-
'dumperLevelLimit' => 5, // int Maximum dumped vars array or object nested dump level
|
58 |
-
'dumperItemsCountLimit' => 100, // int Maximum dumped var same level array items or object properties number
|
59 |
-
'dumperItemSizeLimit' => 5000, // int Maximum length of any string or dumped array item
|
60 |
-
'dumperDumpSizeLimit' => 500000, // int Maximum approximate size of dumped vars result formatted in JSON
|
61 |
-
'detectDumpTraceAndSource' => false, // bool Autodetect and append trace data to debug
|
62 |
-
'dataStorage' => null, // PhpConsole\Storage|null Fixes problem with custom $_SESSION handler(see http://goo.gl/Ne8juJ)
|
63 |
-
);
|
64 |
-
|
65 |
-
/** @var Connector */
|
66 |
-
private $connector;
|
67 |
-
|
68 |
-
/**
|
69 |
-
* @param array $options See \Monolog\Handler\PHPConsoleHandler::$options for more details
|
70 |
-
* @param Connector|null $connector Instance of \PhpConsole\Connector class (optional)
|
71 |
-
* @param int $level
|
72 |
-
* @param bool $bubble
|
73 |
-
* @throws Exception
|
74 |
-
*/
|
75 |
-
public function __construct(array $options = array(), Connector $connector = null, $level = Logger::DEBUG, $bubble = true)
|
76 |
-
{
|
77 |
-
if (!class_exists('PhpConsole\Connector')) {
|
78 |
-
throw new Exception('PHP Console library not found. See https://github.com/barbushin/php-console#installation');
|
79 |
-
}
|
80 |
-
parent::__construct($level, $bubble);
|
81 |
-
$this->options = $this->initOptions($options);
|
82 |
-
$this->connector = $this->initConnector($connector);
|
83 |
-
}
|
84 |
-
|
85 |
-
private function initOptions(array $options)
|
86 |
-
{
|
87 |
-
$wrongOptions = array_diff(array_keys($options), array_keys($this->options));
|
88 |
-
if ($wrongOptions) {
|
89 |
-
throw new Exception('Unknown options: ' . implode(', ', $wrongOptions));
|
90 |
-
}
|
91 |
-
|
92 |
-
return array_replace($this->options, $options);
|
93 |
-
}
|
94 |
-
|
95 |
-
private function initConnector(Connector $connector = null)
|
96 |
-
{
|
97 |
-
if (!$connector) {
|
98 |
-
if ($this->options['dataStorage']) {
|
99 |
-
Connector::setPostponeStorage($this->options['dataStorage']);
|
100 |
-
}
|
101 |
-
$connector = Connector::getInstance();
|
102 |
-
}
|
103 |
-
|
104 |
-
if ($this->options['registerHelper'] && !Helper::isRegistered()) {
|
105 |
-
Helper::register();
|
106 |
-
}
|
107 |
-
|
108 |
-
if ($this->options['enabled'] && $connector->isActiveClient()) {
|
109 |
-
if ($this->options['useOwnErrorsHandler'] || $this->options['useOwnExceptionsHandler']) {
|
110 |
-
$handler = Handler::getInstance();
|
111 |
-
$handler->setHandleErrors($this->options['useOwnErrorsHandler']);
|
112 |
-
$handler->setHandleExceptions($this->options['useOwnExceptionsHandler']);
|
113 |
-
$handler->start();
|
114 |
-
}
|
115 |
-
if ($this->options['sourcesBasePath']) {
|
116 |
-
$connector->setSourcesBasePath($this->options['sourcesBasePath']);
|
117 |
-
}
|
118 |
-
if ($this->options['serverEncoding']) {
|
119 |
-
$connector->setServerEncoding($this->options['serverEncoding']);
|
120 |
-
}
|
121 |
-
if ($this->options['password']) {
|
122 |
-
$connector->setPassword($this->options['password']);
|
123 |
-
}
|
124 |
-
if ($this->options['enableSslOnlyMode']) {
|
125 |
-
$connector->enableSslOnlyMode();
|
126 |
-
}
|
127 |
-
if ($this->options['ipMasks']) {
|
128 |
-
$connector->setAllowedIpMasks($this->options['ipMasks']);
|
129 |
-
}
|
130 |
-
if ($this->options['headersLimit']) {
|
131 |
-
$connector->setHeadersLimit($this->options['headersLimit']);
|
132 |
-
}
|
133 |
-
if ($this->options['detectDumpTraceAndSource']) {
|
134 |
-
$connector->getDebugDispatcher()->detectTraceAndSource = true;
|
135 |
-
}
|
136 |
-
$dumper = $connector->getDumper();
|
137 |
-
$dumper->levelLimit = $this->options['dumperLevelLimit'];
|
138 |
-
$dumper->itemsCountLimit = $this->options['dumperItemsCountLimit'];
|
139 |
-
$dumper->itemSizeLimit = $this->options['dumperItemSizeLimit'];
|
140 |
-
$dumper->dumpSizeLimit = $this->options['dumperDumpSizeLimit'];
|
141 |
-
$dumper->detectCallbacks = $this->options['dumperDetectCallbacks'];
|
142 |
-
if ($this->options['enableEvalListener']) {
|
143 |
-
$connector->startEvalRequestsListener();
|
144 |
-
}
|
145 |
-
}
|
146 |
-
|
147 |
-
return $connector;
|
148 |
-
}
|
149 |
-
|
150 |
-
public function getConnector()
|
151 |
-
{
|
152 |
-
return $this->connector;
|
153 |
-
}
|
154 |
-
|
155 |
-
public function getOptions()
|
156 |
-
{
|
157 |
-
return $this->options;
|
158 |
-
}
|
159 |
-
|
160 |
-
public function handle(array $record)
|
161 |
-
{
|
162 |
-
if ($this->options['enabled'] && $this->connector->isActiveClient()) {
|
163 |
-
return parent::handle($record);
|
164 |
-
}
|
165 |
-
|
166 |
-
return !$this->bubble;
|
167 |
-
}
|
168 |
-
|
169 |
-
/**
|
170 |
-
* Writes the record down to the log of the implementing handler
|
171 |
-
*
|
172 |
-
* @param array $record
|
173 |
-
* @return void
|
174 |
-
*/
|
175 |
-
protected function write(array $record)
|
176 |
-
{
|
177 |
-
if ($record['level'] < Logger::NOTICE) {
|
178 |
-
$this->handleDebugRecord($record);
|
179 |
-
} elseif (isset($record['context']['exception']) && $record['context']['exception'] instanceof Exception) {
|
180 |
-
$this->handleExceptionRecord($record);
|
181 |
-
} else {
|
182 |
-
$this->handleErrorRecord($record);
|
183 |
-
}
|
184 |
-
}
|
185 |
-
|
186 |
-
private function handleDebugRecord(array $record)
|
187 |
-
{
|
188 |
-
$tags = $this->getRecordTags($record);
|
189 |
-
$message = $record['message'];
|
190 |
-
if ($record['context']) {
|
191 |
-
$message .= ' ' . json_encode($this->connector->getDumper()->dump(array_filter($record['context'])));
|
192 |
-
}
|
193 |
-
$this->connector->getDebugDispatcher()->dispatchDebug($message, $tags, $this->options['classesPartialsTraceIgnore']);
|
194 |
-
}
|
195 |
-
|
196 |
-
private function handleExceptionRecord(array $record)
|
197 |
-
{
|
198 |
-
$this->connector->getErrorsDispatcher()->dispatchException($record['context']['exception']);
|
199 |
-
}
|
200 |
-
|
201 |
-
private function handleErrorRecord(array $record)
|
202 |
-
{
|
203 |
-
$context = $record['context'];
|
204 |
-
|
205 |
-
$this->connector->getErrorsDispatcher()->dispatchError(
|
206 |
-
isset($context['code']) ? $context['code'] : null,
|
207 |
-
isset($context['message']) ? $context['message'] : $record['message'],
|
208 |
-
isset($context['file']) ? $context['file'] : null,
|
209 |
-
isset($context['line']) ? $context['line'] : null,
|
210 |
-
$this->options['classesPartialsTraceIgnore']
|
211 |
-
);
|
212 |
-
}
|
213 |
-
|
214 |
-
private function getRecordTags(array &$record)
|
215 |
-
{
|
216 |
-
$tags = null;
|
217 |
-
if (!empty($record['context'])) {
|
218 |
-
$context = & $record['context'];
|
219 |
-
foreach ($this->options['debugTagsKeysInContext'] as $key) {
|
220 |
-
if (!empty($context[$key])) {
|
221 |
-
$tags = $context[$key];
|
222 |
-
if ($key === 0) {
|
223 |
-
array_shift($context);
|
224 |
-
} else {
|
225 |
-
unset($context[$key]);
|
226 |
-
}
|
227 |
-
break;
|
228 |
-
}
|
229 |
-
}
|
230 |
-
}
|
231 |
-
|
232 |
-
return $tags ?: strtolower($record['level_name']);
|
233 |
-
}
|
234 |
-
|
235 |
-
/**
|
236 |
-
* {@inheritDoc}
|
237 |
-
*/
|
238 |
-
protected function getDefaultFormatter()
|
239 |
-
{
|
240 |
-
return new LineFormatter('%message%');
|
241 |
-
}
|
242 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerInterface.php
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php declare(strict_types=1);
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Processor\ProcessorInterface;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Interface to describe loggers that have processors
|
18 |
-
*
|
19 |
-
* This interface is present in monolog 1.x to ease forward compatibility.
|
20 |
-
*
|
21 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
22 |
-
*/
|
23 |
-
interface ProcessableHandlerInterface
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* Adds a processor in the stack.
|
27 |
-
*
|
28 |
-
* @param ProcessorInterface|callable $callback
|
29 |
-
* @return HandlerInterface self
|
30 |
-
*/
|
31 |
-
public function pushProcessor($callback): HandlerInterface;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Removes the processor on top of the stack and returns it.
|
35 |
-
*
|
36 |
-
* @throws \LogicException In case the processor stack is empty
|
37 |
-
* @return callable
|
38 |
-
*/
|
39 |
-
public function popProcessor(): callable;
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerTrait.php
DELETED
@@ -1,73 +0,0 @@
|
|
1 |
-
<?php declare(strict_types=1);
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\ResettableInterface;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Helper trait for implementing ProcessableInterface
|
18 |
-
*
|
19 |
-
* This trait is present in monolog 1.x to ease forward compatibility.
|
20 |
-
*
|
21 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
22 |
-
*/
|
23 |
-
trait ProcessableHandlerTrait
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* @var callable[]
|
27 |
-
*/
|
28 |
-
protected $processors = [];
|
29 |
-
|
30 |
-
/**
|
31 |
-
* {@inheritdoc}
|
32 |
-
* @suppress PhanTypeMismatchReturn
|
33 |
-
*/
|
34 |
-
public function pushProcessor($callback): HandlerInterface
|
35 |
-
{
|
36 |
-
array_unshift($this->processors, $callback);
|
37 |
-
|
38 |
-
return $this;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* {@inheritdoc}
|
43 |
-
*/
|
44 |
-
public function popProcessor(): callable
|
45 |
-
{
|
46 |
-
if (!$this->processors) {
|
47 |
-
throw new \LogicException('You tried to pop from an empty processor stack.');
|
48 |
-
}
|
49 |
-
|
50 |
-
return array_shift($this->processors);
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Processes a record.
|
55 |
-
*/
|
56 |
-
protected function processRecord(array $record): array
|
57 |
-
{
|
58 |
-
foreach ($this->processors as $processor) {
|
59 |
-
$record = $processor($record);
|
60 |
-
}
|
61 |
-
|
62 |
-
return $record;
|
63 |
-
}
|
64 |
-
|
65 |
-
protected function resetProcessors(): void
|
66 |
-
{
|
67 |
-
foreach ($this->processors as $processor) {
|
68 |
-
if ($processor instanceof ResettableInterface) {
|
69 |
-
$processor->reset();
|
70 |
-
}
|
71 |
-
}
|
72 |
-
}
|
73 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php
DELETED
@@ -1,56 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Psr\Log\LoggerInterface;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Proxies log messages to an existing PSR-3 compliant logger.
|
19 |
-
*
|
20 |
-
* @author Michael Moussa <michael.moussa@gmail.com>
|
21 |
-
*/
|
22 |
-
class PsrHandler extends AbstractHandler
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* PSR-3 compliant logger
|
26 |
-
*
|
27 |
-
* @var LoggerInterface
|
28 |
-
*/
|
29 |
-
protected $logger;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @param LoggerInterface $logger The underlying PSR-3 compliant logger to which messages will be proxied
|
33 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
34 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
35 |
-
*/
|
36 |
-
public function __construct(LoggerInterface $logger, $level = Logger::DEBUG, $bubble = true)
|
37 |
-
{
|
38 |
-
parent::__construct($level, $bubble);
|
39 |
-
|
40 |
-
$this->logger = $logger;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* {@inheritDoc}
|
45 |
-
*/
|
46 |
-
public function handle(array $record)
|
47 |
-
{
|
48 |
-
if (!$this->isHandling($record)) {
|
49 |
-
return false;
|
50 |
-
}
|
51 |
-
|
52 |
-
$this->logger->log(strtolower($record['level_name']), $record['message'], $record['context']);
|
53 |
-
|
54 |
-
return false === $this->bubble;
|
55 |
-
}
|
56 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php
DELETED
@@ -1,185 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Sends notifications through the pushover api to mobile phones
|
18 |
-
*
|
19 |
-
* @author Sebastian Göttschkes <sebastian.goettschkes@googlemail.com>
|
20 |
-
* @see https://www.pushover.net/api
|
21 |
-
*/
|
22 |
-
class PushoverHandler extends SocketHandler
|
23 |
-
{
|
24 |
-
private $token;
|
25 |
-
private $users;
|
26 |
-
private $title;
|
27 |
-
private $user;
|
28 |
-
private $retry;
|
29 |
-
private $expire;
|
30 |
-
|
31 |
-
private $highPriorityLevel;
|
32 |
-
private $emergencyLevel;
|
33 |
-
private $useFormattedMessage = false;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* All parameters that can be sent to Pushover
|
37 |
-
* @see https://pushover.net/api
|
38 |
-
* @var array
|
39 |
-
*/
|
40 |
-
private $parameterNames = array(
|
41 |
-
'token' => true,
|
42 |
-
'user' => true,
|
43 |
-
'message' => true,
|
44 |
-
'device' => true,
|
45 |
-
'title' => true,
|
46 |
-
'url' => true,
|
47 |
-
'url_title' => true,
|
48 |
-
'priority' => true,
|
49 |
-
'timestamp' => true,
|
50 |
-
'sound' => true,
|
51 |
-
'retry' => true,
|
52 |
-
'expire' => true,
|
53 |
-
'callback' => true,
|
54 |
-
);
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Sounds the api supports by default
|
58 |
-
* @see https://pushover.net/api#sounds
|
59 |
-
* @var array
|
60 |
-
*/
|
61 |
-
private $sounds = array(
|
62 |
-
'pushover', 'bike', 'bugle', 'cashregister', 'classical', 'cosmic', 'falling', 'gamelan', 'incoming',
|
63 |
-
'intermission', 'magic', 'mechanical', 'pianobar', 'siren', 'spacealarm', 'tugboat', 'alien', 'climb',
|
64 |
-
'persistent', 'echo', 'updown', 'none',
|
65 |
-
);
|
66 |
-
|
67 |
-
/**
|
68 |
-
* @param string $token Pushover api token
|
69 |
-
* @param string|array $users Pushover user id or array of ids the message will be sent to
|
70 |
-
* @param string $title Title sent to the Pushover API
|
71 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
72 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
73 |
-
* @param bool $useSSL Whether to connect via SSL. Required when pushing messages to users that are not
|
74 |
-
* the pushover.net app owner. OpenSSL is required for this option.
|
75 |
-
* @param int $highPriorityLevel The minimum logging level at which this handler will start
|
76 |
-
* sending "high priority" requests to the Pushover API
|
77 |
-
* @param int $emergencyLevel The minimum logging level at which this handler will start
|
78 |
-
* sending "emergency" requests to the Pushover API
|
79 |
-
* @param int $retry The retry parameter specifies how often (in seconds) the Pushover servers will send the same notification to the user.
|
80 |
-
* @param int $expire The expire parameter specifies how many seconds your notification will continue to be retried for (every retry seconds).
|
81 |
-
*/
|
82 |
-
public function __construct($token, $users, $title = null, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $highPriorityLevel = Logger::CRITICAL, $emergencyLevel = Logger::EMERGENCY, $retry = 30, $expire = 25200)
|
83 |
-
{
|
84 |
-
$connectionString = $useSSL ? 'ssl://api.pushover.net:443' : 'api.pushover.net:80';
|
85 |
-
parent::__construct($connectionString, $level, $bubble);
|
86 |
-
|
87 |
-
$this->token = $token;
|
88 |
-
$this->users = (array) $users;
|
89 |
-
$this->title = $title ?: gethostname();
|
90 |
-
$this->highPriorityLevel = Logger::toMonologLevel($highPriorityLevel);
|
91 |
-
$this->emergencyLevel = Logger::toMonologLevel($emergencyLevel);
|
92 |
-
$this->retry = $retry;
|
93 |
-
$this->expire = $expire;
|
94 |
-
}
|
95 |
-
|
96 |
-
protected function generateDataStream($record)
|
97 |
-
{
|
98 |
-
$content = $this->buildContent($record);
|
99 |
-
|
100 |
-
return $this->buildHeader($content) . $content;
|
101 |
-
}
|
102 |
-
|
103 |
-
private function buildContent($record)
|
104 |
-
{
|
105 |
-
// Pushover has a limit of 512 characters on title and message combined.
|
106 |
-
$maxMessageLength = 512 - strlen($this->title);
|
107 |
-
|
108 |
-
$message = ($this->useFormattedMessage) ? $record['formatted'] : $record['message'];
|
109 |
-
$message = substr($message, 0, $maxMessageLength);
|
110 |
-
|
111 |
-
$timestamp = $record['datetime']->getTimestamp();
|
112 |
-
|
113 |
-
$dataArray = array(
|
114 |
-
'token' => $this->token,
|
115 |
-
'user' => $this->user,
|
116 |
-
'message' => $message,
|
117 |
-
'title' => $this->title,
|
118 |
-
'timestamp' => $timestamp,
|
119 |
-
);
|
120 |
-
|
121 |
-
if (isset($record['level']) && $record['level'] >= $this->emergencyLevel) {
|
122 |
-
$dataArray['priority'] = 2;
|
123 |
-
$dataArray['retry'] = $this->retry;
|
124 |
-
$dataArray['expire'] = $this->expire;
|
125 |
-
} elseif (isset($record['level']) && $record['level'] >= $this->highPriorityLevel) {
|
126 |
-
$dataArray['priority'] = 1;
|
127 |
-
}
|
128 |
-
|
129 |
-
// First determine the available parameters
|
130 |
-
$context = array_intersect_key($record['context'], $this->parameterNames);
|
131 |
-
$extra = array_intersect_key($record['extra'], $this->parameterNames);
|
132 |
-
|
133 |
-
// Least important info should be merged with subsequent info
|
134 |
-
$dataArray = array_merge($extra, $context, $dataArray);
|
135 |
-
|
136 |
-
// Only pass sounds that are supported by the API
|
137 |
-
if (isset($dataArray['sound']) && !in_array($dataArray['sound'], $this->sounds)) {
|
138 |
-
unset($dataArray['sound']);
|
139 |
-
}
|
140 |
-
|
141 |
-
return http_build_query($dataArray);
|
142 |
-
}
|
143 |
-
|
144 |
-
private function buildHeader($content)
|
145 |
-
{
|
146 |
-
$header = "POST /1/messages.json HTTP/1.1\r\n";
|
147 |
-
$header .= "Host: api.pushover.net\r\n";
|
148 |
-
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
149 |
-
$header .= "Content-Length: " . strlen($content) . "\r\n";
|
150 |
-
$header .= "\r\n";
|
151 |
-
|
152 |
-
return $header;
|
153 |
-
}
|
154 |
-
|
155 |
-
protected function write(array $record)
|
156 |
-
{
|
157 |
-
foreach ($this->users as $user) {
|
158 |
-
$this->user = $user;
|
159 |
-
|
160 |
-
parent::write($record);
|
161 |
-
$this->closeSocket();
|
162 |
-
}
|
163 |
-
|
164 |
-
$this->user = null;
|
165 |
-
}
|
166 |
-
|
167 |
-
public function setHighPriorityLevel($value)
|
168 |
-
{
|
169 |
-
$this->highPriorityLevel = $value;
|
170 |
-
}
|
171 |
-
|
172 |
-
public function setEmergencyLevel($value)
|
173 |
-
{
|
174 |
-
$this->emergencyLevel = $value;
|
175 |
-
}
|
176 |
-
|
177 |
-
/**
|
178 |
-
* Use the formatted message?
|
179 |
-
* @param bool $value
|
180 |
-
*/
|
181 |
-
public function useFormattedMessage($value)
|
182 |
-
{
|
183 |
-
$this->useFormattedMessage = (bool) $value;
|
184 |
-
}
|
185 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php
DELETED
@@ -1,234 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\LineFormatter;
|
15 |
-
use Monolog\Formatter\FormatterInterface;
|
16 |
-
use Monolog\Logger;
|
17 |
-
use Raven_Client;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Handler to send messages to a Sentry (https://github.com/getsentry/sentry) server
|
21 |
-
* using sentry-php (https://github.com/getsentry/sentry-php)
|
22 |
-
*
|
23 |
-
* @author Marc Abramowitz <marc@marc-abramowitz.com>
|
24 |
-
*/
|
25 |
-
class RavenHandler extends AbstractProcessingHandler
|
26 |
-
{
|
27 |
-
/**
|
28 |
-
* Translates Monolog log levels to Raven log levels.
|
29 |
-
*/
|
30 |
-
protected $logLevels = array(
|
31 |
-
Logger::DEBUG => Raven_Client::DEBUG,
|
32 |
-
Logger::INFO => Raven_Client::INFO,
|
33 |
-
Logger::NOTICE => Raven_Client::INFO,
|
34 |
-
Logger::WARNING => Raven_Client::WARNING,
|
35 |
-
Logger::ERROR => Raven_Client::ERROR,
|
36 |
-
Logger::CRITICAL => Raven_Client::FATAL,
|
37 |
-
Logger::ALERT => Raven_Client::FATAL,
|
38 |
-
Logger::EMERGENCY => Raven_Client::FATAL,
|
39 |
-
);
|
40 |
-
|
41 |
-
/**
|
42 |
-
* @var string should represent the current version of the calling
|
43 |
-
* software. Can be any string (git commit, version number)
|
44 |
-
*/
|
45 |
-
protected $release;
|
46 |
-
|
47 |
-
/**
|
48 |
-
* @var Raven_Client the client object that sends the message to the server
|
49 |
-
*/
|
50 |
-
protected $ravenClient;
|
51 |
-
|
52 |
-
/**
|
53 |
-
* @var LineFormatter The formatter to use for the logs generated via handleBatch()
|
54 |
-
*/
|
55 |
-
protected $batchFormatter;
|
56 |
-
|
57 |
-
/**
|
58 |
-
* @param Raven_Client $ravenClient
|
59 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
60 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
61 |
-
*/
|
62 |
-
public function __construct(Raven_Client $ravenClient, $level = Logger::DEBUG, $bubble = true)
|
63 |
-
{
|
64 |
-
@trigger_error('The Monolog\Handler\RavenHandler class is deprecated. You should rather upgrade to the sentry/sentry 2.x and use Sentry\Monolog\Handler, see https://github.com/getsentry/sentry-php/blob/master/src/Monolog/Handler.php', E_USER_DEPRECATED);
|
65 |
-
|
66 |
-
parent::__construct($level, $bubble);
|
67 |
-
|
68 |
-
$this->ravenClient = $ravenClient;
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* {@inheritdoc}
|
73 |
-
*/
|
74 |
-
public function handleBatch(array $records)
|
75 |
-
{
|
76 |
-
$level = $this->level;
|
77 |
-
|
78 |
-
// filter records based on their level
|
79 |
-
$records = array_filter($records, function ($record) use ($level) {
|
80 |
-
return $record['level'] >= $level;
|
81 |
-
});
|
82 |
-
|
83 |
-
if (!$records) {
|
84 |
-
return;
|
85 |
-
}
|
86 |
-
|
87 |
-
// the record with the highest severity is the "main" one
|
88 |
-
$record = array_reduce($records, function ($highest, $record) {
|
89 |
-
if ($record['level'] > $highest['level']) {
|
90 |
-
return $record;
|
91 |
-
}
|
92 |
-
|
93 |
-
return $highest;
|
94 |
-
});
|
95 |
-
|
96 |
-
// the other ones are added as a context item
|
97 |
-
$logs = array();
|
98 |
-
foreach ($records as $r) {
|
99 |
-
$logs[] = $this->processRecord($r);
|
100 |
-
}
|
101 |
-
|
102 |
-
if ($logs) {
|
103 |
-
$record['context']['logs'] = (string) $this->getBatchFormatter()->formatBatch($logs);
|
104 |
-
}
|
105 |
-
|
106 |
-
$this->handle($record);
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Sets the formatter for the logs generated by handleBatch().
|
111 |
-
*
|
112 |
-
* @param FormatterInterface $formatter
|
113 |
-
*/
|
114 |
-
public function setBatchFormatter(FormatterInterface $formatter)
|
115 |
-
{
|
116 |
-
$this->batchFormatter = $formatter;
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Gets the formatter for the logs generated by handleBatch().
|
121 |
-
*
|
122 |
-
* @return FormatterInterface
|
123 |
-
*/
|
124 |
-
public function getBatchFormatter()
|
125 |
-
{
|
126 |
-
if (!$this->batchFormatter) {
|
127 |
-
$this->batchFormatter = $this->getDefaultBatchFormatter();
|
128 |
-
}
|
129 |
-
|
130 |
-
return $this->batchFormatter;
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* {@inheritdoc}
|
135 |
-
*/
|
136 |
-
protected function write(array $record)
|
137 |
-
{
|
138 |
-
$previousUserContext = false;
|
139 |
-
$options = array();
|
140 |
-
$options['level'] = $this->logLevels[$record['level']];
|
141 |
-
$options['tags'] = array();
|
142 |
-
if (!empty($record['extra']['tags'])) {
|
143 |
-
$options['tags'] = array_merge($options['tags'], $record['extra']['tags']);
|
144 |
-
unset($record['extra']['tags']);
|
145 |
-
}
|
146 |
-
if (!empty($record['context']['tags'])) {
|
147 |
-
$options['tags'] = array_merge($options['tags'], $record['context']['tags']);
|
148 |
-
unset($record['context']['tags']);
|
149 |
-
}
|
150 |
-
if (!empty($record['context']['fingerprint'])) {
|
151 |
-
$options['fingerprint'] = $record['context']['fingerprint'];
|
152 |
-
unset($record['context']['fingerprint']);
|
153 |
-
}
|
154 |
-
if (!empty($record['context']['logger'])) {
|
155 |
-
$options['logger'] = $record['context']['logger'];
|
156 |
-
unset($record['context']['logger']);
|
157 |
-
} else {
|
158 |
-
$options['logger'] = $record['channel'];
|
159 |
-
}
|
160 |
-
foreach ($this->getExtraParameters() as $key) {
|
161 |
-
foreach (array('extra', 'context') as $source) {
|
162 |
-
if (!empty($record[$source][$key])) {
|
163 |
-
$options[$key] = $record[$source][$key];
|
164 |
-
unset($record[$source][$key]);
|
165 |
-
}
|
166 |
-
}
|
167 |
-
}
|
168 |
-
if (!empty($record['context'])) {
|
169 |
-
$options['extra']['context'] = $record['context'];
|
170 |
-
if (!empty($record['context']['user'])) {
|
171 |
-
$previousUserContext = $this->ravenClient->context->user;
|
172 |
-
$this->ravenClient->user_context($record['context']['user']);
|
173 |
-
unset($options['extra']['context']['user']);
|
174 |
-
}
|
175 |
-
}
|
176 |
-
if (!empty($record['extra'])) {
|
177 |
-
$options['extra']['extra'] = $record['extra'];
|
178 |
-
}
|
179 |
-
|
180 |
-
if (!empty($this->release) && !isset($options['release'])) {
|
181 |
-
$options['release'] = $this->release;
|
182 |
-
}
|
183 |
-
|
184 |
-
if (isset($record['context']['exception']) && ($record['context']['exception'] instanceof \Exception || (PHP_VERSION_ID >= 70000 && $record['context']['exception'] instanceof \Throwable))) {
|
185 |
-
$options['message'] = $record['formatted'];
|
186 |
-
$this->ravenClient->captureException($record['context']['exception'], $options);
|
187 |
-
} else {
|
188 |
-
$this->ravenClient->captureMessage($record['formatted'], array(), $options);
|
189 |
-
}
|
190 |
-
|
191 |
-
if ($previousUserContext !== false) {
|
192 |
-
$this->ravenClient->user_context($previousUserContext);
|
193 |
-
}
|
194 |
-
}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* {@inheritDoc}
|
198 |
-
*/
|
199 |
-
protected function getDefaultFormatter()
|
200 |
-
{
|
201 |
-
return new LineFormatter('[%channel%] %message%');
|
202 |
-
}
|
203 |
-
|
204 |
-
/**
|
205 |
-
* Gets the default formatter for the logs generated by handleBatch().
|
206 |
-
*
|
207 |
-
* @return FormatterInterface
|
208 |
-
*/
|
209 |
-
protected function getDefaultBatchFormatter()
|
210 |
-
{
|
211 |
-
return new LineFormatter();
|
212 |
-
}
|
213 |
-
|
214 |
-
/**
|
215 |
-
* Gets extra parameters supported by Raven that can be found in "extra" and "context"
|
216 |
-
*
|
217 |
-
* @return array
|
218 |
-
*/
|
219 |
-
protected function getExtraParameters()
|
220 |
-
{
|
221 |
-
return array('contexts', 'checksum', 'release', 'event_id');
|
222 |
-
}
|
223 |
-
|
224 |
-
/**
|
225 |
-
* @param string $value
|
226 |
-
* @return self
|
227 |
-
*/
|
228 |
-
public function setRelease($value)
|
229 |
-
{
|
230 |
-
$this->release = $value;
|
231 |
-
|
232 |
-
return $this;
|
233 |
-
}
|
234 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php
DELETED
@@ -1,97 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\LineFormatter;
|
15 |
-
use Monolog\Logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Logs to a Redis key using rpush
|
19 |
-
*
|
20 |
-
* usage example:
|
21 |
-
*
|
22 |
-
* $log = new Logger('application');
|
23 |
-
* $redis = new RedisHandler(new Predis\Client("tcp://localhost:6379"), "logs", "prod");
|
24 |
-
* $log->pushHandler($redis);
|
25 |
-
*
|
26 |
-
* @author Thomas Tourlourat <thomas@tourlourat.com>
|
27 |
-
*/
|
28 |
-
class RedisHandler extends AbstractProcessingHandler
|
29 |
-
{
|
30 |
-
private $redisClient;
|
31 |
-
private $redisKey;
|
32 |
-
protected $capSize;
|
33 |
-
|
34 |
-
/**
|
35 |
-
* @param \Predis\Client|\Redis $redis The redis instance
|
36 |
-
* @param string $key The key name to push records to
|
37 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
38 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
39 |
-
* @param int $capSize Number of entries to limit list size to
|
40 |
-
*/
|
41 |
-
public function __construct($redis, $key, $level = Logger::DEBUG, $bubble = true, $capSize = false)
|
42 |
-
{
|
43 |
-
if (!(($redis instanceof \Predis\Client) || ($redis instanceof \Redis))) {
|
44 |
-
throw new \InvalidArgumentException('Predis\Client or Redis instance required');
|
45 |
-
}
|
46 |
-
|
47 |
-
$this->redisClient = $redis;
|
48 |
-
$this->redisKey = $key;
|
49 |
-
$this->capSize = $capSize;
|
50 |
-
|
51 |
-
parent::__construct($level, $bubble);
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* {@inheritDoc}
|
56 |
-
*/
|
57 |
-
protected function write(array $record)
|
58 |
-
{
|
59 |
-
if ($this->capSize) {
|
60 |
-
$this->writeCapped($record);
|
61 |
-
} else {
|
62 |
-
$this->redisClient->rpush($this->redisKey, $record["formatted"]);
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Write and cap the collection
|
68 |
-
* Writes the record to the redis list and caps its
|
69 |
-
*
|
70 |
-
* @param array $record associative record array
|
71 |
-
* @return void
|
72 |
-
*/
|
73 |
-
protected function writeCapped(array $record)
|
74 |
-
{
|
75 |
-
if ($this->redisClient instanceof \Redis) {
|
76 |
-
$this->redisClient->multi()
|
77 |
-
->rpush($this->redisKey, $record["formatted"])
|
78 |
-
->ltrim($this->redisKey, -$this->capSize, -1)
|
79 |
-
->exec();
|
80 |
-
} else {
|
81 |
-
$redisKey = $this->redisKey;
|
82 |
-
$capSize = $this->capSize;
|
83 |
-
$this->redisClient->transaction(function ($tx) use ($record, $redisKey, $capSize) {
|
84 |
-
$tx->rpush($redisKey, $record["formatted"]);
|
85 |
-
$tx->ltrim($redisKey, -$capSize, -1);
|
86 |
-
});
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* {@inheritDoc}
|
92 |
-
*/
|
93 |
-
protected function getDefaultFormatter()
|
94 |
-
{
|
95 |
-
return new LineFormatter();
|
96 |
-
}
|
97 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php
DELETED
@@ -1,144 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use RollbarNotifier;
|
15 |
-
use Exception;
|
16 |
-
use Monolog\Logger;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Sends errors to Rollbar
|
20 |
-
*
|
21 |
-
* If the context data contains a `payload` key, that is used as an array
|
22 |
-
* of payload options to RollbarNotifier's report_message/report_exception methods.
|
23 |
-
*
|
24 |
-
* Rollbar's context info will contain the context + extra keys from the log record
|
25 |
-
* merged, and then on top of that a few keys:
|
26 |
-
*
|
27 |
-
* - level (rollbar level name)
|
28 |
-
* - monolog_level (monolog level name, raw level, as rollbar only has 5 but monolog 8)
|
29 |
-
* - channel
|
30 |
-
* - datetime (unix timestamp)
|
31 |
-
*
|
32 |
-
* @author Paul Statezny <paulstatezny@gmail.com>
|
33 |
-
*/
|
34 |
-
class RollbarHandler extends AbstractProcessingHandler
|
35 |
-
{
|
36 |
-
/**
|
37 |
-
* Rollbar notifier
|
38 |
-
*
|
39 |
-
* @var RollbarNotifier
|
40 |
-
*/
|
41 |
-
protected $rollbarNotifier;
|
42 |
-
|
43 |
-
protected $levelMap = array(
|
44 |
-
Logger::DEBUG => 'debug',
|
45 |
-
Logger::INFO => 'info',
|
46 |
-
Logger::NOTICE => 'info',
|
47 |
-
Logger::WARNING => 'warning',
|
48 |
-
Logger::ERROR => 'error',
|
49 |
-
Logger::CRITICAL => 'critical',
|
50 |
-
Logger::ALERT => 'critical',
|
51 |
-
Logger::EMERGENCY => 'critical',
|
52 |
-
);
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Records whether any log records have been added since the last flush of the rollbar notifier
|
56 |
-
*
|
57 |
-
* @var bool
|
58 |
-
*/
|
59 |
-
private $hasRecords = false;
|
60 |
-
|
61 |
-
protected $initialized = false;
|
62 |
-
|
63 |
-
/**
|
64 |
-
* @param RollbarNotifier $rollbarNotifier RollbarNotifier object constructed with valid token
|
65 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
66 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
67 |
-
*/
|
68 |
-
public function __construct(RollbarNotifier $rollbarNotifier, $level = Logger::ERROR, $bubble = true)
|
69 |
-
{
|
70 |
-
$this->rollbarNotifier = $rollbarNotifier;
|
71 |
-
|
72 |
-
parent::__construct($level, $bubble);
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* {@inheritdoc}
|
77 |
-
*/
|
78 |
-
protected function write(array $record)
|
79 |
-
{
|
80 |
-
if (!$this->initialized) {
|
81 |
-
// __destructor() doesn't get called on Fatal errors
|
82 |
-
register_shutdown_function(array($this, 'close'));
|
83 |
-
$this->initialized = true;
|
84 |
-
}
|
85 |
-
|
86 |
-
$context = $record['context'];
|
87 |
-
$payload = array();
|
88 |
-
if (isset($context['payload'])) {
|
89 |
-
$payload = $context['payload'];
|
90 |
-
unset($context['payload']);
|
91 |
-
}
|
92 |
-
$context = array_merge($context, $record['extra'], array(
|
93 |
-
'level' => $this->levelMap[$record['level']],
|
94 |
-
'monolog_level' => $record['level_name'],
|
95 |
-
'channel' => $record['channel'],
|
96 |
-
'datetime' => $record['datetime']->format('U'),
|
97 |
-
));
|
98 |
-
|
99 |
-
if (isset($context['exception']) && $context['exception'] instanceof Exception) {
|
100 |
-
$payload['level'] = $context['level'];
|
101 |
-
$exception = $context['exception'];
|
102 |
-
unset($context['exception']);
|
103 |
-
|
104 |
-
$this->rollbarNotifier->report_exception($exception, $context, $payload);
|
105 |
-
} else {
|
106 |
-
$this->rollbarNotifier->report_message(
|
107 |
-
$record['message'],
|
108 |
-
$context['level'],
|
109 |
-
$context,
|
110 |
-
$payload
|
111 |
-
);
|
112 |
-
}
|
113 |
-
|
114 |
-
$this->hasRecords = true;
|
115 |
-
}
|
116 |
-
|
117 |
-
public function flush()
|
118 |
-
{
|
119 |
-
if ($this->hasRecords) {
|
120 |
-
$this->rollbarNotifier->flush();
|
121 |
-
$this->hasRecords = false;
|
122 |
-
}
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* {@inheritdoc}
|
127 |
-
*/
|
128 |
-
public function close()
|
129 |
-
{
|
130 |
-
$this->flush();
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* {@inheritdoc}
|
135 |
-
*/
|
136 |
-
public function reset()
|
137 |
-
{
|
138 |
-
$this->flush();
|
139 |
-
|
140 |
-
parent::reset();
|
141 |
-
}
|
142 |
-
|
143 |
-
|
144 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php
DELETED
@@ -1,190 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Stores logs to files that are rotated every day and a limited number of files are kept.
|
18 |
-
*
|
19 |
-
* This rotation is only intended to be used as a workaround. Using logrotate to
|
20 |
-
* handle the rotation is strongly encouraged when you can use it.
|
21 |
-
*
|
22 |
-
* @author Christophe Coevoet <stof@notk.org>
|
23 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
24 |
-
*/
|
25 |
-
class RotatingFileHandler extends StreamHandler
|
26 |
-
{
|
27 |
-
const FILE_PER_DAY = 'Y-m-d';
|
28 |
-
const FILE_PER_MONTH = 'Y-m';
|
29 |
-
const FILE_PER_YEAR = 'Y';
|
30 |
-
|
31 |
-
protected $filename;
|
32 |
-
protected $maxFiles;
|
33 |
-
protected $mustRotate;
|
34 |
-
protected $nextRotation;
|
35 |
-
protected $filenameFormat;
|
36 |
-
protected $dateFormat;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @param string $filename
|
40 |
-
* @param int $maxFiles The maximal amount of files to keep (0 means unlimited)
|
41 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
42 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
43 |
-
* @param int|null $filePermission Optional file permissions (default (0644) are only for owner read/write)
|
44 |
-
* @param bool $useLocking Try to lock log file before doing any writes
|
45 |
-
*/
|
46 |
-
public function __construct($filename, $maxFiles = 0, $level = Logger::DEBUG, $bubble = true, $filePermission = null, $useLocking = false)
|
47 |
-
{
|
48 |
-
$this->filename = $filename;
|
49 |
-
$this->maxFiles = (int) $maxFiles;
|
50 |
-
$this->nextRotation = new \DateTime('tomorrow');
|
51 |
-
$this->filenameFormat = '{filename}-{date}';
|
52 |
-
$this->dateFormat = 'Y-m-d';
|
53 |
-
|
54 |
-
parent::__construct($this->getTimedFilename(), $level, $bubble, $filePermission, $useLocking);
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* {@inheritdoc}
|
59 |
-
*/
|
60 |
-
public function close()
|
61 |
-
{
|
62 |
-
parent::close();
|
63 |
-
|
64 |
-
if (true === $this->mustRotate) {
|
65 |
-
$this->rotate();
|
66 |
-
}
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* {@inheritdoc}
|
71 |
-
*/
|
72 |
-
public function reset()
|
73 |
-
{
|
74 |
-
parent::reset();
|
75 |
-
|
76 |
-
if (true === $this->mustRotate) {
|
77 |
-
$this->rotate();
|
78 |
-
}
|
79 |
-
}
|
80 |
-
|
81 |
-
public function setFilenameFormat($filenameFormat, $dateFormat)
|
82 |
-
{
|
83 |
-
if (!preg_match('{^Y(([/_.-]?m)([/_.-]?d)?)?$}', $dateFormat)) {
|
84 |
-
trigger_error(
|
85 |
-
'Invalid date format - format must be one of '.
|
86 |
-
'RotatingFileHandler::FILE_PER_DAY ("Y-m-d"), RotatingFileHandler::FILE_PER_MONTH ("Y-m") '.
|
87 |
-
'or RotatingFileHandler::FILE_PER_YEAR ("Y"), or you can set one of the '.
|
88 |
-
'date formats using slashes, underscores and/or dots instead of dashes.',
|
89 |
-
E_USER_DEPRECATED
|
90 |
-
);
|
91 |
-
}
|
92 |
-
if (substr_count($filenameFormat, '{date}') === 0) {
|
93 |
-
trigger_error(
|
94 |
-
'Invalid filename format - format should contain at least `{date}`, because otherwise rotating is impossible.',
|
95 |
-
E_USER_DEPRECATED
|
96 |
-
);
|
97 |
-
}
|
98 |
-
$this->filenameFormat = $filenameFormat;
|
99 |
-
$this->dateFormat = $dateFormat;
|
100 |
-
$this->url = $this->getTimedFilename();
|
101 |
-
$this->close();
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* {@inheritdoc}
|
106 |
-
*/
|
107 |
-
protected function write(array $record)
|
108 |
-
{
|
109 |
-
// on the first record written, if the log is new, we should rotate (once per day)
|
110 |
-
if (null === $this->mustRotate) {
|
111 |
-
$this->mustRotate = !file_exists($this->url);
|
112 |
-
}
|
113 |
-
|
114 |
-
if ($this->nextRotation < $record['datetime']) {
|
115 |
-
$this->mustRotate = true;
|
116 |
-
$this->close();
|
117 |
-
}
|
118 |
-
|
119 |
-
parent::write($record);
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Rotates the files.
|
124 |
-
*/
|
125 |
-
protected function rotate()
|
126 |
-
{
|
127 |
-
// update filename
|
128 |
-
$this->url = $this->getTimedFilename();
|
129 |
-
$this->nextRotation = new \DateTime('tomorrow');
|
130 |
-
|
131 |
-
// skip GC of old logs if files are unlimited
|
132 |
-
if (0 === $this->maxFiles) {
|
133 |
-
return;
|
134 |
-
}
|
135 |
-
|
136 |
-
$logFiles = glob($this->getGlobPattern());
|
137 |
-
if ($this->maxFiles >= count($logFiles)) {
|
138 |
-
// no files to remove
|
139 |
-
return;
|
140 |
-
}
|
141 |
-
|
142 |
-
// Sorting the files by name to remove the older ones
|
143 |
-
usort($logFiles, function ($a, $b) {
|
144 |
-
return strcmp($b, $a);
|
145 |
-
});
|
146 |
-
|
147 |
-
foreach (array_slice($logFiles, $this->maxFiles) as $file) {
|
148 |
-
if (is_writable($file)) {
|
149 |
-
// suppress errors here as unlink() might fail if two processes
|
150 |
-
// are cleaning up/rotating at the same time
|
151 |
-
set_error_handler(function ($errno, $errstr, $errfile, $errline) {});
|
152 |
-
unlink($file);
|
153 |
-
restore_error_handler();
|
154 |
-
}
|
155 |
-
}
|
156 |
-
|
157 |
-
$this->mustRotate = false;
|
158 |
-
}
|
159 |
-
|
160 |
-
protected function getTimedFilename()
|
161 |
-
{
|
162 |
-
$fileInfo = pathinfo($this->filename);
|
163 |
-
$timedFilename = str_replace(
|
164 |
-
array('{filename}', '{date}'),
|
165 |
-
array($fileInfo['filename'], date($this->dateFormat)),
|
166 |
-
$fileInfo['dirname'] . '/' . $this->filenameFormat
|
167 |
-
);
|
168 |
-
|
169 |
-
if (!empty($fileInfo['extension'])) {
|
170 |
-
$timedFilename .= '.'.$fileInfo['extension'];
|
171 |
-
}
|
172 |
-
|
173 |
-
return $timedFilename;
|
174 |
-
}
|
175 |
-
|
176 |
-
protected function getGlobPattern()
|
177 |
-
{
|
178 |
-
$fileInfo = pathinfo($this->filename);
|
179 |
-
$glob = str_replace(
|
180 |
-
array('{filename}', '{date}'),
|
181 |
-
array($fileInfo['filename'], '[0-9][0-9][0-9][0-9]*'),
|
182 |
-
$fileInfo['dirname'] . '/' . $this->filenameFormat
|
183 |
-
);
|
184 |
-
if (!empty($fileInfo['extension'])) {
|
185 |
-
$glob .= '.'.$fileInfo['extension'];
|
186 |
-
}
|
187 |
-
|
188 |
-
return $glob;
|
189 |
-
}
|
190 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/SamplingHandler.php
DELETED
@@ -1,82 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Sampling handler
|
16 |
-
*
|
17 |
-
* A sampled event stream can be useful for logging high frequency events in
|
18 |
-
* a production environment where you only need an idea of what is happening
|
19 |
-
* and are not concerned with capturing every occurrence. Since the decision to
|
20 |
-
* handle or not handle a particular event is determined randomly, the
|
21 |
-
* resulting sampled log is not guaranteed to contain 1/N of the events that
|
22 |
-
* occurred in the application, but based on the Law of large numbers, it will
|
23 |
-
* tend to be close to this ratio with a large number of attempts.
|
24 |
-
*
|
25 |
-
* @author Bryan Davis <bd808@wikimedia.org>
|
26 |
-
* @author Kunal Mehta <legoktm@gmail.com>
|
27 |
-
*/
|
28 |
-
class SamplingHandler extends AbstractHandler
|
29 |
-
{
|
30 |
-
/**
|
31 |
-
* @var callable|HandlerInterface $handler
|
32 |
-
*/
|
33 |
-
protected $handler;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* @var int $factor
|
37 |
-
*/
|
38 |
-
protected $factor;
|
39 |
-
|
40 |
-
/**
|
41 |
-
* @param callable|HandlerInterface $handler Handler or factory callable($record, $fingersCrossedHandler).
|
42 |
-
* @param int $factor Sample factor
|
43 |
-
*/
|
44 |
-
public function __construct($handler, $factor)
|
45 |
-
{
|
46 |
-
parent::__construct();
|
47 |
-
$this->handler = $handler;
|
48 |
-
$this->factor = $factor;
|
49 |
-
|
50 |
-
if (!$this->handler instanceof HandlerInterface && !is_callable($this->handler)) {
|
51 |
-
throw new \RuntimeException("The given handler (".json_encode($this->handler).") is not a callable nor a Monolog\Handler\HandlerInterface object");
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
public function isHandling(array $record)
|
56 |
-
{
|
57 |
-
return $this->handler->isHandling($record);
|
58 |
-
}
|
59 |
-
|
60 |
-
public function handle(array $record)
|
61 |
-
{
|
62 |
-
if ($this->isHandling($record) && mt_rand(1, $this->factor) === 1) {
|
63 |
-
// The same logic as in FingersCrossedHandler
|
64 |
-
if (!$this->handler instanceof HandlerInterface) {
|
65 |
-
$this->handler = call_user_func($this->handler, $record, $this);
|
66 |
-
if (!$this->handler instanceof HandlerInterface) {
|
67 |
-
throw new \RuntimeException("The factory callable should return a HandlerInterface");
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
if ($this->processors) {
|
72 |
-
foreach ($this->processors as $processor) {
|
73 |
-
$record = call_user_func($processor, $record);
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
$this->handler->handle($record);
|
78 |
-
}
|
79 |
-
|
80 |
-
return false === $this->bubble;
|
81 |
-
}
|
82 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php
DELETED
@@ -1,294 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler\Slack;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\Formatter\NormalizerFormatter;
|
16 |
-
use Monolog\Formatter\FormatterInterface;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Slack record utility helping to log to Slack webhooks or API.
|
20 |
-
*
|
21 |
-
* @author Greg Kedzierski <greg@gregkedzierski.com>
|
22 |
-
* @author Haralan Dobrev <hkdobrev@gmail.com>
|
23 |
-
* @see https://api.slack.com/incoming-webhooks
|
24 |
-
* @see https://api.slack.com/docs/message-attachments
|
25 |
-
*/
|
26 |
-
class SlackRecord
|
27 |
-
{
|
28 |
-
const COLOR_DANGER = 'danger';
|
29 |
-
|
30 |
-
const COLOR_WARNING = 'warning';
|
31 |
-
|
32 |
-
const COLOR_GOOD = 'good';
|
33 |
-
|
34 |
-
const COLOR_DEFAULT = '#e3e4e6';
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Slack channel (encoded ID or name)
|
38 |
-
* @var string|null
|
39 |
-
*/
|
40 |
-
private $channel;
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Name of a bot
|
44 |
-
* @var string|null
|
45 |
-
*/
|
46 |
-
private $username;
|
47 |
-
|
48 |
-
/**
|
49 |
-
* User icon e.g. 'ghost', 'http://example.com/user.png'
|
50 |
-
* @var string
|
51 |
-
*/
|
52 |
-
private $userIcon;
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Whether the message should be added to Slack as attachment (plain text otherwise)
|
56 |
-
* @var bool
|
57 |
-
*/
|
58 |
-
private $useAttachment;
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Whether the the context/extra messages added to Slack as attachments are in a short style
|
62 |
-
* @var bool
|
63 |
-
*/
|
64 |
-
private $useShortAttachment;
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Whether the attachment should include context and extra data
|
68 |
-
* @var bool
|
69 |
-
*/
|
70 |
-
private $includeContextAndExtra;
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Dot separated list of fields to exclude from slack message. E.g. ['context.field1', 'extra.field2']
|
74 |
-
* @var array
|
75 |
-
*/
|
76 |
-
private $excludeFields;
|
77 |
-
|
78 |
-
/**
|
79 |
-
* @var FormatterInterface
|
80 |
-
*/
|
81 |
-
private $formatter;
|
82 |
-
|
83 |
-
/**
|
84 |
-
* @var NormalizerFormatter
|
85 |
-
*/
|
86 |
-
private $normalizerFormatter;
|
87 |
-
|
88 |
-
public function __construct($channel = null, $username = null, $useAttachment = true, $userIcon = null, $useShortAttachment = false, $includeContextAndExtra = false, array $excludeFields = array(), FormatterInterface $formatter = null)
|
89 |
-
{
|
90 |
-
$this->channel = $channel;
|
91 |
-
$this->username = $username;
|
92 |
-
$this->userIcon = trim($userIcon, ':');
|
93 |
-
$this->useAttachment = $useAttachment;
|
94 |
-
$this->useShortAttachment = $useShortAttachment;
|
95 |
-
$this->includeContextAndExtra = $includeContextAndExtra;
|
96 |
-
$this->excludeFields = $excludeFields;
|
97 |
-
$this->formatter = $formatter;
|
98 |
-
|
99 |
-
if ($this->includeContextAndExtra) {
|
100 |
-
$this->normalizerFormatter = new NormalizerFormatter();
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
public function getSlackData(array $record)
|
105 |
-
{
|
106 |
-
$dataArray = array();
|
107 |
-
$record = $this->excludeFields($record);
|
108 |
-
|
109 |
-
if ($this->username) {
|
110 |
-
$dataArray['username'] = $this->username;
|
111 |
-
}
|
112 |
-
|
113 |
-
if ($this->channel) {
|
114 |
-
$dataArray['channel'] = $this->channel;
|
115 |
-
}
|
116 |
-
|
117 |
-
if ($this->formatter && !$this->useAttachment) {
|
118 |
-
$message = $this->formatter->format($record);
|
119 |
-
} else {
|
120 |
-
$message = $record['message'];
|
121 |
-
}
|
122 |
-
|
123 |
-
if ($this->useAttachment) {
|
124 |
-
$attachment = array(
|
125 |
-
'fallback' => $message,
|
126 |
-
'text' => $message,
|
127 |
-
'color' => $this->getAttachmentColor($record['level']),
|
128 |
-
'fields' => array(),
|
129 |
-
'mrkdwn_in' => array('fields'),
|
130 |
-
'ts' => $record['datetime']->getTimestamp()
|
131 |
-
);
|
132 |
-
|
133 |
-
if ($this->useShortAttachment) {
|
134 |
-
$attachment['title'] = $record['level_name'];
|
135 |
-
} else {
|
136 |
-
$attachment['title'] = 'Message';
|
137 |
-
$attachment['fields'][] = $this->generateAttachmentField('Level', $record['level_name']);
|
138 |
-
}
|
139 |
-
|
140 |
-
|
141 |
-
if ($this->includeContextAndExtra) {
|
142 |
-
foreach (array('extra', 'context') as $key) {
|
143 |
-
if (empty($record[$key])) {
|
144 |
-
continue;
|
145 |
-
}
|
146 |
-
|
147 |
-
if ($this->useShortAttachment) {
|
148 |
-
$attachment['fields'][] = $this->generateAttachmentField(
|
149 |
-
$key,
|
150 |
-
$record[$key]
|
151 |
-
);
|
152 |
-
} else {
|
153 |
-
// Add all extra fields as individual fields in attachment
|
154 |
-
$attachment['fields'] = array_merge(
|
155 |
-
$attachment['fields'],
|
156 |
-
$this->generateAttachmentFields($record[$key])
|
157 |
-
);
|
158 |
-
}
|
159 |
-
}
|
160 |
-
}
|
161 |
-
|
162 |
-
$dataArray['attachments'] = array($attachment);
|
163 |
-
} else {
|
164 |
-
$dataArray['text'] = $message;
|
165 |
-
}
|
166 |
-
|
167 |
-
if ($this->userIcon) {
|
168 |
-
if (filter_var($this->userIcon, FILTER_VALIDATE_URL)) {
|
169 |
-
$dataArray['icon_url'] = $this->userIcon;
|
170 |
-
} else {
|
171 |
-
$dataArray['icon_emoji'] = ":{$this->userIcon}:";
|
172 |
-
}
|
173 |
-
}
|
174 |
-
|
175 |
-
return $dataArray;
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Returned a Slack message attachment color associated with
|
180 |
-
* provided level.
|
181 |
-
*
|
182 |
-
* @param int $level
|
183 |
-
* @return string
|
184 |
-
*/
|
185 |
-
public function getAttachmentColor($level)
|
186 |
-
{
|
187 |
-
switch (true) {
|
188 |
-
case $level >= Logger::ERROR:
|
189 |
-
return self::COLOR_DANGER;
|
190 |
-
case $level >= Logger::WARNING:
|
191 |
-
return self::COLOR_WARNING;
|
192 |
-
case $level >= Logger::INFO:
|
193 |
-
return self::COLOR_GOOD;
|
194 |
-
default:
|
195 |
-
return self::COLOR_DEFAULT;
|
196 |
-
}
|
197 |
-
}
|
198 |
-
|
199 |
-
/**
|
200 |
-
* Stringifies an array of key/value pairs to be used in attachment fields
|
201 |
-
*
|
202 |
-
* @param array $fields
|
203 |
-
*
|
204 |
-
* @return string
|
205 |
-
*/
|
206 |
-
public function stringify($fields)
|
207 |
-
{
|
208 |
-
$normalized = $this->normalizerFormatter->format($fields);
|
209 |
-
$prettyPrintFlag = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 128;
|
210 |
-
|
211 |
-
$hasSecondDimension = count(array_filter($normalized, 'is_array'));
|
212 |
-
$hasNonNumericKeys = !count(array_filter(array_keys($normalized), 'is_numeric'));
|
213 |
-
|
214 |
-
return $hasSecondDimension || $hasNonNumericKeys
|
215 |
-
? json_encode($normalized, $prettyPrintFlag)
|
216 |
-
: json_encode($normalized);
|
217 |
-
}
|
218 |
-
|
219 |
-
/**
|
220 |
-
* Sets the formatter
|
221 |
-
*
|
222 |
-
* @param FormatterInterface $formatter
|
223 |
-
*/
|
224 |
-
public function setFormatter(FormatterInterface $formatter)
|
225 |
-
{
|
226 |
-
$this->formatter = $formatter;
|
227 |
-
}
|
228 |
-
|
229 |
-
/**
|
230 |
-
* Generates attachment field
|
231 |
-
*
|
232 |
-
* @param string $title
|
233 |
-
* @param string|array $value
|
234 |
-
*
|
235 |
-
* @return array
|
236 |
-
*/
|
237 |
-
private function generateAttachmentField($title, $value)
|
238 |
-
{
|
239 |
-
$value = is_array($value)
|
240 |
-
? sprintf('```%s```', $this->stringify($value))
|
241 |
-
: $value;
|
242 |
-
|
243 |
-
return array(
|
244 |
-
'title' => ucfirst($title),
|
245 |
-
'value' => $value,
|
246 |
-
'short' => false
|
247 |
-
);
|
248 |
-
}
|
249 |
-
|
250 |
-
/**
|
251 |
-
* Generates a collection of attachment fields from array
|
252 |
-
*
|
253 |
-
* @param array $data
|
254 |
-
*
|
255 |
-
* @return array
|
256 |
-
*/
|
257 |
-
private function generateAttachmentFields(array $data)
|
258 |
-
{
|
259 |
-
$fields = array();
|
260 |
-
foreach ($this->normalizerFormatter->format($data) as $key => $value) {
|
261 |
-
$fields[] = $this->generateAttachmentField($key, $value);
|
262 |
-
}
|
263 |
-
|
264 |
-
return $fields;
|
265 |
-
}
|
266 |
-
|
267 |
-
/**
|
268 |
-
* Get a copy of record with fields excluded according to $this->excludeFields
|
269 |
-
*
|
270 |
-
* @param array $record
|
271 |
-
*
|
272 |
-
* @return array
|
273 |
-
*/
|
274 |
-
private function excludeFields(array $record)
|
275 |
-
{
|
276 |
-
foreach ($this->excludeFields as $field) {
|
277 |
-
$keys = explode('.', $field);
|
278 |
-
$node = &$record;
|
279 |
-
$lastKey = end($keys);
|
280 |
-
foreach ($keys as $key) {
|
281 |
-
if (!isset($node[$key])) {
|
282 |
-
break;
|
283 |
-
}
|
284 |
-
if ($lastKey === $key) {
|
285 |
-
unset($node[$key]);
|
286 |
-
break;
|
287 |
-
}
|
288 |
-
$node = &$node[$key];
|
289 |
-
}
|
290 |
-
}
|
291 |
-
|
292 |
-
return $record;
|
293 |
-
}
|
294 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php
DELETED
@@ -1,220 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\FormatterInterface;
|
15 |
-
use Monolog\Logger;
|
16 |
-
use Monolog\Handler\Slack\SlackRecord;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Sends notifications through Slack API
|
20 |
-
*
|
21 |
-
* @author Greg Kedzierski <greg@gregkedzierski.com>
|
22 |
-
* @see https://api.slack.com/
|
23 |
-
*/
|
24 |
-
class SlackHandler extends SocketHandler
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Slack API token
|
28 |
-
* @var string
|
29 |
-
*/
|
30 |
-
private $token;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Instance of the SlackRecord util class preparing data for Slack API.
|
34 |
-
* @var SlackRecord
|
35 |
-
*/
|
36 |
-
private $slackRecord;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @param string $token Slack API token
|
40 |
-
* @param string $channel Slack channel (encoded ID or name)
|
41 |
-
* @param string|null $username Name of a bot
|
42 |
-
* @param bool $useAttachment Whether the message should be added to Slack as attachment (plain text otherwise)
|
43 |
-
* @param string|null $iconEmoji The emoji name to use (or null)
|
44 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
45 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
46 |
-
* @param bool $useShortAttachment Whether the the context/extra messages added to Slack as attachments are in a short style
|
47 |
-
* @param bool $includeContextAndExtra Whether the attachment should include context and extra data
|
48 |
-
* @param array $excludeFields Dot separated list of fields to exclude from slack message. E.g. ['context.field1', 'extra.field2']
|
49 |
-
* @throws MissingExtensionException If no OpenSSL PHP extension configured
|
50 |
-
*/
|
51 |
-
public function __construct($token, $channel, $username = null, $useAttachment = true, $iconEmoji = null, $level = Logger::CRITICAL, $bubble = true, $useShortAttachment = false, $includeContextAndExtra = false, array $excludeFields = array())
|
52 |
-
{
|
53 |
-
if (!extension_loaded('openssl')) {
|
54 |
-
throw new MissingExtensionException('The OpenSSL PHP extension is required to use the SlackHandler');
|
55 |
-
}
|
56 |
-
|
57 |
-
parent::__construct('ssl://slack.com:443', $level, $bubble);
|
58 |
-
|
59 |
-
$this->slackRecord = new SlackRecord(
|
60 |
-
$channel,
|
61 |
-
$username,
|
62 |
-
$useAttachment,
|
63 |
-
$iconEmoji,
|
64 |
-
$useShortAttachment,
|
65 |
-
$includeContextAndExtra,
|
66 |
-
$excludeFields,
|
67 |
-
$this->formatter
|
68 |
-
);
|
69 |
-
|
70 |
-
$this->token = $token;
|
71 |
-
}
|
72 |
-
|
73 |
-
public function getSlackRecord()
|
74 |
-
{
|
75 |
-
return $this->slackRecord;
|
76 |
-
}
|
77 |
-
|
78 |
-
public function getToken()
|
79 |
-
{
|
80 |
-
return $this->token;
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* {@inheritdoc}
|
85 |
-
*
|
86 |
-
* @param array $record
|
87 |
-
* @return string
|
88 |
-
*/
|
89 |
-
protected function generateDataStream($record)
|
90 |
-
{
|
91 |
-
$content = $this->buildContent($record);
|
92 |
-
|
93 |
-
return $this->buildHeader($content) . $content;
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Builds the body of API call
|
98 |
-
*
|
99 |
-
* @param array $record
|
100 |
-
* @return string
|
101 |
-
*/
|
102 |
-
private function buildContent($record)
|
103 |
-
{
|
104 |
-
$dataArray = $this->prepareContentData($record);
|
105 |
-
|
106 |
-
return http_build_query($dataArray);
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Prepares content data
|
111 |
-
*
|
112 |
-
* @param array $record
|
113 |
-
* @return array
|
114 |
-
*/
|
115 |
-
protected function prepareContentData($record)
|
116 |
-
{
|
117 |
-
$dataArray = $this->slackRecord->getSlackData($record);
|
118 |
-
$dataArray['token'] = $this->token;
|
119 |
-
|
120 |
-
if (!empty($dataArray['attachments'])) {
|
121 |
-
$dataArray['attachments'] = json_encode($dataArray['attachments']);
|
122 |
-
}
|
123 |
-
|
124 |
-
return $dataArray;
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* Builds the header of the API Call
|
129 |
-
*
|
130 |
-
* @param string $content
|
131 |
-
* @return string
|
132 |
-
*/
|
133 |
-
private function buildHeader($content)
|
134 |
-
{
|
135 |
-
$header = "POST /api/chat.postMessage HTTP/1.1\r\n";
|
136 |
-
$header .= "Host: slack.com\r\n";
|
137 |
-
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
138 |
-
$header .= "Content-Length: " . strlen($content) . "\r\n";
|
139 |
-
$header .= "\r\n";
|
140 |
-
|
141 |
-
return $header;
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* {@inheritdoc}
|
146 |
-
*
|
147 |
-
* @param array $record
|
148 |
-
*/
|
149 |
-
protected function write(array $record)
|
150 |
-
{
|
151 |
-
parent::write($record);
|
152 |
-
$this->finalizeWrite();
|
153 |
-
}
|
154 |
-
|
155 |
-
/**
|
156 |
-
* Finalizes the request by reading some bytes and then closing the socket
|
157 |
-
*
|
158 |
-
* If we do not read some but close the socket too early, slack sometimes
|
159 |
-
* drops the request entirely.
|
160 |
-
*/
|
161 |
-
protected function finalizeWrite()
|
162 |
-
{
|
163 |
-
$res = $this->getResource();
|
164 |
-
if (is_resource($res)) {
|
165 |
-
@fread($res, 2048);
|
166 |
-
}
|
167 |
-
$this->closeSocket();
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Returned a Slack message attachment color associated with
|
172 |
-
* provided level.
|
173 |
-
*
|
174 |
-
* @param int $level
|
175 |
-
* @return string
|
176 |
-
* @deprecated Use underlying SlackRecord instead
|
177 |
-
*/
|
178 |
-
protected function getAttachmentColor($level)
|
179 |
-
{
|
180 |
-
trigger_error(
|
181 |
-
'SlackHandler::getAttachmentColor() is deprecated. Use underlying SlackRecord instead.',
|
182 |
-
E_USER_DEPRECATED
|
183 |
-
);
|
184 |
-
|
185 |
-
return $this->slackRecord->getAttachmentColor($level);
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* Stringifies an array of key/value pairs to be used in attachment fields
|
190 |
-
*
|
191 |
-
* @param array $fields
|
192 |
-
* @return string
|
193 |
-
* @deprecated Use underlying SlackRecord instead
|
194 |
-
*/
|
195 |
-
protected function stringify($fields)
|
196 |
-
{
|
197 |
-
trigger_error(
|
198 |
-
'SlackHandler::stringify() is deprecated. Use underlying SlackRecord instead.',
|
199 |
-
E_USER_DEPRECATED
|
200 |
-
);
|
201 |
-
|
202 |
-
return $this->slackRecord->stringify($fields);
|
203 |
-
}
|
204 |
-
|
205 |
-
public function setFormatter(FormatterInterface $formatter)
|
206 |
-
{
|
207 |
-
parent::setFormatter($formatter);
|
208 |
-
$this->slackRecord->setFormatter($formatter);
|
209 |
-
|
210 |
-
return $this;
|
211 |
-
}
|
212 |
-
|
213 |
-
public function getFormatter()
|
214 |
-
{
|
215 |
-
$formatter = parent::getFormatter();
|
216 |
-
$this->slackRecord->setFormatter($formatter);
|
217 |
-
|
218 |
-
return $formatter;
|
219 |
-
}
|
220 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php
DELETED
@@ -1,120 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Formatter\FormatterInterface;
|
15 |
-
use Monolog\Logger;
|
16 |
-
use Monolog\Handler\Slack\SlackRecord;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Sends notifications through Slack Webhooks
|
20 |
-
*
|
21 |
-
* @author Haralan Dobrev <hkdobrev@gmail.com>
|
22 |
-
* @see https://api.slack.com/incoming-webhooks
|
23 |
-
*/
|
24 |
-
class SlackWebhookHandler extends AbstractProcessingHandler
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Slack Webhook token
|
28 |
-
* @var string
|
29 |
-
*/
|
30 |
-
private $webhookUrl;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Instance of the SlackRecord util class preparing data for Slack API.
|
34 |
-
* @var SlackRecord
|
35 |
-
*/
|
36 |
-
private $slackRecord;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @param string $webhookUrl Slack Webhook URL
|
40 |
-
* @param string|null $channel Slack channel (encoded ID or name)
|
41 |
-
* @param string|null $username Name of a bot
|
42 |
-
* @param bool $useAttachment Whether the message should be added to Slack as attachment (plain text otherwise)
|
43 |
-
* @param string|null $iconEmoji The emoji name to use (or null)
|
44 |
-
* @param bool $useShortAttachment Whether the the context/extra messages added to Slack as attachments are in a short style
|
45 |
-
* @param bool $includeContextAndExtra Whether the attachment should include context and extra data
|
46 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
47 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
48 |
-
* @param array $excludeFields Dot separated list of fields to exclude from slack message. E.g. ['context.field1', 'extra.field2']
|
49 |
-
*/
|
50 |
-
public function __construct($webhookUrl, $channel = null, $username = null, $useAttachment = true, $iconEmoji = null, $useShortAttachment = false, $includeContextAndExtra = false, $level = Logger::CRITICAL, $bubble = true, array $excludeFields = array())
|
51 |
-
{
|
52 |
-
parent::__construct($level, $bubble);
|
53 |
-
|
54 |
-
$this->webhookUrl = $webhookUrl;
|
55 |
-
|
56 |
-
$this->slackRecord = new SlackRecord(
|
57 |
-
$channel,
|
58 |
-
$username,
|
59 |
-
$useAttachment,
|
60 |
-
$iconEmoji,
|
61 |
-
$useShortAttachment,
|
62 |
-
$includeContextAndExtra,
|
63 |
-
$excludeFields,
|
64 |
-
$this->formatter
|
65 |
-
);
|
66 |
-
}
|
67 |
-
|
68 |
-
public function getSlackRecord()
|
69 |
-
{
|
70 |
-
return $this->slackRecord;
|
71 |
-
}
|
72 |
-
|
73 |
-
public function getWebhookUrl()
|
74 |
-
{
|
75 |
-
return $this->webhookUrl;
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* {@inheritdoc}
|
80 |
-
*
|
81 |
-
* @param array $record
|
82 |
-
*/
|
83 |
-
protected function write(array $record)
|
84 |
-
{
|
85 |
-
$postData = $this->slackRecord->getSlackData($record);
|
86 |
-
$postString = json_encode($postData);
|
87 |
-
|
88 |
-
$ch = curl_init();
|
89 |
-
$options = array(
|
90 |
-
CURLOPT_URL => $this->webhookUrl,
|
91 |
-
CURLOPT_POST => true,
|
92 |
-
CURLOPT_RETURNTRANSFER => true,
|
93 |
-
CURLOPT_HTTPHEADER => array('Content-type: application/json'),
|
94 |
-
CURLOPT_POSTFIELDS => $postString
|
95 |
-
);
|
96 |
-
if (defined('CURLOPT_SAFE_UPLOAD')) {
|
97 |
-
$options[CURLOPT_SAFE_UPLOAD] = true;
|
98 |
-
}
|
99 |
-
|
100 |
-
curl_setopt_array($ch, $options);
|
101 |
-
|
102 |
-
Curl\Util::execute($ch);
|
103 |
-
}
|
104 |
-
|
105 |
-
public function setFormatter(FormatterInterface $formatter)
|
106 |
-
{
|
107 |
-
parent::setFormatter($formatter);
|
108 |
-
$this->slackRecord->setFormatter($formatter);
|
109 |
-
|
110 |
-
return $this;
|
111 |
-
}
|
112 |
-
|
113 |
-
public function getFormatter()
|
114 |
-
{
|
115 |
-
$formatter = parent::getFormatter();
|
116 |
-
$this->slackRecord->setFormatter($formatter);
|
117 |
-
|
118 |
-
return $formatter;
|
119 |
-
}
|
120 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/SlackbotHandler.php
DELETED
@@ -1,84 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Sends notifications through Slack's Slackbot
|
18 |
-
*
|
19 |
-
* @author Haralan Dobrev <hkdobrev@gmail.com>
|
20 |
-
* @see https://slack.com/apps/A0F81R8ET-slackbot
|
21 |
-
* @deprecated According to Slack the API used on this handler it is deprecated.
|
22 |
-
* Therefore this handler will be removed on 2.x
|
23 |
-
* Slack suggests to use webhooks instead. Please contact slack for more information.
|
24 |
-
*/
|
25 |
-
class SlackbotHandler extends AbstractProcessingHandler
|
26 |
-
{
|
27 |
-
/**
|
28 |
-
* The slug of the Slack team
|
29 |
-
* @var string
|
30 |
-
*/
|
31 |
-
private $slackTeam;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Slackbot token
|
35 |
-
* @var string
|
36 |
-
*/
|
37 |
-
private $token;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Slack channel name
|
41 |
-
* @var string
|
42 |
-
*/
|
43 |
-
private $channel;
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @param string $slackTeam Slack team slug
|
47 |
-
* @param string $token Slackbot token
|
48 |
-
* @param string $channel Slack channel (encoded ID or name)
|
49 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
50 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
51 |
-
*/
|
52 |
-
public function __construct($slackTeam, $token, $channel, $level = Logger::CRITICAL, $bubble = true)
|
53 |
-
{
|
54 |
-
@trigger_error('SlackbotHandler is deprecated and will be removed on 2.x', E_USER_DEPRECATED);
|
55 |
-
parent::__construct($level, $bubble);
|
56 |
-
|
57 |
-
$this->slackTeam = $slackTeam;
|
58 |
-
$this->token = $token;
|
59 |
-
$this->channel = $channel;
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* {@inheritdoc}
|
64 |
-
*
|
65 |
-
* @param array $record
|
66 |
-
*/
|
67 |
-
protected function write(array $record)
|
68 |
-
{
|
69 |
-
$slackbotUrl = sprintf(
|
70 |
-
'https://%s.slack.com/services/hooks/slackbot?token=%s&channel=%s',
|
71 |
-
$this->slackTeam,
|
72 |
-
$this->token,
|
73 |
-
$this->channel
|
74 |
-
);
|
75 |
-
|
76 |
-
$ch = curl_init();
|
77 |
-
curl_setopt($ch, CURLOPT_URL, $slackbotUrl);
|
78 |
-
curl_setopt($ch, CURLOPT_POST, true);
|
79 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
80 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $record['message']);
|
81 |
-
|
82 |
-
Curl\Util::execute($ch);
|
83 |
-
}
|
84 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php
DELETED
@@ -1,385 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Stores to any socket - uses fsockopen() or pfsockopen().
|
18 |
-
*
|
19 |
-
* @author Pablo de Leon Belloc <pablolb@gmail.com>
|
20 |
-
* @see http://php.net/manual/en/function.fsockopen.php
|
21 |
-
*/
|
22 |
-
class SocketHandler extends AbstractProcessingHandler
|
23 |
-
{
|
24 |
-
private $connectionString;
|
25 |
-
private $connectionTimeout;
|
26 |
-
private $resource;
|
27 |
-
private $timeout = 0;
|
28 |
-
private $writingTimeout = 10;
|
29 |
-
private $lastSentBytes = null;
|
30 |
-
private $chunkSize = null;
|
31 |
-
private $persistent = false;
|
32 |
-
private $errno;
|
33 |
-
private $errstr;
|
34 |
-
private $lastWritingAt;
|
35 |
-
|
36 |
-
/**
|
37 |
-
* @param string $connectionString Socket connection string
|
38 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
39 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
40 |
-
*/
|
41 |
-
public function __construct($connectionString, $level = Logger::DEBUG, $bubble = true)
|
42 |
-
{
|
43 |
-
parent::__construct($level, $bubble);
|
44 |
-
$this->connectionString = $connectionString;
|
45 |
-
$this->connectionTimeout = (float) ini_get('default_socket_timeout');
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Connect (if necessary) and write to the socket
|
50 |
-
*
|
51 |
-
* @param array $record
|
52 |
-
*
|
53 |
-
* @throws \UnexpectedValueException
|
54 |
-
* @throws \RuntimeException
|
55 |
-
*/
|
56 |
-
protected function write(array $record)
|
57 |
-
{
|
58 |
-
$this->connectIfNotConnected();
|
59 |
-
$data = $this->generateDataStream($record);
|
60 |
-
$this->writeToSocket($data);
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* We will not close a PersistentSocket instance so it can be reused in other requests.
|
65 |
-
*/
|
66 |
-
public function close()
|
67 |
-
{
|
68 |
-
if (!$this->isPersistent()) {
|
69 |
-
$this->closeSocket();
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Close socket, if open
|
75 |
-
*/
|
76 |
-
public function closeSocket()
|
77 |
-
{
|
78 |
-
if (is_resource($this->resource)) {
|
79 |
-
fclose($this->resource);
|
80 |
-
$this->resource = null;
|
81 |
-
}
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Set socket connection to nbe persistent. It only has effect before the connection is initiated.
|
86 |
-
*
|
87 |
-
* @param bool $persistent
|
88 |
-
*/
|
89 |
-
public function setPersistent($persistent)
|
90 |
-
{
|
91 |
-
$this->persistent = (bool) $persistent;
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Set connection timeout. Only has effect before we connect.
|
96 |
-
*
|
97 |
-
* @param float $seconds
|
98 |
-
*
|
99 |
-
* @see http://php.net/manual/en/function.fsockopen.php
|
100 |
-
*/
|
101 |
-
public function setConnectionTimeout($seconds)
|
102 |
-
{
|
103 |
-
$this->validateTimeout($seconds);
|
104 |
-
$this->connectionTimeout = (float) $seconds;
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Set write timeout. Only has effect before we connect.
|
109 |
-
*
|
110 |
-
* @param float $seconds
|
111 |
-
*
|
112 |
-
* @see http://php.net/manual/en/function.stream-set-timeout.php
|
113 |
-
*/
|
114 |
-
public function setTimeout($seconds)
|
115 |
-
{
|
116 |
-
$this->validateTimeout($seconds);
|
117 |
-
$this->timeout = (float) $seconds;
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* Set writing timeout. Only has effect during connection in the writing cycle.
|
122 |
-
*
|
123 |
-
* @param float $seconds 0 for no timeout
|
124 |
-
*/
|
125 |
-
public function setWritingTimeout($seconds)
|
126 |
-
{
|
127 |
-
$this->validateTimeout($seconds);
|
128 |
-
$this->writingTimeout = (float) $seconds;
|
129 |
-
}
|
130 |
-
|
131 |
-
/**
|
132 |
-
* Set chunk size. Only has effect during connection in the writing cycle.
|
133 |
-
*
|
134 |
-
* @param float $bytes
|
135 |
-
*/
|
136 |
-
public function setChunkSize($bytes)
|
137 |
-
{
|
138 |
-
$this->chunkSize = $bytes;
|
139 |
-
}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Get current connection string
|
143 |
-
*
|
144 |
-
* @return string
|
145 |
-
*/
|
146 |
-
public function getConnectionString()
|
147 |
-
{
|
148 |
-
return $this->connectionString;
|
149 |
-
}
|
150 |
-
|
151 |
-
/**
|
152 |
-
* Get persistent setting
|
153 |
-
*
|
154 |
-
* @return bool
|
155 |
-
*/
|
156 |
-
public function isPersistent()
|
157 |
-
{
|
158 |
-
return $this->persistent;
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Get current connection timeout setting
|
163 |
-
*
|
164 |
-
* @return float
|
165 |
-
*/
|
166 |
-
public function getConnectionTimeout()
|
167 |
-
{
|
168 |
-
return $this->connectionTimeout;
|
169 |
-
}
|
170 |
-
|
171 |
-
/**
|
172 |
-
* Get current in-transfer timeout
|
173 |
-
*
|
174 |
-
* @return float
|
175 |
-
*/
|
176 |
-
public function getTimeout()
|
177 |
-
{
|
178 |
-
return $this->timeout;
|
179 |
-
}
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Get current local writing timeout
|
183 |
-
*
|
184 |
-
* @return float
|
185 |
-
*/
|
186 |
-
public function getWritingTimeout()
|
187 |
-
{
|
188 |
-
return $this->writingTimeout;
|
189 |
-
}
|
190 |
-
|
191 |
-
/**
|
192 |
-
* Get current chunk size
|
193 |
-
*
|
194 |
-
* @return float
|
195 |
-
*/
|
196 |
-
public function getChunkSize()
|
197 |
-
{
|
198 |
-
return $this->chunkSize;
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* Check to see if the socket is currently available.
|
203 |
-
*
|
204 |
-
* UDP might appear to be connected but might fail when writing. See http://php.net/fsockopen for details.
|
205 |
-
*
|
206 |
-
* @return bool
|
207 |
-
*/
|
208 |
-
public function isConnected()
|
209 |
-
{
|
210 |
-
return is_resource($this->resource)
|
211 |
-
&& !feof($this->resource); // on TCP - other party can close connection.
|
212 |
-
}
|
213 |
-
|
214 |
-
/**
|
215 |
-
* Wrapper to allow mocking
|
216 |
-
*/
|
217 |
-
protected function pfsockopen()
|
218 |
-
{
|
219 |
-
return @pfsockopen($this->connectionString, -1, $this->errno, $this->errstr, $this->connectionTimeout);
|
220 |
-
}
|
221 |
-
|
222 |
-
/**
|
223 |
-
* Wrapper to allow mocking
|
224 |
-
*/
|
225 |
-
protected function fsockopen()
|
226 |
-
{
|
227 |
-
return @fsockopen($this->connectionString, -1, $this->errno, $this->errstr, $this->connectionTimeout);
|
228 |
-
}
|
229 |
-
|
230 |
-
/**
|
231 |
-
* Wrapper to allow mocking
|
232 |
-
*
|
233 |
-
* @see http://php.net/manual/en/function.stream-set-timeout.php
|
234 |
-
*/
|
235 |
-
protected function streamSetTimeout()
|
236 |
-
{
|
237 |
-
$seconds = floor($this->timeout);
|
238 |
-
$microseconds = round(($this->timeout - $seconds) * 1e6);
|
239 |
-
|
240 |
-
return stream_set_timeout($this->resource, $seconds, $microseconds);
|
241 |
-
}
|
242 |
-
|
243 |
-
/**
|
244 |
-
* Wrapper to allow mocking
|
245 |
-
*
|
246 |
-
* @see http://php.net/manual/en/function.stream-set-chunk-size.php
|
247 |
-
*/
|
248 |
-
protected function streamSetChunkSize()
|
249 |
-
{
|
250 |
-
return stream_set_chunk_size($this->resource, $this->chunkSize);
|
251 |
-
}
|
252 |
-
|
253 |
-
/**
|
254 |
-
* Wrapper to allow mocking
|
255 |
-
*/
|
256 |
-
protected function fwrite($data)
|
257 |
-
{
|
258 |
-
return @fwrite($this->resource, $data);
|
259 |
-
}
|
260 |
-
|
261 |
-
/**
|
262 |
-
* Wrapper to allow mocking
|
263 |
-
*/
|
264 |
-
protected function streamGetMetadata()
|
265 |
-
{
|
266 |
-
return stream_get_meta_data($this->resource);
|
267 |
-
}
|
268 |
-
|
269 |
-
private function validateTimeout($value)
|
270 |
-
{
|
271 |
-
$ok = filter_var($value, FILTER_VALIDATE_FLOAT);
|
272 |
-
if ($ok === false || $value < 0) {
|
273 |
-
throw new \InvalidArgumentException("Timeout must be 0 or a positive float (got $value)");
|
274 |
-
}
|
275 |
-
}
|
276 |
-
|
277 |
-
private function connectIfNotConnected()
|
278 |
-
{
|
279 |
-
if ($this->isConnected()) {
|
280 |
-
return;
|
281 |
-
}
|
282 |
-
$this->connect();
|
283 |
-
}
|
284 |
-
|
285 |
-
protected function generateDataStream($record)
|
286 |
-
{
|
287 |
-
return (string) $record['formatted'];
|
288 |
-
}
|
289 |
-
|
290 |
-
/**
|
291 |
-
* @return resource|null
|
292 |
-
*/
|
293 |
-
protected function getResource()
|
294 |
-
{
|
295 |
-
return $this->resource;
|
296 |
-
}
|
297 |
-
|
298 |
-
private function connect()
|
299 |
-
{
|
300 |
-
$this->createSocketResource();
|
301 |
-
$this->setSocketTimeout();
|
302 |
-
$this->setStreamChunkSize();
|
303 |
-
}
|
304 |
-
|
305 |
-
private function createSocketResource()
|
306 |
-
{
|
307 |
-
if ($this->isPersistent()) {
|
308 |
-
$resource = $this->pfsockopen();
|
309 |
-
} else {
|
310 |
-
$resource = $this->fsockopen();
|
311 |
-
}
|
312 |
-
if (!$resource) {
|
313 |
-
throw new \UnexpectedValueException("Failed connecting to $this->connectionString ($this->errno: $this->errstr)");
|
314 |
-
}
|
315 |
-
$this->resource = $resource;
|
316 |
-
}
|
317 |
-
|
318 |
-
private function setSocketTimeout()
|
319 |
-
{
|
320 |
-
if (!$this->streamSetTimeout()) {
|
321 |
-
throw new \UnexpectedValueException("Failed setting timeout with stream_set_timeout()");
|
322 |
-
}
|
323 |
-
}
|
324 |
-
|
325 |
-
private function setStreamChunkSize()
|
326 |
-
{
|
327 |
-
if ($this->chunkSize && !$this->streamSetChunkSize()) {
|
328 |
-
throw new \UnexpectedValueException("Failed setting chunk size with stream_set_chunk_size()");
|
329 |
-
}
|
330 |
-
}
|
331 |
-
|
332 |
-
private function writeToSocket($data)
|
333 |
-
{
|
334 |
-
$length = strlen($data);
|
335 |
-
$sent = 0;
|
336 |
-
$this->lastSentBytes = $sent;
|
337 |
-
while ($this->isConnected() && $sent < $length) {
|
338 |
-
if (0 == $sent) {
|
339 |
-
$chunk = $this->fwrite($data);
|
340 |
-
} else {
|
341 |
-
$chunk = $this->fwrite(substr($data, $sent));
|
342 |
-
}
|
343 |
-
if ($chunk === false) {
|
344 |
-
throw new \RuntimeException("Could not write to socket");
|
345 |
-
}
|
346 |
-
$sent += $chunk;
|
347 |
-
$socketInfo = $this->streamGetMetadata();
|
348 |
-
if ($socketInfo['timed_out']) {
|
349 |
-
throw new \RuntimeException("Write timed-out");
|
350 |
-
}
|
351 |
-
|
352 |
-
if ($this->writingIsTimedOut($sent)) {
|
353 |
-
throw new \RuntimeException("Write timed-out, no data sent for `{$this->writingTimeout}` seconds, probably we got disconnected (sent $sent of $length)");
|
354 |
-
}
|
355 |
-
}
|
356 |
-
if (!$this->isConnected() && $sent < $length) {
|
357 |
-
throw new \RuntimeException("End-of-file reached, probably we got disconnected (sent $sent of $length)");
|
358 |
-
}
|
359 |
-
}
|
360 |
-
|
361 |
-
private function writingIsTimedOut($sent)
|
362 |
-
{
|
363 |
-
$writingTimeout = (int) floor($this->writingTimeout);
|
364 |
-
if (0 === $writingTimeout) {
|
365 |
-
return false;
|
366 |
-
}
|
367 |
-
|
368 |
-
if ($sent !== $this->lastSentBytes) {
|
369 |
-
$this->lastWritingAt = time();
|
370 |
-
$this->lastSentBytes = $sent;
|
371 |
-
|
372 |
-
return false;
|
373 |
-
} else {
|
374 |
-
usleep(100);
|
375 |
-
}
|
376 |
-
|
377 |
-
if ((time() - $this->lastWritingAt) >= $writingTimeout) {
|
378 |
-
$this->closeSocket();
|
379 |
-
|
380 |
-
return true;
|
381 |
-
}
|
382 |
-
|
383 |
-
return false;
|
384 |
-
}
|
385 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php
DELETED
@@ -1,177 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Stores to any stream resource
|
18 |
-
*
|
19 |
-
* Can be used to store into php://stderr, remote and local files, etc.
|
20 |
-
*
|
21 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
22 |
-
*/
|
23 |
-
class StreamHandler extends AbstractProcessingHandler
|
24 |
-
{
|
25 |
-
protected $stream;
|
26 |
-
protected $url;
|
27 |
-
private $errorMessage;
|
28 |
-
protected $filePermission;
|
29 |
-
protected $useLocking;
|
30 |
-
private $dirCreated;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @param resource|string $stream
|
34 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
35 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
36 |
-
* @param int|null $filePermission Optional file permissions (default (0644) are only for owner read/write)
|
37 |
-
* @param bool $useLocking Try to lock log file before doing any writes
|
38 |
-
*
|
39 |
-
* @throws \Exception If a missing directory is not buildable
|
40 |
-
* @throws \InvalidArgumentException If stream is not a resource or string
|
41 |
-
*/
|
42 |
-
public function __construct($stream, $level = Logger::DEBUG, $bubble = true, $filePermission = null, $useLocking = false)
|
43 |
-
{
|
44 |
-
parent::__construct($level, $bubble);
|
45 |
-
if (is_resource($stream)) {
|
46 |
-
$this->stream = $stream;
|
47 |
-
} elseif (is_string($stream)) {
|
48 |
-
$this->url = $stream;
|
49 |
-
} else {
|
50 |
-
throw new \InvalidArgumentException('A stream must either be a resource or a string.');
|
51 |
-
}
|
52 |
-
|
53 |
-
$this->filePermission = $filePermission;
|
54 |
-
$this->useLocking = $useLocking;
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* {@inheritdoc}
|
59 |
-
*/
|
60 |
-
public function close()
|
61 |
-
{
|
62 |
-
if ($this->url && is_resource($this->stream)) {
|
63 |
-
fclose($this->stream);
|
64 |
-
}
|
65 |
-
$this->stream = null;
|
66 |
-
$this->dirCreated = null;
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Return the currently active stream if it is open
|
71 |
-
*
|
72 |
-
* @return resource|null
|
73 |
-
*/
|
74 |
-
public function getStream()
|
75 |
-
{
|
76 |
-
return $this->stream;
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Return the stream URL if it was configured with a URL and not an active resource
|
81 |
-
*
|
82 |
-
* @return string|null
|
83 |
-
*/
|
84 |
-
public function getUrl()
|
85 |
-
{
|
86 |
-
return $this->url;
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* {@inheritdoc}
|
91 |
-
*/
|
92 |
-
protected function write(array $record)
|
93 |
-
{
|
94 |
-
if (!is_resource($this->stream)) {
|
95 |
-
if (null === $this->url || '' === $this->url) {
|
96 |
-
throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().');
|
97 |
-
}
|
98 |
-
$this->createDir();
|
99 |
-
$this->errorMessage = null;
|
100 |
-
set_error_handler(array($this, 'customErrorHandler'));
|
101 |
-
$this->stream = fopen($this->url, 'a');
|
102 |
-
if ($this->filePermission !== null) {
|
103 |
-
@chmod($this->url, $this->filePermission);
|
104 |
-
}
|
105 |
-
restore_error_handler();
|
106 |
-
if (!is_resource($this->stream)) {
|
107 |
-
$this->stream = null;
|
108 |
-
throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: '.$this->errorMessage, $this->url));
|
109 |
-
}
|
110 |
-
}
|
111 |
-
|
112 |
-
if ($this->useLocking) {
|
113 |
-
// ignoring errors here, there's not much we can do about them
|
114 |
-
flock($this->stream, LOCK_EX);
|
115 |
-
}
|
116 |
-
|
117 |
-
$this->streamWrite($this->stream, $record);
|
118 |
-
|
119 |
-
if ($this->useLocking) {
|
120 |
-
flock($this->stream, LOCK_UN);
|
121 |
-
}
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* Write to stream
|
126 |
-
* @param resource $stream
|
127 |
-
* @param array $record
|
128 |
-
*/
|
129 |
-
protected function streamWrite($stream, array $record)
|
130 |
-
{
|
131 |
-
fwrite($stream, (string) $record['formatted']);
|
132 |
-
}
|
133 |
-
|
134 |
-
private function customErrorHandler($code, $msg)
|
135 |
-
{
|
136 |
-
$this->errorMessage = preg_replace('{^(fopen|mkdir)\(.*?\): }', '', $msg);
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* @param string $stream
|
141 |
-
*
|
142 |
-
* @return null|string
|
143 |
-
*/
|
144 |
-
private function getDirFromStream($stream)
|
145 |
-
{
|
146 |
-
$pos = strpos($stream, '://');
|
147 |
-
if ($pos === false) {
|
148 |
-
return dirname($stream);
|
149 |
-
}
|
150 |
-
|
151 |
-
if ('file://' === substr($stream, 0, 7)) {
|
152 |
-
return dirname(substr($stream, 7));
|
153 |
-
}
|
154 |
-
|
155 |
-
return;
|
156 |
-
}
|
157 |
-
|
158 |
-
private function createDir()
|
159 |
-
{
|
160 |
-
// Do not try to create dir if it has already been tried.
|
161 |
-
if ($this->dirCreated) {
|
162 |
-
return;
|
163 |
-
}
|
164 |
-
|
165 |
-
$dir = $this->getDirFromStream($this->url);
|
166 |
-
if (null !== $dir && !is_dir($dir)) {
|
167 |
-
$this->errorMessage = null;
|
168 |
-
set_error_handler(array($this, 'customErrorHandler'));
|
169 |
-
$status = mkdir($dir, 0777, true);
|
170 |
-
restore_error_handler();
|
171 |
-
if (false === $status && !is_dir($dir)) {
|
172 |
-
throw new \UnexpectedValueException(sprintf('There is no existing directory at "%s" and its not buildable: '.$this->errorMessage, $dir));
|
173 |
-
}
|
174 |
-
}
|
175 |
-
$this->dirCreated = true;
|
176 |
-
}
|
177 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php
DELETED
@@ -1,111 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\Formatter\FormatterInterface;
|
16 |
-
use Monolog\Formatter\LineFormatter;
|
17 |
-
use Swift;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* SwiftMailerHandler uses Swift_Mailer to send the emails
|
21 |
-
*
|
22 |
-
* @author Gyula Sallai
|
23 |
-
*/
|
24 |
-
class SwiftMailerHandler extends MailHandler
|
25 |
-
{
|
26 |
-
protected $mailer;
|
27 |
-
private $messageTemplate;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @param \Swift_Mailer $mailer The mailer to use
|
31 |
-
* @param callable|\Swift_Message $message An example message for real messages, only the body will be replaced
|
32 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
33 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
34 |
-
*/
|
35 |
-
public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, $bubble = true)
|
36 |
-
{
|
37 |
-
parent::__construct($level, $bubble);
|
38 |
-
|
39 |
-
$this->mailer = $mailer;
|
40 |
-
$this->messageTemplate = $message;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* {@inheritdoc}
|
45 |
-
*/
|
46 |
-
protected function send($content, array $records)
|
47 |
-
{
|
48 |
-
$this->mailer->send($this->buildMessage($content, $records));
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Gets the formatter for the Swift_Message subject.
|
53 |
-
*
|
54 |
-
* @param string $format The format of the subject
|
55 |
-
* @return FormatterInterface
|
56 |
-
*/
|
57 |
-
protected function getSubjectFormatter($format)
|
58 |
-
{
|
59 |
-
return new LineFormatter($format);
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Creates instance of Swift_Message to be sent
|
64 |
-
*
|
65 |
-
* @param string $content formatted email body to be sent
|
66 |
-
* @param array $records Log records that formed the content
|
67 |
-
* @return \Swift_Message
|
68 |
-
*/
|
69 |
-
protected function buildMessage($content, array $records)
|
70 |
-
{
|
71 |
-
$message = null;
|
72 |
-
if ($this->messageTemplate instanceof \Swift_Message) {
|
73 |
-
$message = clone $this->messageTemplate;
|
74 |
-
$message->generateId();
|
75 |
-
} elseif (is_callable($this->messageTemplate)) {
|
76 |
-
$message = call_user_func($this->messageTemplate, $content, $records);
|
77 |
-
}
|
78 |
-
|
79 |
-
if (!$message instanceof \Swift_Message) {
|
80 |
-
throw new \InvalidArgumentException('Could not resolve message as instance of Swift_Message or a callable returning it');
|
81 |
-
}
|
82 |
-
|
83 |
-
if ($records) {
|
84 |
-
$subjectFormatter = $this->getSubjectFormatter($message->getSubject());
|
85 |
-
$message->setSubject($subjectFormatter->format($this->getHighestRecord($records)));
|
86 |
-
}
|
87 |
-
|
88 |
-
$message->setBody($content);
|
89 |
-
if (version_compare(Swift::VERSION, '6.0.0', '>=')) {
|
90 |
-
$message->setDate(new \DateTimeImmutable());
|
91 |
-
} else {
|
92 |
-
$message->setDate(time());
|
93 |
-
}
|
94 |
-
|
95 |
-
return $message;
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* BC getter, to be removed in 2.0
|
100 |
-
*/
|
101 |
-
public function __get($name)
|
102 |
-
{
|
103 |
-
if ($name === 'message') {
|
104 |
-
trigger_error('SwiftMailerHandler->message is deprecated, use ->buildMessage() instead to retrieve the message', E_USER_DEPRECATED);
|
105 |
-
|
106 |
-
return $this->buildMessage(null, array());
|
107 |
-
}
|
108 |
-
|
109 |
-
throw new \InvalidArgumentException('Invalid property '.$name);
|
110 |
-
}
|
111 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Logs to syslog service.
|
18 |
-
*
|
19 |
-
* usage example:
|
20 |
-
*
|
21 |
-
* $log = new Logger('application');
|
22 |
-
* $syslog = new SyslogHandler('myfacility', 'local6');
|
23 |
-
* $formatter = new LineFormatter("%channel%.%level_name%: %message% %extra%");
|
24 |
-
* $syslog->setFormatter($formatter);
|
25 |
-
* $log->pushHandler($syslog);
|
26 |
-
*
|
27 |
-
* @author Sven Paulus <sven@karlsruhe.org>
|
28 |
-
*/
|
29 |
-
class SyslogHandler extends AbstractSyslogHandler
|
30 |
-
{
|
31 |
-
protected $ident;
|
32 |
-
protected $logopts;
|
33 |
-
|
34 |
-
/**
|
35 |
-
* @param string $ident
|
36 |
-
* @param mixed $facility
|
37 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
38 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
39 |
-
* @param int $logopts Option flags for the openlog() call, defaults to LOG_PID
|
40 |
-
*/
|
41 |
-
public function __construct($ident, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true, $logopts = LOG_PID)
|
42 |
-
{
|
43 |
-
parent::__construct($facility, $level, $bubble);
|
44 |
-
|
45 |
-
$this->ident = $ident;
|
46 |
-
$this->logopts = $logopts;
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* {@inheritdoc}
|
51 |
-
*/
|
52 |
-
public function close()
|
53 |
-
{
|
54 |
-
closelog();
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* {@inheritdoc}
|
59 |
-
*/
|
60 |
-
protected function write(array $record)
|
61 |
-
{
|
62 |
-
if (!openlog($this->ident, $this->logopts, $this->facility)) {
|
63 |
-
throw new \LogicException('Can\'t open syslog for ident "'.$this->ident.'" and facility "'.$this->facility.'"');
|
64 |
-
}
|
65 |
-
syslog($this->logLevels[$record['level']], (string) $record['formatted']);
|
66 |
-
}
|
67 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php
DELETED
@@ -1,56 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler\SyslogUdp;
|
13 |
-
|
14 |
-
class UdpSocket
|
15 |
-
{
|
16 |
-
const DATAGRAM_MAX_LENGTH = 65023;
|
17 |
-
|
18 |
-
protected $ip;
|
19 |
-
protected $port;
|
20 |
-
protected $socket;
|
21 |
-
|
22 |
-
public function __construct($ip, $port = 514)
|
23 |
-
{
|
24 |
-
$this->ip = $ip;
|
25 |
-
$this->port = $port;
|
26 |
-
$this->socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
|
27 |
-
}
|
28 |
-
|
29 |
-
public function write($line, $header = "")
|
30 |
-
{
|
31 |
-
$this->send($this->assembleMessage($line, $header));
|
32 |
-
}
|
33 |
-
|
34 |
-
public function close()
|
35 |
-
{
|
36 |
-
if (is_resource($this->socket)) {
|
37 |
-
socket_close($this->socket);
|
38 |
-
$this->socket = null;
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
protected function send($chunk)
|
43 |
-
{
|
44 |
-
if (!is_resource($this->socket)) {
|
45 |
-
throw new \LogicException('The UdpSocket to '.$this->ip.':'.$this->port.' has been closed and can not be written to anymore');
|
46 |
-
}
|
47 |
-
socket_sendto($this->socket, $chunk, strlen($chunk), $flags = 0, $this->ip, $this->port);
|
48 |
-
}
|
49 |
-
|
50 |
-
protected function assembleMessage($line, $header)
|
51 |
-
{
|
52 |
-
$chunkSize = self::DATAGRAM_MAX_LENGTH - strlen($header);
|
53 |
-
|
54 |
-
return $header . substr($line, 0, $chunkSize);
|
55 |
-
}
|
56 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php
DELETED
@@ -1,124 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
use Monolog\Handler\SyslogUdp\UdpSocket;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* A Handler for logging to a remote syslogd server.
|
19 |
-
*
|
20 |
-
* @author Jesper Skovgaard Nielsen <nulpunkt@gmail.com>
|
21 |
-
* @author Dominik Kukacka <dominik.kukacka@gmail.com>
|
22 |
-
*/
|
23 |
-
class SyslogUdpHandler extends AbstractSyslogHandler
|
24 |
-
{
|
25 |
-
const RFC3164 = 0;
|
26 |
-
const RFC5424 = 1;
|
27 |
-
|
28 |
-
private $dateFormats = array(
|
29 |
-
self::RFC3164 => 'M d H:i:s',
|
30 |
-
self::RFC5424 => \DateTime::RFC3339,
|
31 |
-
);
|
32 |
-
|
33 |
-
protected $socket;
|
34 |
-
protected $ident;
|
35 |
-
protected $rfc;
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @param string $host
|
39 |
-
* @param int $port
|
40 |
-
* @param mixed $facility
|
41 |
-
* @param int $level The minimum logging level at which this handler will be triggered
|
42 |
-
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
43 |
-
* @param string $ident Program name or tag for each log message.
|
44 |
-
* @param int $rfc RFC to format the message for.
|
45 |
-
*/
|
46 |
-
public function __construct($host, $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true, $ident = 'php', $rfc = self::RFC5424)
|
47 |
-
{
|
48 |
-
parent::__construct($facility, $level, $bubble);
|
49 |
-
|
50 |
-
$this->ident = $ident;
|
51 |
-
$this->rfc = $rfc;
|
52 |
-
|
53 |
-
$this->socket = new UdpSocket($host, $port ?: 514);
|
54 |
-
}
|
55 |
-
|
56 |
-
protected function write(array $record)
|
57 |
-
{
|
58 |
-
$lines = $this->splitMessageIntoLines($record['formatted']);
|
59 |
-
|
60 |
-
$header = $this->makeCommonSyslogHeader($this->logLevels[$record['level']]);
|
61 |
-
|
62 |
-
foreach ($lines as $line) {
|
63 |
-
$this->socket->write($line, $header);
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
public function close()
|
68 |
-
{
|
69 |
-
$this->socket->close();
|
70 |
-
}
|
71 |
-
|
72 |
-
private function splitMessageIntoLines($message)
|
73 |
-
{
|
74 |
-
if (is_array($message)) {
|
75 |
-
$message = implode("\n", $message);
|
76 |
-
}
|
77 |
-
|
78 |
-
return preg_split('/$\R?^/m', $message, -1, PREG_SPLIT_NO_EMPTY);
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Make common syslog header (see rfc5424 or rfc3164)
|
83 |
-
*/
|
84 |
-
protected function makeCommonSyslogHeader($severity)
|
85 |
-
{
|
86 |
-
$priority = $severity + $this->facility;
|
87 |
-
|
88 |
-
if (!$pid = getmypid()) {
|
89 |
-
$pid = '-';
|
90 |
-
}
|
91 |
-
|
92 |
-
if (!$hostname = gethostname()) {
|
93 |
-
$hostname = '-';
|
94 |
-
}
|
95 |
-
|
96 |
-
$date = $this->getDateTime();
|
97 |
-
|
98 |
-
if ($this->rfc === self::RFC3164) {
|
99 |
-
return "<$priority>" .
|
100 |
-
$date . " " .
|
101 |
-
$hostname . " " .
|
102 |
-
$this->ident . "[" . $pid . "]: ";
|
103 |
-
} else {
|
104 |
-
return "<$priority>1 " .
|
105 |
-
$date . " " .
|
106 |
-
$hostname . " " .
|
107 |
-
$this->ident . " " .
|
108 |
-
$pid . " - - ";
|
109 |
-
}
|
110 |
-
}
|
111 |
-
|
112 |
-
protected function getDateTime()
|
113 |
-
{
|
114 |
-
return date($this->dateFormats[$this->rfc]);
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Inject your own socket, mainly used for testing
|
119 |
-
*/
|
120 |
-
public function setSocket($socket)
|
121 |
-
{
|
122 |
-
$this->socket = $socket;
|
123 |
-
}
|
124 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php
DELETED
@@ -1,177 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Used for testing purposes.
|
16 |
-
*
|
17 |
-
* It records all records and gives you access to them for verification.
|
18 |
-
*
|
19 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
20 |
-
*
|
21 |
-
* @method bool hasEmergency($record)
|
22 |
-
* @method bool hasAlert($record)
|
23 |
-
* @method bool hasCritical($record)
|
24 |
-
* @method bool hasError($record)
|
25 |
-
* @method bool hasWarning($record)
|
26 |
-
* @method bool hasNotice($record)
|
27 |
-
* @method bool hasInfo($record)
|
28 |
-
* @method bool hasDebug($record)
|
29 |
-
*
|
30 |
-
* @method bool hasEmergencyRecords()
|
31 |
-
* @method bool hasAlertRecords()
|
32 |
-
* @method bool hasCriticalRecords()
|
33 |
-
* @method bool hasErrorRecords()
|
34 |
-
* @method bool hasWarningRecords()
|
35 |
-
* @method bool hasNoticeRecords()
|
36 |
-
* @method bool hasInfoRecords()
|
37 |
-
* @method bool hasDebugRecords()
|
38 |
-
*
|
39 |
-
* @method bool hasEmergencyThatContains($message)
|
40 |
-
* @method bool hasAlertThatContains($message)
|
41 |
-
* @method bool hasCriticalThatContains($message)
|
42 |
-
* @method bool hasErrorThatContains($message)
|
43 |
-
* @method bool hasWarningThatContains($message)
|
44 |
-
* @method bool hasNoticeThatContains($message)
|
45 |
-
* @method bool hasInfoThatContains($message)
|
46 |
-
* @method bool hasDebugThatContains($message)
|
47 |
-
*
|
48 |
-
* @method bool hasEmergencyThatMatches($message)
|
49 |
-
* @method bool hasAlertThatMatches($message)
|
50 |
-
* @method bool hasCriticalThatMatches($message)
|
51 |
-
* @method bool hasErrorThatMatches($message)
|
52 |
-
* @method bool hasWarningThatMatches($message)
|
53 |
-
* @method bool hasNoticeThatMatches($message)
|
54 |
-
* @method bool hasInfoThatMatches($message)
|
55 |
-
* @method bool hasDebugThatMatches($message)
|
56 |
-
*
|
57 |
-
* @method bool hasEmergencyThatPasses($message)
|
58 |
-
* @method bool hasAlertThatPasses($message)
|
59 |
-
* @method bool hasCriticalThatPasses($message)
|
60 |
-
* @method bool hasErrorThatPasses($message)
|
61 |
-
* @method bool hasWarningThatPasses($message)
|
62 |
-
* @method bool hasNoticeThatPasses($message)
|
63 |
-
* @method bool hasInfoThatPasses($message)
|
64 |
-
* @method bool hasDebugThatPasses($message)
|
65 |
-
*/
|
66 |
-
class TestHandler extends AbstractProcessingHandler
|
67 |
-
{
|
68 |
-
protected $records = array();
|
69 |
-
protected $recordsByLevel = array();
|
70 |
-
private $skipReset = false;
|
71 |
-
|
72 |
-
public function getRecords()
|
73 |
-
{
|
74 |
-
return $this->records;
|
75 |
-
}
|
76 |
-
|
77 |
-
public function clear()
|
78 |
-
{
|
79 |
-
$this->records = array();
|
80 |
-
$this->recordsByLevel = array();
|
81 |
-
}
|
82 |
-
|
83 |
-
public function reset()
|
84 |
-
{
|
85 |
-
if (!$this->skipReset) {
|
86 |
-
$this->clear();
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
public function setSkipReset($skipReset)
|
91 |
-
{
|
92 |
-
$this->skipReset = $skipReset;
|
93 |
-
}
|
94 |
-
|
95 |
-
public function hasRecords($level)
|
96 |
-
{
|
97 |
-
return isset($this->recordsByLevel[$level]);
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* @param string|array $record Either a message string or an array containing message and optionally context keys that will be checked against all records
|
102 |
-
* @param int $level Logger::LEVEL constant value
|
103 |
-
*/
|
104 |
-
public function hasRecord($record, $level)
|
105 |
-
{
|
106 |
-
if (is_string($record)) {
|
107 |
-
$record = array('message' => $record);
|
108 |
-
}
|
109 |
-
|
110 |
-
return $this->hasRecordThatPasses(function ($rec) use ($record) {
|
111 |
-
if ($rec['message'] !== $record['message']) {
|
112 |
-
return false;
|
113 |
-
}
|
114 |
-
if (isset($record['context']) && $rec['context'] !== $record['context']) {
|
115 |
-
return false;
|
116 |
-
}
|
117 |
-
return true;
|
118 |
-
}, $level);
|
119 |
-
}
|
120 |
-
|
121 |
-
public function hasRecordThatContains($message, $level)
|
122 |
-
{
|
123 |
-
return $this->hasRecordThatPasses(function ($rec) use ($message) {
|
124 |
-
return strpos($rec['message'], $message) !== false;
|
125 |
-
}, $level);
|
126 |
-
}
|
127 |
-
|
128 |
-
public function hasRecordThatMatches($regex, $level)
|
129 |
-
{
|
130 |
-
return $this->hasRecordThatPasses(function ($rec) use ($regex) {
|
131 |
-
return preg_match($regex, $rec['message']) > 0;
|
132 |
-
}, $level);
|
133 |
-
}
|
134 |
-
|
135 |
-
public function hasRecordThatPasses($predicate, $level)
|
136 |
-
{
|
137 |
-
if (!is_callable($predicate)) {
|
138 |
-
throw new \InvalidArgumentException("Expected a callable for hasRecordThatSucceeds");
|
139 |
-
}
|
140 |
-
|
141 |
-
if (!isset($this->recordsByLevel[$level])) {
|
142 |
-
return false;
|
143 |
-
}
|
144 |
-
|
145 |
-
foreach ($this->recordsByLevel[$level] as $i => $rec) {
|
146 |
-
if (call_user_func($predicate, $rec, $i)) {
|
147 |
-
return true;
|
148 |
-
}
|
149 |
-
}
|
150 |
-
|
151 |
-
return false;
|
152 |
-
}
|
153 |
-
|
154 |
-
/**
|
155 |
-
* {@inheritdoc}
|
156 |
-
*/
|
157 |
-
protected function write(array $record)
|
158 |
-
{
|
159 |
-
$this->recordsByLevel[$record['level']][] = $record;
|
160 |
-
$this->records[] = $record;
|
161 |
-
}
|
162 |
-
|
163 |
-
public function __call($method, $args)
|
164 |
-
{
|
165 |
-
if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
|
166 |
-
$genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3];
|
167 |
-
$level = constant('Monolog\Logger::' . strtoupper($matches[2]));
|
168 |
-
if (method_exists($this, $genericMethod)) {
|
169 |
-
$args[] = $level;
|
170 |
-
|
171 |
-
return call_user_func_array(array($this, $genericMethod), $args);
|
172 |
-
}
|
173 |
-
}
|
174 |
-
|
175 |
-
throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()');
|
176 |
-
}
|
177 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Handler;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Forwards records to multiple handlers suppressing failures of each handler
|
16 |
-
* and continuing through to give every handler a chance to succeed.
|
17 |
-
*
|
18 |
-
* @author Craig D'Amelio <craig@damelio.ca>
|
19 |
-
*/
|
20 |
-
class WhatFailureGroupHandler extends GroupHandler
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* {@inheritdoc}
|
24 |
-
*/
|
25 |
-
public function handle(array $record)
|
26 |
-
{
|
27 |
-
if ($this->processors) {
|
28 |
-
foreach ($this->processors as $processor) {
|
29 |
-
$record = call_user_func($processor, $record);
|
30 |
-
}
|
31 |
-
}
|
32 |
-
|
33 |
-
foreach ($this->handlers as $handler) {
|
34 |
-
try {
|
35 |
-
$handler->handle($record);
|
36 |
-
} catch (\Exception $e) {
|
37 |
-
// What failure?
|
38 |
-
} catch (\Throwable $e) {
|
39 |
-
// What failure?
|
40 |
-
}
|
41 |
-
}
|
42 |
-
|
43 |
-
return false === $this->bubble;
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* {@inheritdoc}
|
48 |
-
*/
|
49 |
-
public function handleBatch(array $records)
|
50 |
-
{
|
51 |
-
if ($this->processors) {
|
52 |
-
$processed = array();
|
53 |
-
foreach ($records as $record) {
|
54 |
-
foreach ($this->processors as $processor) {
|
55 |
-
$record = call_user_func($processor, $record);
|
56 |
-
}
|
57 |
-
$processed[] = $record;
|
58 |
-
}
|
59 |
-
$records = $processed;
|
60 |
-
}
|
61 |
-
|
62 |
-
foreach ($this->handlers as $handler) {
|
63 |
-
try {
|
64 |
-
$handler->handleBatch($records);
|
65 |
-
} catch (\Exception $e) {
|
66 |
-
// What failure?
|
67 |
-
} catch (\Throwable $e) {
|
68 |
-
// What failure?
|
69 |
-
}
|
70 |
-
}
|
71 |
-
}
|
72 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php
DELETED
@@ -1,101 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* This file is part of the Monolog package.
|
4 |
-
*
|
5 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
6 |
-
*
|
7 |
-
* For the full copyright and license information, please view the LICENSE
|
8 |
-
* file that was distributed with this source code.
|
9 |
-
*/
|
10 |
-
|
11 |
-
namespace Monolog\Handler;
|
12 |
-
|
13 |
-
use Monolog\Formatter\NormalizerFormatter;
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Handler sending logs to Zend Monitor
|
18 |
-
*
|
19 |
-
* @author Christian Bergau <cbergau86@gmail.com>
|
20 |
-
* @author Jason Davis <happydude@jasondavis.net>
|
21 |
-
*/
|
22 |
-
class ZendMonitorHandler extends AbstractProcessingHandler
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* Monolog level / ZendMonitor Custom Event priority map
|
26 |
-
*
|
27 |
-
* @var array
|
28 |
-
*/
|
29 |
-
protected $levelMap = array();
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Construct
|
33 |
-
*
|
34 |
-
* @param int $level
|
35 |
-
* @param bool $bubble
|
36 |
-
* @throws MissingExtensionException
|
37 |
-
*/
|
38 |
-
public function __construct($level = Logger::DEBUG, $bubble = true)
|
39 |
-
{
|
40 |
-
if (!function_exists('zend_monitor_custom_event')) {
|
41 |
-
throw new MissingExtensionException(
|
42 |
-
'You must have Zend Server installed with Zend Monitor enabled in order to use this handler'
|
43 |
-
);
|
44 |
-
}
|
45 |
-
//zend monitor constants are not defined if zend monitor is not enabled.
|
46 |
-
$this->levelMap = array(
|
47 |
-
Logger::DEBUG => \ZEND_MONITOR_EVENT_SEVERITY_INFO,
|
48 |
-
Logger::INFO => \ZEND_MONITOR_EVENT_SEVERITY_INFO,
|
49 |
-
Logger::NOTICE => \ZEND_MONITOR_EVENT_SEVERITY_INFO,
|
50 |
-
Logger::WARNING => \ZEND_MONITOR_EVENT_SEVERITY_WARNING,
|
51 |
-
Logger::ERROR => \ZEND_MONITOR_EVENT_SEVERITY_ERROR,
|
52 |
-
Logger::CRITICAL => \ZEND_MONITOR_EVENT_SEVERITY_ERROR,
|
53 |
-
Logger::ALERT => \ZEND_MONITOR_EVENT_SEVERITY_ERROR,
|
54 |
-
Logger::EMERGENCY => \ZEND_MONITOR_EVENT_SEVERITY_ERROR,
|
55 |
-
);
|
56 |
-
parent::__construct($level, $bubble);
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* {@inheritdoc}
|
61 |
-
*/
|
62 |
-
protected function write(array $record)
|
63 |
-
{
|
64 |
-
$this->writeZendMonitorCustomEvent(
|
65 |
-
Logger::getLevelName($record['level']),
|
66 |
-
$record['message'],
|
67 |
-
$record['formatted'],
|
68 |
-
$this->levelMap[$record['level']]
|
69 |
-
);
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Write to Zend Monitor Events
|
74 |
-
* @param string $type Text displayed in "Class Name (custom)" field
|
75 |
-
* @param string $message Text displayed in "Error String"
|
76 |
-
* @param mixed $formatted Displayed in Custom Variables tab
|
77 |
-
* @param int $severity Set the event severity level (-1,0,1)
|
78 |
-
*/
|
79 |
-
protected function writeZendMonitorCustomEvent($type, $message, $formatted, $severity)
|
80 |
-
{
|
81 |
-
zend_monitor_custom_event($type, $message, $formatted, $severity);
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* {@inheritdoc}
|
86 |
-
*/
|
87 |
-
public function getDefaultFormatter()
|
88 |
-
{
|
89 |
-
return new NormalizerFormatter();
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Get the level map
|
94 |
-
*
|
95 |
-
* @return array
|
96 |
-
*/
|
97 |
-
public function getLevelMap()
|
98 |
-
{
|
99 |
-
return $this->levelMap;
|
100 |
-
}
|
101 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Logger.php
DELETED
@@ -1,791 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog;
|
13 |
-
|
14 |
-
use Monolog\Handler\HandlerInterface;
|
15 |
-
use Monolog\Handler\StreamHandler;
|
16 |
-
use Psr\Log\LoggerInterface;
|
17 |
-
use Psr\Log\InvalidArgumentException;
|
18 |
-
use Exception;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Monolog log channel
|
22 |
-
*
|
23 |
-
* It contains a stack of Handlers and a stack of Processors,
|
24 |
-
* and uses them to store records that are added to it.
|
25 |
-
*
|
26 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
27 |
-
*/
|
28 |
-
class Logger implements LoggerInterface, ResettableInterface
|
29 |
-
{
|
30 |
-
/**
|
31 |
-
* Detailed debug information
|
32 |
-
*/
|
33 |
-
const DEBUG = 100;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Interesting events
|
37 |
-
*
|
38 |
-
* Examples: User logs in, SQL logs.
|
39 |
-
*/
|
40 |
-
const INFO = 200;
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Uncommon events
|
44 |
-
*/
|
45 |
-
const NOTICE = 250;
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Exceptional occurrences that are not errors
|
49 |
-
*
|
50 |
-
* Examples: Use of deprecated APIs, poor use of an API,
|
51 |
-
* undesirable things that are not necessarily wrong.
|
52 |
-
*/
|
53 |
-
const WARNING = 300;
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Runtime errors
|
57 |
-
*/
|
58 |
-
const ERROR = 400;
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Critical conditions
|
62 |
-
*
|
63 |
-
* Example: Application component unavailable, unexpected exception.
|
64 |
-
*/
|
65 |
-
const CRITICAL = 500;
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Action must be taken immediately
|
69 |
-
*
|
70 |
-
* Example: Entire website down, database unavailable, etc.
|
71 |
-
* This should trigger the SMS alerts and wake you up.
|
72 |
-
*/
|
73 |
-
const ALERT = 550;
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Urgent alert.
|
77 |
-
*/
|
78 |
-
const EMERGENCY = 600;
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Monolog API version
|
82 |
-
*
|
83 |
-
* This is only bumped when API breaks are done and should
|
84 |
-
* follow the major version of the library
|
85 |
-
*
|
86 |
-
* @var int
|
87 |
-
*/
|
88 |
-
const API = 1;
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Logging levels from syslog protocol defined in RFC 5424
|
92 |
-
*
|
93 |
-
* @var array $levels Logging levels
|
94 |
-
*/
|
95 |
-
protected static $levels = array(
|
96 |
-
self::DEBUG => 'DEBUG',
|
97 |
-
self::INFO => 'INFO',
|
98 |
-
self::NOTICE => 'NOTICE',
|
99 |
-
self::WARNING => 'WARNING',
|
100 |
-
self::ERROR => 'ERROR',
|
101 |
-
self::CRITICAL => 'CRITICAL',
|
102 |
-
self::ALERT => 'ALERT',
|
103 |
-
self::EMERGENCY => 'EMERGENCY',
|
104 |
-
);
|
105 |
-
|
106 |
-
/**
|
107 |
-
* @var \DateTimeZone
|
108 |
-
*/
|
109 |
-
protected static $timezone;
|
110 |
-
|
111 |
-
/**
|
112 |
-
* @var string
|
113 |
-
*/
|
114 |
-
protected $name;
|
115 |
-
|
116 |
-
/**
|
117 |
-
* The handler stack
|
118 |
-
*
|
119 |
-
* @var HandlerInterface[]
|
120 |
-
*/
|
121 |
-
protected $handlers;
|
122 |
-
|
123 |
-
/**
|
124 |
-
* Processors that will process all log records
|
125 |
-
*
|
126 |
-
* To process records of a single handler instead, add the processor on that specific handler
|
127 |
-
*
|
128 |
-
* @var callable[]
|
129 |
-
*/
|
130 |
-
protected $processors;
|
131 |
-
|
132 |
-
/**
|
133 |
-
* @var bool
|
134 |
-
*/
|
135 |
-
protected $microsecondTimestamps = true;
|
136 |
-
|
137 |
-
/**
|
138 |
-
* @var callable
|
139 |
-
*/
|
140 |
-
protected $exceptionHandler;
|
141 |
-
|
142 |
-
/**
|
143 |
-
* @param string $name The logging channel
|
144 |
-
* @param HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc.
|
145 |
-
* @param callable[] $processors Optional array of processors
|
146 |
-
*/
|
147 |
-
public function __construct($name, array $handlers = array(), array $processors = array())
|
148 |
-
{
|
149 |
-
$this->name = $name;
|
150 |
-
$this->setHandlers($handlers);
|
151 |
-
$this->processors = $processors;
|
152 |
-
}
|
153 |
-
|
154 |
-
/**
|
155 |
-
* @return string
|
156 |
-
*/
|
157 |
-
public function getName()
|
158 |
-
{
|
159 |
-
return $this->name;
|
160 |
-
}
|
161 |
-
|
162 |
-
/**
|
163 |
-
* Return a new cloned instance with the name changed
|
164 |
-
*
|
165 |
-
* @return static
|
166 |
-
*/
|
167 |
-
public function withName($name)
|
168 |
-
{
|
169 |
-
$new = clone $this;
|
170 |
-
$new->name = $name;
|
171 |
-
|
172 |
-
return $new;
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Pushes a handler on to the stack.
|
177 |
-
*
|
178 |
-
* @param HandlerInterface $handler
|
179 |
-
* @return $this
|
180 |
-
*/
|
181 |
-
public function pushHandler(HandlerInterface $handler)
|
182 |
-
{
|
183 |
-
array_unshift($this->handlers, $handler);
|
184 |
-
|
185 |
-
return $this;
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* Pops a handler from the stack
|
190 |
-
*
|
191 |
-
* @return HandlerInterface
|
192 |
-
*/
|
193 |
-
public function popHandler()
|
194 |
-
{
|
195 |
-
if (!$this->handlers) {
|
196 |
-
throw new \LogicException('You tried to pop from an empty handler stack.');
|
197 |
-
}
|
198 |
-
|
199 |
-
return array_shift($this->handlers);
|
200 |
-
}
|
201 |
-
|
202 |
-
/**
|
203 |
-
* Set handlers, replacing all existing ones.
|
204 |
-
*
|
205 |
-
* If a map is passed, keys will be ignored.
|
206 |
-
*
|
207 |
-
* @param HandlerInterface[] $handlers
|
208 |
-
* @return $this
|
209 |
-
*/
|
210 |
-
public function setHandlers(array $handlers)
|
211 |
-
{
|
212 |
-
$this->handlers = array();
|
213 |
-
foreach (array_reverse($handlers) as $handler) {
|
214 |
-
$this->pushHandler($handler);
|
215 |
-
}
|
216 |
-
|
217 |
-
return $this;
|
218 |
-
}
|
219 |
-
|
220 |
-
/**
|
221 |
-
* @return HandlerInterface[]
|
222 |
-
*/
|
223 |
-
public function getHandlers()
|
224 |
-
{
|
225 |
-
return $this->handlers;
|
226 |
-
}
|
227 |
-
|
228 |
-
/**
|
229 |
-
* Adds a processor on to the stack.
|
230 |
-
*
|
231 |
-
* @param callable $callback
|
232 |
-
* @return $this
|
233 |
-
*/
|
234 |
-
public function pushProcessor($callback)
|
235 |
-
{
|
236 |
-
if (!is_callable($callback)) {
|
237 |
-
throw new \InvalidArgumentException('Processors must be valid callables (callback or object with an __invoke method), '.var_export($callback, true).' given');
|
238 |
-
}
|
239 |
-
array_unshift($this->processors, $callback);
|
240 |
-
|
241 |
-
return $this;
|
242 |
-
}
|
243 |
-
|
244 |
-
/**
|
245 |
-
* Removes the processor on top of the stack and returns it.
|
246 |
-
*
|
247 |
-
* @return callable
|
248 |
-
*/
|
249 |
-
public function popProcessor()
|
250 |
-
{
|
251 |
-
if (!$this->processors) {
|
252 |
-
throw new \LogicException('You tried to pop from an empty processor stack.');
|
253 |
-
}
|
254 |
-
|
255 |
-
return array_shift($this->processors);
|
256 |
-
}
|
257 |
-
|
258 |
-
/**
|
259 |
-
* @return callable[]
|
260 |
-
*/
|
261 |
-
public function getProcessors()
|
262 |
-
{
|
263 |
-
return $this->processors;
|
264 |
-
}
|
265 |
-
|
266 |
-
/**
|
267 |
-
* Control the use of microsecond resolution timestamps in the 'datetime'
|
268 |
-
* member of new records.
|
269 |
-
*
|
270 |
-
* Generating microsecond resolution timestamps by calling
|
271 |
-
* microtime(true), formatting the result via sprintf() and then parsing
|
272 |
-
* the resulting string via \DateTime::createFromFormat() can incur
|
273 |
-
* a measurable runtime overhead vs simple usage of DateTime to capture
|
274 |
-
* a second resolution timestamp in systems which generate a large number
|
275 |
-
* of log events.
|
276 |
-
*
|
277 |
-
* @param bool $micro True to use microtime() to create timestamps
|
278 |
-
*/
|
279 |
-
public function useMicrosecondTimestamps($micro)
|
280 |
-
{
|
281 |
-
$this->microsecondTimestamps = (bool) $micro;
|
282 |
-
}
|
283 |
-
|
284 |
-
/**
|
285 |
-
* Adds a log record.
|
286 |
-
*
|
287 |
-
* @param int $level The logging level
|
288 |
-
* @param string $message The log message
|
289 |
-
* @param array $context The log context
|
290 |
-
* @return bool Whether the record has been processed
|
291 |
-
*/
|
292 |
-
public function addRecord($level, $message, array $context = array())
|
293 |
-
{
|
294 |
-
if (!$this->handlers) {
|
295 |
-
$this->pushHandler(new StreamHandler('php://stderr', static::DEBUG));
|
296 |
-
}
|
297 |
-
|
298 |
-
$levelName = static::getLevelName($level);
|
299 |
-
|
300 |
-
// check if any handler will handle this message so we can return early and save cycles
|
301 |
-
$handlerKey = null;
|
302 |
-
reset($this->handlers);
|
303 |
-
while ($handler = current($this->handlers)) {
|
304 |
-
if ($handler->isHandling(array('level' => $level))) {
|
305 |
-
$handlerKey = key($this->handlers);
|
306 |
-
break;
|
307 |
-
}
|
308 |
-
|
309 |
-
next($this->handlers);
|
310 |
-
}
|
311 |
-
|
312 |
-
if (null === $handlerKey) {
|
313 |
-
return false;
|
314 |
-
}
|
315 |
-
|
316 |
-
if (!static::$timezone) {
|
317 |
-
static::$timezone = new \DateTimeZone(date_default_timezone_get() ?: 'UTC');
|
318 |
-
}
|
319 |
-
|
320 |
-
// php7.1+ always has microseconds enabled, so we do not need this hack
|
321 |
-
if ($this->microsecondTimestamps && PHP_VERSION_ID < 70100) {
|
322 |
-
$ts = \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), static::$timezone);
|
323 |
-
} else {
|
324 |
-
$ts = new \DateTime(null, static::$timezone);
|
325 |
-
}
|
326 |
-
$ts->setTimezone(static::$timezone);
|
327 |
-
|
328 |
-
$record = array(
|
329 |
-
'message' => (string) $message,
|
330 |
-
'context' => $context,
|
331 |
-
'level' => $level,
|
332 |
-
'level_name' => $levelName,
|
333 |
-
'channel' => $this->name,
|
334 |
-
'datetime' => $ts,
|
335 |
-
'extra' => array(),
|
336 |
-
);
|
337 |
-
|
338 |
-
try {
|
339 |
-
foreach ($this->processors as $processor) {
|
340 |
-
$record = call_user_func($processor, $record);
|
341 |
-
}
|
342 |
-
|
343 |
-
while ($handler = current($this->handlers)) {
|
344 |
-
if (true === $handler->handle($record)) {
|
345 |
-
break;
|
346 |
-
}
|
347 |
-
|
348 |
-
next($this->handlers);
|
349 |
-
}
|
350 |
-
} catch (Exception $e) {
|
351 |
-
$this->handleException($e, $record);
|
352 |
-
}
|
353 |
-
|
354 |
-
return true;
|
355 |
-
}
|
356 |
-
|
357 |
-
/**
|
358 |
-
* Ends a log cycle and frees all resources used by handlers.
|
359 |
-
*
|
360 |
-
* Closing a Handler means flushing all buffers and freeing any open resources/handles.
|
361 |
-
* Handlers that have been closed should be able to accept log records again and re-open
|
362 |
-
* themselves on demand, but this may not always be possible depending on implementation.
|
363 |
-
*
|
364 |
-
* This is useful at the end of a request and will be called automatically on every handler
|
365 |
-
* when they get destructed.
|
366 |
-
*/
|
367 |
-
public function close()
|
368 |
-
{
|
369 |
-
foreach ($this->handlers as $handler) {
|
370 |
-
if (method_exists($handler, 'close')) {
|
371 |
-
$handler->close();
|
372 |
-
}
|
373 |
-
}
|
374 |
-
}
|
375 |
-
|
376 |
-
/**
|
377 |
-
* Ends a log cycle and resets all handlers and processors to their initial state.
|
378 |
-
*
|
379 |
-
* Resetting a Handler or a Processor means flushing/cleaning all buffers, resetting internal
|
380 |
-
* state, and getting it back to a state in which it can receive log records again.
|
381 |
-
*
|
382 |
-
* This is useful in case you want to avoid logs leaking between two requests or jobs when you
|
383 |
-
* have a long running process like a worker or an application server serving multiple requests
|
384 |
-
* in one process.
|
385 |
-
*/
|
386 |
-
public function reset()
|
387 |
-
{
|
388 |
-
foreach ($this->handlers as $handler) {
|
389 |
-
if ($handler instanceof ResettableInterface) {
|
390 |
-
$handler->reset();
|
391 |
-
}
|
392 |
-
}
|
393 |
-
|
394 |
-
foreach ($this->processors as $processor) {
|
395 |
-
if ($processor instanceof ResettableInterface) {
|
396 |
-
$processor->reset();
|
397 |
-
}
|
398 |
-
}
|
399 |
-
}
|
400 |
-
|
401 |
-
/**
|
402 |
-
* Adds a log record at the DEBUG level.
|
403 |
-
*
|
404 |
-
* @param string $message The log message
|
405 |
-
* @param array $context The log context
|
406 |
-
* @return bool Whether the record has been processed
|
407 |
-
*/
|
408 |
-
public function addDebug($message, array $context = array())
|
409 |
-
{
|
410 |
-
return $this->addRecord(static::DEBUG, $message, $context);
|
411 |
-
}
|
412 |
-
|
413 |
-
/**
|
414 |
-
* Adds a log record at the INFO level.
|
415 |
-
*
|
416 |
-
* @param string $message The log message
|
417 |
-
* @param array $context The log context
|
418 |
-
* @return bool Whether the record has been processed
|
419 |
-
*/
|
420 |
-
public function addInfo($message, array $context = array())
|
421 |
-
{
|
422 |
-
return $this->addRecord(static::INFO, $message, $context);
|
423 |
-
}
|
424 |
-
|
425 |
-
/**
|
426 |
-
* Adds a log record at the NOTICE level.
|
427 |
-
*
|
428 |
-
* @param string $message The log message
|
429 |
-
* @param array $context The log context
|
430 |
-
* @return bool Whether the record has been processed
|
431 |
-
*/
|
432 |
-
public function addNotice($message, array $context = array())
|
433 |
-
{
|
434 |
-
return $this->addRecord(static::NOTICE, $message, $context);
|
435 |
-
}
|
436 |
-
|
437 |
-
/**
|
438 |
-
* Adds a log record at the WARNING level.
|
439 |
-
*
|
440 |
-
* @param string $message The log message
|
441 |
-
* @param array $context The log context
|
442 |
-
* @return bool Whether the record has been processed
|
443 |
-
*/
|
444 |
-
public function addWarning($message, array $context = array())
|
445 |
-
{
|
446 |
-
return $this->addRecord(static::WARNING, $message, $context);
|
447 |
-
}
|
448 |
-
|
449 |
-
/**
|
450 |
-
* Adds a log record at the ERROR level.
|
451 |
-
*
|
452 |
-
* @param string $message The log message
|
453 |
-
* @param array $context The log context
|
454 |
-
* @return bool Whether the record has been processed
|
455 |
-
*/
|
456 |
-
public function addError($message, array $context = array())
|
457 |
-
{
|
458 |
-
return $this->addRecord(static::ERROR, $message, $context);
|
459 |
-
}
|
460 |
-
|
461 |
-
/**
|
462 |
-
* Adds a log record at the CRITICAL level.
|
463 |
-
*
|
464 |
-
* @param string $message The log message
|
465 |
-
* @param array $context The log context
|
466 |
-
* @return bool Whether the record has been processed
|
467 |
-
*/
|
468 |
-
public function addCritical($message, array $context = array())
|
469 |
-
{
|
470 |
-
return $this->addRecord(static::CRITICAL, $message, $context);
|
471 |
-
}
|
472 |
-
|
473 |
-
/**
|
474 |
-
* Adds a log record at the ALERT level.
|
475 |
-
*
|
476 |
-
* @param string $message The log message
|
477 |
-
* @param array $context The log context
|
478 |
-
* @return bool Whether the record has been processed
|
479 |
-
*/
|
480 |
-
public function addAlert($message, array $context = array())
|
481 |
-
{
|
482 |
-
return $this->addRecord(static::ALERT, $message, $context);
|
483 |
-
}
|
484 |
-
|
485 |
-
/**
|
486 |
-
* Adds a log record at the EMERGENCY level.
|
487 |
-
*
|
488 |
-
* @param string $message The log message
|
489 |
-
* @param array $context The log context
|
490 |
-
* @return bool Whether the record has been processed
|
491 |
-
*/
|
492 |
-
public function addEmergency($message, array $context = array())
|
493 |
-
{
|
494 |
-
return $this->addRecord(static::EMERGENCY, $message, $context);
|
495 |
-
}
|
496 |
-
|
497 |
-
/**
|
498 |
-
* Gets all supported logging levels.
|
499 |
-
*
|
500 |
-
* @return array Assoc array with human-readable level names => level codes.
|
501 |
-
*/
|
502 |
-
public static function getLevels()
|
503 |
-
{
|
504 |
-
return array_flip(static::$levels);
|
505 |
-
}
|
506 |
-
|
507 |
-
/**
|
508 |
-
* Gets the name of the logging level.
|
509 |
-
*
|
510 |
-
* @param int $level
|
511 |
-
* @return string
|
512 |
-
*/
|
513 |
-
public static function getLevelName($level)
|
514 |
-
{
|
515 |
-
if (!isset(static::$levels[$level])) {
|
516 |
-
throw new InvalidArgumentException('Level "'.$level.'" is not defined, use one of: '.implode(', ', array_keys(static::$levels)));
|
517 |
-
}
|
518 |
-
|
519 |
-
return static::$levels[$level];
|
520 |
-
}
|
521 |
-
|
522 |
-
/**
|
523 |
-
* Converts PSR-3 levels to Monolog ones if necessary
|
524 |
-
*
|
525 |
-
* @param string|int Level number (monolog) or name (PSR-3)
|
526 |
-
* @return int
|
527 |
-
*/
|
528 |
-
public static function toMonologLevel($level)
|
529 |
-
{
|
530 |
-
if (is_string($level) && defined(__CLASS__.'::'.strtoupper($level))) {
|
531 |
-
return constant(__CLASS__.'::'.strtoupper($level));
|
532 |
-
}
|
533 |
-
|
534 |
-
return $level;
|
535 |
-
}
|
536 |
-
|
537 |
-
/**
|
538 |
-
* Checks whether the Logger has a handler that listens on the given level
|
539 |
-
*
|
540 |
-
* @param int $level
|
541 |
-
* @return bool
|
542 |
-
*/
|
543 |
-
public function isHandling($level)
|
544 |
-
{
|
545 |
-
$record = array(
|
546 |
-
'level' => $level,
|
547 |
-
);
|
548 |
-
|
549 |
-
foreach ($this->handlers as $handler) {
|
550 |
-
if ($handler->isHandling($record)) {
|
551 |
-
return true;
|
552 |
-
}
|
553 |
-
}
|
554 |
-
|
555 |
-
return false;
|
556 |
-
}
|
557 |
-
|
558 |
-
/**
|
559 |
-
* Set a custom exception handler
|
560 |
-
*
|
561 |
-
* @param callable $callback
|
562 |
-
* @return $this
|
563 |
-
*/
|
564 |
-
public function setExceptionHandler($callback)
|
565 |
-
{
|
566 |
-
if (!is_callable($callback)) {
|
567 |
-
throw new \InvalidArgumentException('Exception handler must be valid callable (callback or object with an __invoke method), '.var_export($callback, true).' given');
|
568 |
-
}
|
569 |
-
$this->exceptionHandler = $callback;
|
570 |
-
|
571 |
-
return $this;
|
572 |
-
}
|
573 |
-
|
574 |
-
/**
|
575 |
-
* @return callable
|
576 |
-
*/
|
577 |
-
public function getExceptionHandler()
|
578 |
-
{
|
579 |
-
return $this->exceptionHandler;
|
580 |
-
}
|
581 |
-
|
582 |
-
/**
|
583 |
-
* Delegates exception management to the custom exception handler,
|
584 |
-
* or throws the exception if no custom handler is set.
|
585 |
-
*/
|
586 |
-
protected function handleException(Exception $e, array $record)
|
587 |
-
{
|
588 |
-
if (!$this->exceptionHandler) {
|
589 |
-
throw $e;
|
590 |
-
}
|
591 |
-
|
592 |
-
call_user_func($this->exceptionHandler, $e, $record);
|
593 |
-
}
|
594 |
-
|
595 |
-
/**
|
596 |
-
* Adds a log record at an arbitrary level.
|
597 |
-
*
|
598 |
-
* This method allows for compatibility with common interfaces.
|
599 |
-
*
|
600 |
-
* @param mixed $level The log level
|
601 |
-
* @param string $message The log message
|
602 |
-
* @param array $context The log context
|
603 |
-
* @return bool Whether the record has been processed
|
604 |
-
*/
|
605 |
-
public function log($level, $message, array $context = array())
|
606 |
-
{
|
607 |
-
$level = static::toMonologLevel($level);
|
608 |
-
|
609 |
-
return $this->addRecord($level, $message, $context);
|
610 |
-
}
|
611 |
-
|
612 |
-
/**
|
613 |
-
* Adds a log record at the DEBUG level.
|
614 |
-
*
|
615 |
-
* This method allows for compatibility with common interfaces.
|
616 |
-
*
|
617 |
-
* @param string $message The log message
|
618 |
-
* @param array $context The log context
|
619 |
-
* @return bool Whether the record has been processed
|
620 |
-
*/
|
621 |
-
public function debug($message, array $context = array())
|
622 |
-
{
|
623 |
-
return $this->addRecord(static::DEBUG, $message, $context);
|
624 |
-
}
|
625 |
-
|
626 |
-
/**
|
627 |
-
* Adds a log record at the INFO level.
|
628 |
-
*
|
629 |
-
* This method allows for compatibility with common interfaces.
|
630 |
-
*
|
631 |
-
* @param string $message The log message
|
632 |
-
* @param array $context The log context
|
633 |
-
* @return bool Whether the record has been processed
|
634 |
-
*/
|
635 |
-
public function info($message, array $context = array())
|
636 |
-
{
|
637 |
-
return $this->addRecord(static::INFO, $message, $context);
|
638 |
-
}
|
639 |
-
|
640 |
-
/**
|
641 |
-
* Adds a log record at the NOTICE level.
|
642 |
-
*
|
643 |
-
* This method allows for compatibility with common interfaces.
|
644 |
-
*
|
645 |
-
* @param string $message The log message
|
646 |
-
* @param array $context The log context
|
647 |
-
* @return bool Whether the record has been processed
|
648 |
-
*/
|
649 |
-
public function notice($message, array $context = array())
|
650 |
-
{
|
651 |
-
return $this->addRecord(static::NOTICE, $message, $context);
|
652 |
-
}
|
653 |
-
|
654 |
-
/**
|
655 |
-
* Adds a log record at the WARNING level.
|
656 |
-
*
|
657 |
-
* This method allows for compatibility with common interfaces.
|
658 |
-
*
|
659 |
-
* @param string $message The log message
|
660 |
-
* @param array $context The log context
|
661 |
-
* @return bool Whether the record has been processed
|
662 |
-
*/
|
663 |
-
public function warn($message, array $context = array())
|
664 |
-
{
|
665 |
-
return $this->addRecord(static::WARNING, $message, $context);
|
666 |
-
}
|
667 |
-
|
668 |
-
/**
|
669 |
-
* Adds a log record at the WARNING level.
|
670 |
-
*
|
671 |
-
* This method allows for compatibility with common interfaces.
|
672 |
-
*
|
673 |
-
* @param string $message The log message
|
674 |
-
* @param array $context The log context
|
675 |
-
* @return bool Whether the record has been processed
|
676 |
-
*/
|
677 |
-
public function warning($message, array $context = array())
|
678 |
-
{
|
679 |
-
return $this->addRecord(static::WARNING, $message, $context);
|
680 |
-
}
|
681 |
-
|
682 |
-
/**
|
683 |
-
* Adds a log record at the ERROR level.
|
684 |
-
*
|
685 |
-
* This method allows for compatibility with common interfaces.
|
686 |
-
*
|
687 |
-
* @param string $message The log message
|
688 |
-
* @param array $context The log context
|
689 |
-
* @return bool Whether the record has been processed
|
690 |
-
*/
|
691 |
-
public function err($message, array $context = array())
|
692 |
-
{
|
693 |
-
return $this->addRecord(static::ERROR, $message, $context);
|
694 |
-
}
|
695 |
-
|
696 |
-
/**
|
697 |
-
* Adds a log record at the ERROR level.
|
698 |
-
*
|
699 |
-
* This method allows for compatibility with common interfaces.
|
700 |
-
*
|
701 |
-
* @param string $message The log message
|
702 |
-
* @param array $context The log context
|
703 |
-
* @return bool Whether the record has been processed
|
704 |
-
*/
|
705 |
-
public function error($message, array $context = array())
|
706 |
-
{
|
707 |
-
return $this->addRecord(static::ERROR, $message, $context);
|
708 |
-
}
|
709 |
-
|
710 |
-
/**
|
711 |
-
* Adds a log record at the CRITICAL level.
|
712 |
-
*
|
713 |
-
* This method allows for compatibility with common interfaces.
|
714 |
-
*
|
715 |
-
* @param string $message The log message
|
716 |
-
* @param array $context The log context
|
717 |
-
* @return bool Whether the record has been processed
|
718 |
-
*/
|
719 |
-
public function crit($message, array $context = array())
|
720 |
-
{
|
721 |
-
return $this->addRecord(static::CRITICAL, $message, $context);
|
722 |
-
}
|
723 |
-
|
724 |
-
/**
|
725 |
-
* Adds a log record at the CRITICAL level.
|
726 |
-
*
|
727 |
-
* This method allows for compatibility with common interfaces.
|
728 |
-
*
|
729 |
-
* @param string $message The log message
|
730 |
-
* @param array $context The log context
|
731 |
-
* @return bool Whether the record has been processed
|
732 |
-
*/
|
733 |
-
public function critical($message, array $context = array())
|
734 |
-
{
|
735 |
-
return $this->addRecord(static::CRITICAL, $message, $context);
|
736 |
-
}
|
737 |
-
|
738 |
-
/**
|
739 |
-
* Adds a log record at the ALERT level.
|
740 |
-
*
|
741 |
-
* This method allows for compatibility with common interfaces.
|
742 |
-
*
|
743 |
-
* @param string $message The log message
|
744 |
-
* @param array $context The log context
|
745 |
-
* @return bool Whether the record has been processed
|
746 |
-
*/
|
747 |
-
public function alert($message, array $context = array())
|
748 |
-
{
|
749 |
-
return $this->addRecord(static::ALERT, $message, $context);
|
750 |
-
}
|
751 |
-
|
752 |
-
/**
|
753 |
-
* Adds a log record at the EMERGENCY level.
|
754 |
-
*
|
755 |
-
* This method allows for compatibility with common interfaces.
|
756 |
-
*
|
757 |
-
* @param string $message The log message
|
758 |
-
* @param array $context The log context
|
759 |
-
* @return bool Whether the record has been processed
|
760 |
-
*/
|
761 |
-
public function emerg($message, array $context = array())
|
762 |
-
{
|
763 |
-
return $this->addRecord(static::EMERGENCY, $message, $context);
|
764 |
-
}
|
765 |
-
|
766 |
-
/**
|
767 |
-
* Adds a log record at the EMERGENCY level.
|
768 |
-
*
|
769 |
-
* This method allows for compatibility with common interfaces.
|
770 |
-
*
|
771 |
-
* @param string $message The log message
|
772 |
-
* @param array $context The log context
|
773 |
-
* @return bool Whether the record has been processed
|
774 |
-
*/
|
775 |
-
public function emergency($message, array $context = array())
|
776 |
-
{
|
777 |
-
return $this->addRecord(static::EMERGENCY, $message, $context);
|
778 |
-
}
|
779 |
-
|
780 |
-
/**
|
781 |
-
* Set the timezone to be used for the timestamp of log records.
|
782 |
-
*
|
783 |
-
* This is stored globally for all Logger instances
|
784 |
-
*
|
785 |
-
* @param \DateTimeZone $tz Timezone object
|
786 |
-
*/
|
787 |
-
public static function setTimezone(\DateTimeZone $tz)
|
788 |
-
{
|
789 |
-
self::$timezone = $tz;
|
790 |
-
}
|
791 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Injects Git branch and Git commit SHA in all records
|
18 |
-
*
|
19 |
-
* @author Nick Otter
|
20 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
21 |
-
*/
|
22 |
-
class GitProcessor implements ProcessorInterface
|
23 |
-
{
|
24 |
-
private $level;
|
25 |
-
private static $cache;
|
26 |
-
|
27 |
-
public function __construct($level = Logger::DEBUG)
|
28 |
-
{
|
29 |
-
$this->level = Logger::toMonologLevel($level);
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @param array $record
|
34 |
-
* @return array
|
35 |
-
*/
|
36 |
-
public function __invoke(array $record)
|
37 |
-
{
|
38 |
-
// return if the level is not high enough
|
39 |
-
if ($record['level'] < $this->level) {
|
40 |
-
return $record;
|
41 |
-
}
|
42 |
-
|
43 |
-
$record['extra']['git'] = self::getGitInfo();
|
44 |
-
|
45 |
-
return $record;
|
46 |
-
}
|
47 |
-
|
48 |
-
private static function getGitInfo()
|
49 |
-
{
|
50 |
-
if (self::$cache) {
|
51 |
-
return self::$cache;
|
52 |
-
}
|
53 |
-
|
54 |
-
$branches = `git branch -v --no-abbrev`;
|
55 |
-
if (preg_match('{^\* (.+?)\s+([a-f0-9]{40})(?:\s|$)}m', $branches, $matches)) {
|
56 |
-
return self::$cache = array(
|
57 |
-
'branch' => $matches[1],
|
58 |
-
'commit' => $matches[2],
|
59 |
-
);
|
60 |
-
}
|
61 |
-
|
62 |
-
return self::$cache = array();
|
63 |
-
}
|
64 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php
DELETED
@@ -1,112 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Injects line/file:class/function where the log message came from
|
18 |
-
*
|
19 |
-
* Warning: This only works if the handler processes the logs directly.
|
20 |
-
* If you put the processor on a handler that is behind a FingersCrossedHandler
|
21 |
-
* for example, the processor will only be called once the trigger level is reached,
|
22 |
-
* and all the log records will have the same file/line/.. data from the call that
|
23 |
-
* triggered the FingersCrossedHandler.
|
24 |
-
*
|
25 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
26 |
-
*/
|
27 |
-
class IntrospectionProcessor implements ProcessorInterface
|
28 |
-
{
|
29 |
-
private $level;
|
30 |
-
|
31 |
-
private $skipClassesPartials;
|
32 |
-
|
33 |
-
private $skipStackFramesCount;
|
34 |
-
|
35 |
-
private $skipFunctions = array(
|
36 |
-
'call_user_func',
|
37 |
-
'call_user_func_array',
|
38 |
-
);
|
39 |
-
|
40 |
-
public function __construct($level = Logger::DEBUG, array $skipClassesPartials = array(), $skipStackFramesCount = 0)
|
41 |
-
{
|
42 |
-
$this->level = Logger::toMonologLevel($level);
|
43 |
-
$this->skipClassesPartials = array_merge(array('Monolog\\'), $skipClassesPartials);
|
44 |
-
$this->skipStackFramesCount = $skipStackFramesCount;
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* @param array $record
|
49 |
-
* @return array
|
50 |
-
*/
|
51 |
-
public function __invoke(array $record)
|
52 |
-
{
|
53 |
-
// return if the level is not high enough
|
54 |
-
if ($record['level'] < $this->level) {
|
55 |
-
return $record;
|
56 |
-
}
|
57 |
-
|
58 |
-
/*
|
59 |
-
* http://php.net/manual/en/function.debug-backtrace.php
|
60 |
-
* As of 5.3.6, DEBUG_BACKTRACE_IGNORE_ARGS option was added.
|
61 |
-
* Any version less than 5.3.6 must use the DEBUG_BACKTRACE_IGNORE_ARGS constant value '2'.
|
62 |
-
*/
|
63 |
-
$trace = debug_backtrace((PHP_VERSION_ID < 50306) ? 2 : DEBUG_BACKTRACE_IGNORE_ARGS);
|
64 |
-
|
65 |
-
// skip first since it's always the current method
|
66 |
-
array_shift($trace);
|
67 |
-
// the call_user_func call is also skipped
|
68 |
-
array_shift($trace);
|
69 |
-
|
70 |
-
$i = 0;
|
71 |
-
|
72 |
-
while ($this->isTraceClassOrSkippedFunction($trace, $i)) {
|
73 |
-
if (isset($trace[$i]['class'])) {
|
74 |
-
foreach ($this->skipClassesPartials as $part) {
|
75 |
-
if (strpos($trace[$i]['class'], $part) !== false) {
|
76 |
-
$i++;
|
77 |
-
continue 2;
|
78 |
-
}
|
79 |
-
}
|
80 |
-
} elseif (in_array($trace[$i]['function'], $this->skipFunctions)) {
|
81 |
-
$i++;
|
82 |
-
continue;
|
83 |
-
}
|
84 |
-
|
85 |
-
break;
|
86 |
-
}
|
87 |
-
|
88 |
-
$i += $this->skipStackFramesCount;
|
89 |
-
|
90 |
-
// we should have the call source now
|
91 |
-
$record['extra'] = array_merge(
|
92 |
-
$record['extra'],
|
93 |
-
array(
|
94 |
-
'file' => isset($trace[$i - 1]['file']) ? $trace[$i - 1]['file'] : null,
|
95 |
-
'line' => isset($trace[$i - 1]['line']) ? $trace[$i - 1]['line'] : null,
|
96 |
-
'class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : null,
|
97 |
-
'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null,
|
98 |
-
)
|
99 |
-
);
|
100 |
-
|
101 |
-
return $record;
|
102 |
-
}
|
103 |
-
|
104 |
-
private function isTraceClassOrSkippedFunction(array $trace, $index)
|
105 |
-
{
|
106 |
-
if (!isset($trace[$index])) {
|
107 |
-
return false;
|
108 |
-
}
|
109 |
-
|
110 |
-
return isset($trace[$index]['class']) || in_array($trace[$index]['function'], $this->skipFunctions);
|
111 |
-
}
|
112 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Injects memory_get_peak_usage in all records
|
16 |
-
*
|
17 |
-
* @see Monolog\Processor\MemoryProcessor::__construct() for options
|
18 |
-
* @author Rob Jensen
|
19 |
-
*/
|
20 |
-
class MemoryPeakUsageProcessor extends MemoryProcessor
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* @param array $record
|
24 |
-
* @return array
|
25 |
-
*/
|
26 |
-
public function __invoke(array $record)
|
27 |
-
{
|
28 |
-
$bytes = memory_get_peak_usage($this->realUsage);
|
29 |
-
$formatted = $this->formatBytes($bytes);
|
30 |
-
|
31 |
-
$record['extra']['memory_peak_usage'] = $formatted;
|
32 |
-
|
33 |
-
return $record;
|
34 |
-
}
|
35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Some methods that are common for all memory processors
|
16 |
-
*
|
17 |
-
* @author Rob Jensen
|
18 |
-
*/
|
19 |
-
abstract class MemoryProcessor implements ProcessorInterface
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* @var bool If true, get the real size of memory allocated from system. Else, only the memory used by emalloc() is reported.
|
23 |
-
*/
|
24 |
-
protected $realUsage;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @var bool If true, then format memory size to human readable string (MB, KB, B depending on size)
|
28 |
-
*/
|
29 |
-
protected $useFormatting;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @param bool $realUsage Set this to true to get the real size of memory allocated from system.
|
33 |
-
* @param bool $useFormatting If true, then format memory size to human readable string (MB, KB, B depending on size)
|
34 |
-
*/
|
35 |
-
public function __construct($realUsage = true, $useFormatting = true)
|
36 |
-
{
|
37 |
-
$this->realUsage = (bool) $realUsage;
|
38 |
-
$this->useFormatting = (bool) $useFormatting;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Formats bytes into a human readable string if $this->useFormatting is true, otherwise return $bytes as is
|
43 |
-
*
|
44 |
-
* @param int $bytes
|
45 |
-
* @return string|int Formatted string if $this->useFormatting is true, otherwise return $bytes as is
|
46 |
-
*/
|
47 |
-
protected function formatBytes($bytes)
|
48 |
-
{
|
49 |
-
$bytes = (int) $bytes;
|
50 |
-
|
51 |
-
if (!$this->useFormatting) {
|
52 |
-
return $bytes;
|
53 |
-
}
|
54 |
-
|
55 |
-
if ($bytes > 1024 * 1024) {
|
56 |
-
return round($bytes / 1024 / 1024, 2).' MB';
|
57 |
-
} elseif ($bytes > 1024) {
|
58 |
-
return round($bytes / 1024, 2).' KB';
|
59 |
-
}
|
60 |
-
|
61 |
-
return $bytes . ' B';
|
62 |
-
}
|
63 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Injects memory_get_usage in all records
|
16 |
-
*
|
17 |
-
* @see Monolog\Processor\MemoryProcessor::__construct() for options
|
18 |
-
* @author Rob Jensen
|
19 |
-
*/
|
20 |
-
class MemoryUsageProcessor extends MemoryProcessor
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* @param array $record
|
24 |
-
* @return array
|
25 |
-
*/
|
26 |
-
public function __invoke(array $record)
|
27 |
-
{
|
28 |
-
$bytes = memory_get_usage($this->realUsage);
|
29 |
-
$formatted = $this->formatBytes($bytes);
|
30 |
-
|
31 |
-
$record['extra']['memory_usage'] = $formatted;
|
32 |
-
|
33 |
-
return $record;
|
34 |
-
}
|
35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Processor/MercurialProcessor.php
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jonathan A. Schweder <jonathanschweder@gmail.com>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
use Monolog\Logger;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Injects Hg branch and Hg revision number in all records
|
18 |
-
*
|
19 |
-
* @author Jonathan A. Schweder <jonathanschweder@gmail.com>
|
20 |
-
*/
|
21 |
-
class MercurialProcessor implements ProcessorInterface
|
22 |
-
{
|
23 |
-
private $level;
|
24 |
-
private static $cache;
|
25 |
-
|
26 |
-
public function __construct($level = Logger::DEBUG)
|
27 |
-
{
|
28 |
-
$this->level = Logger::toMonologLevel($level);
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @param array $record
|
33 |
-
* @return array
|
34 |
-
*/
|
35 |
-
public function __invoke(array $record)
|
36 |
-
{
|
37 |
-
// return if the level is not high enough
|
38 |
-
if ($record['level'] < $this->level) {
|
39 |
-
return $record;
|
40 |
-
}
|
41 |
-
|
42 |
-
$record['extra']['hg'] = self::getMercurialInfo();
|
43 |
-
|
44 |
-
return $record;
|
45 |
-
}
|
46 |
-
|
47 |
-
private static function getMercurialInfo()
|
48 |
-
{
|
49 |
-
if (self::$cache) {
|
50 |
-
return self::$cache;
|
51 |
-
}
|
52 |
-
|
53 |
-
$result = explode(' ', trim(`hg id -nb`));
|
54 |
-
if (count($result) >= 3) {
|
55 |
-
return self::$cache = array(
|
56 |
-
'branch' => $result[1],
|
57 |
-
'revision' => $result[2],
|
58 |
-
);
|
59 |
-
}
|
60 |
-
|
61 |
-
return self::$cache = array();
|
62 |
-
}
|
63 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Adds value of getmypid into records
|
16 |
-
*
|
17 |
-
* @author Andreas Hörnicke
|
18 |
-
*/
|
19 |
-
class ProcessIdProcessor implements ProcessorInterface
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* @param array $record
|
23 |
-
* @return array
|
24 |
-
*/
|
25 |
-
public function __invoke(array $record)
|
26 |
-
{
|
27 |
-
$record['extra']['process_id'] = getmypid();
|
28 |
-
|
29 |
-
return $record;
|
30 |
-
}
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Processor/ProcessorInterface.php
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* An optional interface to allow labelling Monolog processors.
|
16 |
-
*
|
17 |
-
* @author Nicolas Grekas <p@tchwork.com>
|
18 |
-
*/
|
19 |
-
interface ProcessorInterface
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* @return array The processed records
|
23 |
-
*/
|
24 |
-
public function __invoke(array $records);
|
25 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
use Monolog\Utils;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Processes a record's message according to PSR-3 rules
|
18 |
-
*
|
19 |
-
* It replaces {foo} with the value from $context['foo']
|
20 |
-
*
|
21 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
22 |
-
*/
|
23 |
-
class PsrLogMessageProcessor implements ProcessorInterface
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* @param array $record
|
27 |
-
* @return array
|
28 |
-
*/
|
29 |
-
public function __invoke(array $record)
|
30 |
-
{
|
31 |
-
if (false === strpos($record['message'], '{')) {
|
32 |
-
return $record;
|
33 |
-
}
|
34 |
-
|
35 |
-
$replacements = array();
|
36 |
-
foreach ($record['context'] as $key => $val) {
|
37 |
-
if (is_null($val) || is_scalar($val) || (is_object($val) && method_exists($val, "__toString"))) {
|
38 |
-
$replacements['{'.$key.'}'] = $val;
|
39 |
-
} elseif (is_object($val)) {
|
40 |
-
$replacements['{'.$key.'}'] = '[object '.Utils::getClass($val).']';
|
41 |
-
} else {
|
42 |
-
$replacements['{'.$key.'}'] = '['.gettype($val).']';
|
43 |
-
}
|
44 |
-
}
|
45 |
-
|
46 |
-
$record['message'] = strtr($record['message'], $replacements);
|
47 |
-
|
48 |
-
return $record;
|
49 |
-
}
|
50 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Adds a tags array into record
|
16 |
-
*
|
17 |
-
* @author Martijn Riemers
|
18 |
-
*/
|
19 |
-
class TagProcessor implements ProcessorInterface
|
20 |
-
{
|
21 |
-
private $tags;
|
22 |
-
|
23 |
-
public function __construct(array $tags = array())
|
24 |
-
{
|
25 |
-
$this->setTags($tags);
|
26 |
-
}
|
27 |
-
|
28 |
-
public function addTags(array $tags = array())
|
29 |
-
{
|
30 |
-
$this->tags = array_merge($this->tags, $tags);
|
31 |
-
}
|
32 |
-
|
33 |
-
public function setTags(array $tags = array())
|
34 |
-
{
|
35 |
-
$this->tags = $tags;
|
36 |
-
}
|
37 |
-
|
38 |
-
public function __invoke(array $record)
|
39 |
-
{
|
40 |
-
$record['extra']['tags'] = $this->tags;
|
41 |
-
|
42 |
-
return $record;
|
43 |
-
}
|
44 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php
DELETED
@@ -1,59 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
use Monolog\ResettableInterface;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Adds a unique identifier into records
|
18 |
-
*
|
19 |
-
* @author Simon Mönch <sm@webfactory.de>
|
20 |
-
*/
|
21 |
-
class UidProcessor implements ProcessorInterface, ResettableInterface
|
22 |
-
{
|
23 |
-
private $uid;
|
24 |
-
|
25 |
-
public function __construct($length = 7)
|
26 |
-
{
|
27 |
-
if (!is_int($length) || $length > 32 || $length < 1) {
|
28 |
-
throw new \InvalidArgumentException('The uid length must be an integer between 1 and 32');
|
29 |
-
}
|
30 |
-
|
31 |
-
|
32 |
-
$this->uid = $this->generateUid($length);
|
33 |
-
}
|
34 |
-
|
35 |
-
public function __invoke(array $record)
|
36 |
-
{
|
37 |
-
$record['extra']['uid'] = $this->uid;
|
38 |
-
|
39 |
-
return $record;
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* @return string
|
44 |
-
*/
|
45 |
-
public function getUid()
|
46 |
-
{
|
47 |
-
return $this->uid;
|
48 |
-
}
|
49 |
-
|
50 |
-
public function reset()
|
51 |
-
{
|
52 |
-
$this->uid = $this->generateUid(strlen($this->uid));
|
53 |
-
}
|
54 |
-
|
55 |
-
private function generateUid($length)
|
56 |
-
{
|
57 |
-
return substr(hash('md5', uniqid('', true)), 0, $length);
|
58 |
-
}
|
59 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php
DELETED
@@ -1,113 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog\Processor;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Injects url/method and remote IP of the current web request in all records
|
16 |
-
*
|
17 |
-
* @author Jordi Boggiano <j.boggiano@seld.be>
|
18 |
-
*/
|
19 |
-
class WebProcessor implements ProcessorInterface
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* @var array|\ArrayAccess
|
23 |
-
*/
|
24 |
-
protected $serverData;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Default fields
|
28 |
-
*
|
29 |
-
* Array is structured as [key in record.extra => key in $serverData]
|
30 |
-
*
|
31 |
-
* @var array
|
32 |
-
*/
|
33 |
-
protected $extraFields = array(
|
34 |
-
'url' => 'REQUEST_URI',
|
35 |
-
'ip' => 'REMOTE_ADDR',
|
36 |
-
'http_method' => 'REQUEST_METHOD',
|
37 |
-
'server' => 'SERVER_NAME',
|
38 |
-
'referrer' => 'HTTP_REFERER',
|
39 |
-
);
|
40 |
-
|
41 |
-
/**
|
42 |
-
* @param array|\ArrayAccess $serverData Array or object w/ ArrayAccess that provides access to the $_SERVER data
|
43 |
-
* @param array|null $extraFields Field names and the related key inside $serverData to be added. If not provided it defaults to: url, ip, http_method, server, referrer
|
44 |
-
*/
|
45 |
-
public function __construct($serverData = null, array $extraFields = null)
|
46 |
-
{
|
47 |
-
if (null === $serverData) {
|
48 |
-
$this->serverData = &$_SERVER;
|
49 |
-
} elseif (is_array($serverData) || $serverData instanceof \ArrayAccess) {
|
50 |
-
$this->serverData = $serverData;
|
51 |
-
} else {
|
52 |
-
throw new \UnexpectedValueException('$serverData must be an array or object implementing ArrayAccess.');
|
53 |
-
}
|
54 |
-
|
55 |
-
if (null !== $extraFields) {
|
56 |
-
if (isset($extraFields[0])) {
|
57 |
-
foreach (array_keys($this->extraFields) as $fieldName) {
|
58 |
-
if (!in_array($fieldName, $extraFields)) {
|
59 |
-
unset($this->extraFields[$fieldName]);
|
60 |
-
}
|
61 |
-
}
|
62 |
-
} else {
|
63 |
-
$this->extraFields = $extraFields;
|
64 |
-
}
|
65 |
-
}
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* @param array $record
|
70 |
-
* @return array
|
71 |
-
*/
|
72 |
-
public function __invoke(array $record)
|
73 |
-
{
|
74 |
-
// skip processing if for some reason request data
|
75 |
-
// is not present (CLI or wonky SAPIs)
|
76 |
-
if (!isset($this->serverData['REQUEST_URI'])) {
|
77 |
-
return $record;
|
78 |
-
}
|
79 |
-
|
80 |
-
$record['extra'] = $this->appendExtraFields($record['extra']);
|
81 |
-
|
82 |
-
return $record;
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* @param string $extraName
|
87 |
-
* @param string $serverName
|
88 |
-
* @return $this
|
89 |
-
*/
|
90 |
-
public function addExtraField($extraName, $serverName)
|
91 |
-
{
|
92 |
-
$this->extraFields[$extraName] = $serverName;
|
93 |
-
|
94 |
-
return $this;
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* @param array $extra
|
99 |
-
* @return array
|
100 |
-
*/
|
101 |
-
private function appendExtraFields(array $extra)
|
102 |
-
{
|
103 |
-
foreach ($this->extraFields as $extraName => $serverName) {
|
104 |
-
$extra[$extraName] = isset($this->serverData[$serverName]) ? $this->serverData[$serverName] : null;
|
105 |
-
}
|
106 |
-
|
107 |
-
if (isset($this->serverData['UNIQUE_ID'])) {
|
108 |
-
$extra['unique_id'] = $this->serverData['UNIQUE_ID'];
|
109 |
-
}
|
110 |
-
|
111 |
-
return $extra;
|
112 |
-
}
|
113 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Registry.php
DELETED
@@ -1,134 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog;
|
13 |
-
|
14 |
-
use InvalidArgumentException;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Monolog log registry
|
18 |
-
*
|
19 |
-
* Allows to get `Logger` instances in the global scope
|
20 |
-
* via static method calls on this class.
|
21 |
-
*
|
22 |
-
* <code>
|
23 |
-
* $application = new Monolog\Logger('application');
|
24 |
-
* $api = new Monolog\Logger('api');
|
25 |
-
*
|
26 |
-
* Monolog\Registry::addLogger($application);
|
27 |
-
* Monolog\Registry::addLogger($api);
|
28 |
-
*
|
29 |
-
* function testLogger()
|
30 |
-
* {
|
31 |
-
* Monolog\Registry::api()->addError('Sent to $api Logger instance');
|
32 |
-
* Monolog\Registry::application()->addError('Sent to $application Logger instance');
|
33 |
-
* }
|
34 |
-
* </code>
|
35 |
-
*
|
36 |
-
* @author Tomas Tatarko <tomas@tatarko.sk>
|
37 |
-
*/
|
38 |
-
class Registry
|
39 |
-
{
|
40 |
-
/**
|
41 |
-
* List of all loggers in the registry (by named indexes)
|
42 |
-
*
|
43 |
-
* @var Logger[]
|
44 |
-
*/
|
45 |
-
private static $loggers = array();
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Adds new logging channel to the registry
|
49 |
-
*
|
50 |
-
* @param Logger $logger Instance of the logging channel
|
51 |
-
* @param string|null $name Name of the logging channel ($logger->getName() by default)
|
52 |
-
* @param bool $overwrite Overwrite instance in the registry if the given name already exists?
|
53 |
-
* @throws \InvalidArgumentException If $overwrite set to false and named Logger instance already exists
|
54 |
-
*/
|
55 |
-
public static function addLogger(Logger $logger, $name = null, $overwrite = false)
|
56 |
-
{
|
57 |
-
$name = $name ?: $logger->getName();
|
58 |
-
|
59 |
-
if (isset(self::$loggers[$name]) && !$overwrite) {
|
60 |
-
throw new InvalidArgumentException('Logger with the given name already exists');
|
61 |
-
}
|
62 |
-
|
63 |
-
self::$loggers[$name] = $logger;
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Checks if such logging channel exists by name or instance
|
68 |
-
*
|
69 |
-
* @param string|Logger $logger Name or logger instance
|
70 |
-
*/
|
71 |
-
public static function hasLogger($logger)
|
72 |
-
{
|
73 |
-
if ($logger instanceof Logger) {
|
74 |
-
$index = array_search($logger, self::$loggers, true);
|
75 |
-
|
76 |
-
return false !== $index;
|
77 |
-
} else {
|
78 |
-
return isset(self::$loggers[$logger]);
|
79 |
-
}
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Removes instance from registry by name or instance
|
84 |
-
*
|
85 |
-
* @param string|Logger $logger Name or logger instance
|
86 |
-
*/
|
87 |
-
public static function removeLogger($logger)
|
88 |
-
{
|
89 |
-
if ($logger instanceof Logger) {
|
90 |
-
if (false !== ($idx = array_search($logger, self::$loggers, true))) {
|
91 |
-
unset(self::$loggers[$idx]);
|
92 |
-
}
|
93 |
-
} else {
|
94 |
-
unset(self::$loggers[$logger]);
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Clears the registry
|
100 |
-
*/
|
101 |
-
public static function clear()
|
102 |
-
{
|
103 |
-
self::$loggers = array();
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Gets Logger instance from the registry
|
108 |
-
*
|
109 |
-
* @param string $name Name of the requested Logger instance
|
110 |
-
* @throws \InvalidArgumentException If named Logger instance is not in the registry
|
111 |
-
* @return Logger Requested instance of Logger
|
112 |
-
*/
|
113 |
-
public static function getInstance($name)
|
114 |
-
{
|
115 |
-
if (!isset(self::$loggers[$name])) {
|
116 |
-
throw new InvalidArgumentException(sprintf('Requested "%s" logger instance is not in the registry', $name));
|
117 |
-
}
|
118 |
-
|
119 |
-
return self::$loggers[$name];
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Gets Logger instance from the registry via static method call
|
124 |
-
*
|
125 |
-
* @param string $name Name of the requested Logger instance
|
126 |
-
* @param array $arguments Arguments passed to static method call
|
127 |
-
* @throws \InvalidArgumentException If named Logger instance is not in the registry
|
128 |
-
* @return Logger Requested instance of Logger
|
129 |
-
*/
|
130 |
-
public static function __callStatic($name, $arguments)
|
131 |
-
{
|
132 |
-
return self::getInstance($name);
|
133 |
-
}
|
134 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/ResettableInterface.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Handler or Processor implementing this interface will be reset when Logger::reset() is called.
|
16 |
-
*
|
17 |
-
* Resetting ends a log cycle gets them back to their initial state.
|
18 |
-
*
|
19 |
-
* Resetting a Handler or a Processor means flushing/cleaning all buffers, resetting internal
|
20 |
-
* state, and getting it back to a state in which it can receive log records again.
|
21 |
-
*
|
22 |
-
* This is useful in case you want to avoid logs leaking between two requests or jobs when you
|
23 |
-
* have a long running process like a worker or an application server serving multiple requests
|
24 |
-
* in one process.
|
25 |
-
*
|
26 |
-
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
27 |
-
*/
|
28 |
-
interface ResettableInterface
|
29 |
-
{
|
30 |
-
public function reset();
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/SignalHandler.php
DELETED
@@ -1,115 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog;
|
13 |
-
|
14 |
-
use Psr\Log\LoggerInterface;
|
15 |
-
use Psr\Log\LogLevel;
|
16 |
-
use ReflectionExtension;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Monolog POSIX signal handler
|
20 |
-
*
|
21 |
-
* @author Robert Gust-Bardon <robert@gust-bardon.org>
|
22 |
-
*/
|
23 |
-
class SignalHandler
|
24 |
-
{
|
25 |
-
private $logger;
|
26 |
-
|
27 |
-
private $previousSignalHandler = array();
|
28 |
-
private $signalLevelMap = array();
|
29 |
-
private $signalRestartSyscalls = array();
|
30 |
-
|
31 |
-
public function __construct(LoggerInterface $logger)
|
32 |
-
{
|
33 |
-
$this->logger = $logger;
|
34 |
-
}
|
35 |
-
|
36 |
-
public function registerSignalHandler($signo, $level = LogLevel::CRITICAL, $callPrevious = true, $restartSyscalls = true, $async = true)
|
37 |
-
{
|
38 |
-
if (!extension_loaded('pcntl') || !function_exists('pcntl_signal')) {
|
39 |
-
return $this;
|
40 |
-
}
|
41 |
-
|
42 |
-
if ($callPrevious) {
|
43 |
-
if (function_exists('pcntl_signal_get_handler')) {
|
44 |
-
$handler = pcntl_signal_get_handler($signo);
|
45 |
-
if ($handler === false) {
|
46 |
-
return $this;
|
47 |
-
}
|
48 |
-
$this->previousSignalHandler[$signo] = $handler;
|
49 |
-
} else {
|
50 |
-
$this->previousSignalHandler[$signo] = true;
|
51 |
-
}
|
52 |
-
} else {
|
53 |
-
unset($this->previousSignalHandler[$signo]);
|
54 |
-
}
|
55 |
-
$this->signalLevelMap[$signo] = $level;
|
56 |
-
$this->signalRestartSyscalls[$signo] = $restartSyscalls;
|
57 |
-
|
58 |
-
if (function_exists('pcntl_async_signals') && $async !== null) {
|
59 |
-
pcntl_async_signals($async);
|
60 |
-
}
|
61 |
-
|
62 |
-
pcntl_signal($signo, array($this, 'handleSignal'), $restartSyscalls);
|
63 |
-
|
64 |
-
return $this;
|
65 |
-
}
|
66 |
-
|
67 |
-
public function handleSignal($signo, array $siginfo = null)
|
68 |
-
{
|
69 |
-
static $signals = array();
|
70 |
-
|
71 |
-
if (!$signals && extension_loaded('pcntl')) {
|
72 |
-
$pcntl = new ReflectionExtension('pcntl');
|
73 |
-
$constants = $pcntl->getConstants();
|
74 |
-
if (!$constants) {
|
75 |
-
// HHVM 3.24.2 returns an empty array.
|
76 |
-
$constants = get_defined_constants(true);
|
77 |
-
$constants = $constants['Core'];
|
78 |
-
}
|
79 |
-
foreach ($constants as $name => $value) {
|
80 |
-
if (substr($name, 0, 3) === 'SIG' && $name[3] !== '_' && is_int($value)) {
|
81 |
-
$signals[$value] = $name;
|
82 |
-
}
|
83 |
-
}
|
84 |
-
unset($constants);
|
85 |
-
}
|
86 |
-
|
87 |
-
$level = isset($this->signalLevelMap[$signo]) ? $this->signalLevelMap[$signo] : LogLevel::CRITICAL;
|
88 |
-
$signal = isset($signals[$signo]) ? $signals[$signo] : $signo;
|
89 |
-
$context = isset($siginfo) ? $siginfo : array();
|
90 |
-
$this->logger->log($level, sprintf('Program received signal %s', $signal), $context);
|
91 |
-
|
92 |
-
if (!isset($this->previousSignalHandler[$signo])) {
|
93 |
-
return;
|
94 |
-
}
|
95 |
-
|
96 |
-
if ($this->previousSignalHandler[$signo] === true || $this->previousSignalHandler[$signo] === SIG_DFL) {
|
97 |
-
if (extension_loaded('pcntl') && function_exists('pcntl_signal') && function_exists('pcntl_sigprocmask') && function_exists('pcntl_signal_dispatch')
|
98 |
-
&& extension_loaded('posix') && function_exists('posix_getpid') && function_exists('posix_kill')) {
|
99 |
-
$restartSyscalls = isset($this->signalRestartSyscalls[$signo]) ? $this->signalRestartSyscalls[$signo] : true;
|
100 |
-
pcntl_signal($signo, SIG_DFL, $restartSyscalls);
|
101 |
-
pcntl_sigprocmask(SIG_UNBLOCK, array($signo), $oldset);
|
102 |
-
posix_kill(posix_getpid(), $signo);
|
103 |
-
pcntl_signal_dispatch();
|
104 |
-
pcntl_sigprocmask(SIG_SETMASK, $oldset);
|
105 |
-
pcntl_signal($signo, array($this, 'handleSignal'), $restartSyscalls);
|
106 |
-
}
|
107 |
-
} elseif (is_callable($this->previousSignalHandler[$signo])) {
|
108 |
-
if (PHP_VERSION_ID >= 70100) {
|
109 |
-
$this->previousSignalHandler[$signo]($signo, $siginfo);
|
110 |
-
} else {
|
111 |
-
$this->previousSignalHandler[$signo]($signo);
|
112 |
-
}
|
113 |
-
}
|
114 |
-
}
|
115 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/monolog/monolog/src/Monolog/Utils.php
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of the Monolog package.
|
5 |
-
*
|
6 |
-
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Monolog;
|
13 |
-
|
14 |
-
class Utils
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* @internal
|
18 |
-
*/
|
19 |
-
public static function getClass($object)
|
20 |
-
{
|
21 |
-
$class = \get_class($object);
|
22 |
-
|
23 |
-
return 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class;
|
24 |
-
}
|
25 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/psr/log/LICENSE
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
Copyright (c) 2012 PHP Framework Interoperability Group
|
2 |
-
|
3 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
-
of this software and associated documentation files (the "Software"), to deal
|
5 |
-
in the Software without restriction, including without limitation the rights
|
6 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7 |
-
copies of the Software, and to permit persons to whom the Software is
|
8 |
-
furnished to do so, subject to the following conditions:
|
9 |
-
|
10 |
-
The above copyright notice and this permission notice shall be included in
|
11 |
-
all copies or substantial portions of the Software.
|
12 |
-
|
13 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19 |
-
THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/psr/log/Psr/Log/AbstractLogger.php
DELETED
@@ -1,128 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Psr\Log;
|
4 |
-
|
5 |
-
/**
|
6 |
-
* This is a simple Logger implementation that other Loggers can inherit from.
|
7 |
-
*
|
8 |
-
* It simply delegates all log-level-specific methods to the `log` method to
|
9 |
-
* reduce boilerplate code that a simple Logger that does the same thing with
|
10 |
-
* messages regardless of the error level has to implement.
|
11 |
-
*/
|
12 |
-
abstract class AbstractLogger implements LoggerInterface
|
13 |
-
{
|
14 |
-
/**
|
15 |
-
* System is unusable.
|
16 |
-
*
|
17 |
-
* @param string $message
|
18 |
-
* @param array $context
|
19 |
-
*
|
20 |
-
* @return void
|
21 |
-
*/
|
22 |
-
public function emergency($message, array $context = array())
|
23 |
-
{
|
24 |
-
$this->log(LogLevel::EMERGENCY, $message, $context);
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Action must be taken immediately.
|
29 |
-
*
|
30 |
-
* Example: Entire website down, database unavailable, etc. This should
|
31 |
-
* trigger the SMS alerts and wake you up.
|
32 |
-
*
|
33 |
-
* @param string $message
|
34 |
-
* @param array $context
|
35 |
-
*
|
36 |
-
* @return void
|
37 |
-
*/
|
38 |
-
public function alert($message, array $context = array())
|
39 |
-
{
|
40 |
-
$this->log(LogLevel::ALERT, $message, $context);
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Critical conditions.
|
45 |
-
*
|
46 |
-
* Example: Application component unavailable, unexpected exception.
|
47 |
-
*
|
48 |
-
* @param string $message
|
49 |
-
* @param array $context
|
50 |
-
*
|
51 |
-
* @return void
|
52 |
-
*/
|
53 |
-
public function critical($message, array $context = array())
|
54 |
-
{
|
55 |
-
$this->log(LogLevel::CRITICAL, $message, $context);
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Runtime errors that do not require immediate action but should typically
|
60 |
-
* be logged and monitored.
|
61 |
-
*
|
62 |
-
* @param string $message
|
63 |
-
* @param array $context
|
64 |
-
*
|
65 |
-
* @return void
|
66 |
-
*/
|
67 |
-
public function error($message, array $context = array())
|
68 |
-
{
|
69 |
-
$this->log(LogLevel::ERROR, $message, $context);
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Exceptional occurrences that are not errors.
|
74 |
-
*
|
75 |
-
* Example: Use of deprecated APIs, poor use of an API, undesirable things
|
76 |
-
* that are not necessarily wrong.
|
77 |
-
*
|
78 |
-
* @param string $message
|
79 |
-
* @param array $context
|
80 |
-
*
|
81 |
-
* @return void
|
82 |
-
*/
|
83 |
-
public function warning($message, array $context = array())
|
84 |
-
{
|
85 |
-
$this->log(LogLevel::WARNING, $message, $context);
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Normal but significant events.
|
90 |
-
*
|
91 |
-
* @param string $message
|
92 |
-
* @param array $context
|
93 |
-
*
|
94 |
-
* @return void
|
95 |
-
*/
|
96 |
-
public function notice($message, array $context = array())
|
97 |
-
{
|
98 |
-
$this->log(LogLevel::NOTICE, $message, $context);
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Interesting events.
|
103 |
-
*
|
104 |
-
* Example: User logs in, SQL logs.
|
105 |
-
*
|
106 |
-
* @param string $message
|
107 |
-
* @param array $context
|
108 |
-
*
|
109 |
-
* @return void
|
110 |
-
*/
|
111 |
-
public function info($message, array $context = array())
|
112 |
-
{
|
113 |
-
$this->log(LogLevel::INFO, $message, $context);
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* Detailed debug information.
|
118 |
-
*
|
119 |
-
* @param string $message
|
120 |
-
* @param array $context
|
121 |
-
*
|
122 |
-
* @return void
|
123 |
-
*/
|
124 |
-
public function debug($message, array $context = array())
|
125 |
-
{
|
126 |
-
$this->log(LogLevel::DEBUG, $message, $context);
|
127 |
-
}
|
128 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/psr/log/Psr/Log/InvalidArgumentException.php
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Psr\Log;
|
4 |
-
|
5 |
-
class InvalidArgumentException extends \InvalidArgumentException
|
6 |
-
{
|
7 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/psr/log/Psr/Log/LogLevel.php
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Psr\Log;
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Describes log levels.
|
7 |
-
*/
|
8 |
-
class LogLevel
|
9 |
-
{
|
10 |
-
const EMERGENCY = 'emergency';
|
11 |
-
const ALERT = 'alert';
|
12 |
-
const CRITICAL = 'critical';
|
13 |
-
const ERROR = 'error';
|
14 |
-
const WARNING = 'warning';
|
15 |
-
const NOTICE = 'notice';
|
16 |
-
const INFO = 'info';
|
17 |
-
const DEBUG = 'debug';
|
18 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/psr/log/Psr/Log/LoggerAwareInterface.php
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Psr\Log;
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Describes a logger-aware instance.
|
7 |
-
*/
|
8 |
-
interface LoggerAwareInterface
|
9 |
-
{
|
10 |
-
/**
|
11 |
-
* Sets a logger instance on the object.
|
12 |
-
*
|
13 |
-
* @param LoggerInterface $logger
|
14 |
-
*
|
15 |
-
* @return void
|
16 |
-
*/
|
17 |
-
public function setLogger(LoggerInterface $logger);
|
18 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/psr/log/Psr/Log/LoggerAwareTrait.php
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Psr\Log;
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Basic Implementation of LoggerAwareInterface.
|
7 |
-
*/
|
8 |
-
trait LoggerAwareTrait
|
9 |
-
{
|
10 |
-
/**
|
11 |
-
* The logger instance.
|
12 |
-
*
|
13 |
-
* @var LoggerInterface
|
14 |
-
*/
|
15 |
-
protected $logger;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Sets a logger.
|
19 |
-
*
|
20 |
-
* @param LoggerInterface $logger
|
21 |
-
*/
|
22 |
-
public function setLogger(LoggerInterface $logger)
|
23 |
-
{
|
24 |
-
$this->logger = $logger;
|
25 |
-
}
|
26 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/psr/log/Psr/Log/LoggerInterface.php
DELETED
@@ -1,123 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Psr\Log;
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Describes a logger instance.
|
7 |
-
*
|
8 |
-
* The message MUST be a string or object implementing __toString().
|
9 |
-
*
|
10 |
-
* The message MAY contain placeholders in the form: {foo} where foo
|
11 |
-
* will be replaced by the context data in key "foo".
|
12 |
-
*
|
13 |
-
* The context array can contain arbitrary data. The only assumption that
|
14 |
-
* can be made by implementors is that if an Exception instance is given
|
15 |
-
* to produce a stack trace, it MUST be in a key named "exception".
|
16 |
-
*
|
17 |
-
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
|
18 |
-
* for the full interface specification.
|
19 |
-
*/
|
20 |
-
interface LoggerInterface
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* System is unusable.
|
24 |
-
*
|
25 |
-
* @param string $message
|
26 |
-
* @param array $context
|
27 |
-
*
|
28 |
-
* @return void
|
29 |
-
*/
|
30 |
-
public function emergency($message, array $context = array());
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Action must be taken immediately.
|
34 |
-
*
|
35 |
-
* Example: Entire website down, database unavailable, etc. This should
|
36 |
-
* trigger the SMS alerts and wake you up.
|
37 |
-
*
|
38 |
-
* @param string $message
|
39 |
-
* @param array $context
|
40 |
-
*
|
41 |
-
* @return void
|
42 |
-
*/
|
43 |
-
public function alert($message, array $context = array());
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Critical conditions.
|
47 |
-
*
|
48 |
-
* Example: Application component unavailable, unexpected exception.
|
49 |
-
*
|
50 |
-
* @param string $message
|
51 |
-
* @param array $context
|
52 |
-
*
|
53 |
-
* @return void
|
54 |
-
*/
|
55 |
-
public function critical($message, array $context = array());
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Runtime errors that do not require immediate action but should typically
|
59 |
-
* be logged and monitored.
|
60 |
-
*
|
61 |
-
* @param string $message
|
62 |
-
* @param array $context
|
63 |
-
*
|
64 |
-
* @return void
|
65 |
-
*/
|
66 |
-
public function error($message, array $context = array());
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Exceptional occurrences that are not errors.
|
70 |
-
*
|
71 |
-
* Example: Use of deprecated APIs, poor use of an API, undesirable things
|
72 |
-
* that are not necessarily wrong.
|
73 |
-
*
|
74 |
-
* @param string $message
|
75 |
-
* @param array $context
|
76 |
-
*
|
77 |
-
* @return void
|
78 |
-
*/
|
79 |
-
public function warning($message, array $context = array());
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Normal but significant events.
|
83 |
-
*
|
84 |
-
* @param string $message
|
85 |
-
* @param array $context
|
86 |
-
*
|
87 |
-
* @return void
|
88 |
-
*/
|
89 |
-
public function notice($message, array $context = array());
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Interesting events.
|
93 |
-
*
|
94 |
-
* Example: User logs in, SQL logs.
|
95 |
-
*
|
96 |
-
* @param string $message
|
97 |
-
* @param array $context
|
98 |
-
*
|
99 |
-
* @return void
|
100 |
-
*/
|
101 |
-
public function info($message, array $context = array());
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Detailed debug information.
|
105 |
-
*
|
106 |
-
* @param string $message
|
107 |
-
* @param array $context
|
108 |
-
*
|
109 |
-
* @return void
|
110 |
-
*/
|
111 |
-
public function debug($message, array $context = array());
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Logs with an arbitrary level.
|
115 |
-
*
|
116 |
-
* @param mixed $level
|
117 |
-
* @param string $message
|
118 |
-
* @param array $context
|
119 |
-
*
|
120 |
-
* @return void
|
121 |
-
*/
|
122 |
-
public function log($level, $message, array $context = array());
|
123 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/psr/log/Psr/Log/LoggerTrait.php
DELETED
@@ -1,140 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Psr\Log;
|
4 |
-
|
5 |
-
/**
|
6 |
-
* This is a simple Logger trait that classes unable to extend AbstractLogger
|
7 |
-
* (because they extend another class, etc) can include.
|
8 |
-
*
|
9 |
-
* It simply delegates all log-level-specific methods to the `log` method to
|
10 |
-
* reduce boilerplate code that a simple Logger that does the same thing with
|
11 |
-
* messages regardless of the error level has to implement.
|
12 |
-
*/
|
13 |
-
trait LoggerTrait
|
14 |
-
{
|
15 |
-
/**
|
16 |
-
* System is unusable.
|
17 |
-
*
|
18 |
-
* @param string $message
|
19 |
-
* @param array $context
|
20 |
-
*
|
21 |
-
* @return void
|
22 |
-
*/
|
23 |
-
public function emergency($message, array $context = array())
|
24 |
-
{
|
25 |
-
$this->log(LogLevel::EMERGENCY, $message, $context);
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Action must be taken immediately.
|
30 |
-
*
|
31 |
-
* Example: Entire website down, database unavailable, etc. This should
|
32 |
-
* trigger the SMS alerts and wake you up.
|
33 |
-
*
|
34 |
-
* @param string $message
|
35 |
-
* @param array $context
|
36 |
-
*
|
37 |
-
* @return void
|
38 |
-
*/
|
39 |
-
public function alert($message, array $context = array())
|
40 |
-
{
|
41 |
-
$this->log(LogLevel::ALERT, $message, $context);
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Critical conditions.
|
46 |
-
*
|
47 |
-
* Example: Application component unavailable, unexpected exception.
|
48 |
-
*
|
49 |
-
* @param string $message
|
50 |
-
* @param array $context
|
51 |
-
*
|
52 |
-
* @return void
|
53 |
-
*/
|
54 |
-
public function critical($message, array $context = array())
|
55 |
-
{
|
56 |
-
$this->log(LogLevel::CRITICAL, $message, $context);
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Runtime errors that do not require immediate action but should typically
|
61 |
-
* be logged and monitored.
|
62 |
-
*
|
63 |
-
* @param string $message
|
64 |
-
* @param array $context
|
65 |
-
*
|
66 |
-
* @return void
|
67 |
-
*/
|
68 |
-
public function error($message, array $context = array())
|
69 |
-
{
|
70 |
-
$this->log(LogLevel::ERROR, $message, $context);
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Exceptional occurrences that are not errors.
|
75 |
-
*
|
76 |
-
* Example: Use of deprecated APIs, poor use of an API, undesirable things
|
77 |
-
* that are not necessarily wrong.
|
78 |
-
*
|
79 |
-
* @param string $message
|
80 |
-
* @param array $context
|
81 |
-
*
|
82 |
-
* @return void
|
83 |
-
*/
|
84 |
-
public function warning($message, array $context = array())
|
85 |
-
{
|
86 |
-
$this->log(LogLevel::WARNING, $message, $context);
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Normal but significant events.
|
91 |
-
*
|
92 |
-
* @param string $message
|
93 |
-
* @param array $context
|
94 |
-
*
|
95 |
-
* @return void
|
96 |
-
*/
|
97 |
-
public function notice($message, array $context = array())
|
98 |
-
{
|
99 |
-
$this->log(LogLevel::NOTICE, $message, $context);
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Interesting events.
|
104 |
-
*
|
105 |
-
* Example: User logs in, SQL logs.
|
106 |
-
*
|
107 |
-
* @param string $message
|
108 |
-
* @param array $context
|
109 |
-
*
|
110 |
-
* @return void
|
111 |
-
*/
|
112 |
-
public function info($message, array $context = array())
|
113 |
-
{
|
114 |
-
$this->log(LogLevel::INFO, $message, $context);
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Detailed debug information.
|
119 |
-
*
|
120 |
-
* @param string $message
|
121 |
-
* @param array $context
|
122 |
-
*
|
123 |
-
* @return void
|
124 |
-
*/
|
125 |
-
public function debug($message, array $context = array())
|
126 |
-
{
|
127 |
-
$this->log(LogLevel::DEBUG, $message, $context);
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Logs with an arbitrary level.
|
132 |
-
*
|
133 |
-
* @param mixed $level
|
134 |
-
* @param string $message
|
135 |
-
* @param array $context
|
136 |
-
*
|
137 |
-
* @return void
|
138 |
-
*/
|
139 |
-
abstract public function log($level, $message, array $context = array());
|
140 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/psr/log/Psr/Log/NullLogger.php
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Psr\Log;
|
4 |
-
|
5 |
-
/**
|
6 |
-
* This Logger can be used to avoid conditional log calls.
|
7 |
-
*
|
8 |
-
* Logging should always be optional, and if no logger is provided to your
|
9 |
-
* library creating a NullLogger instance to have something to throw logs at
|
10 |
-
* is a good way to avoid littering your code with `if ($this->logger) { }`
|
11 |
-
* blocks.
|
12 |
-
*/
|
13 |
-
class NullLogger extends AbstractLogger
|
14 |
-
{
|
15 |
-
/**
|
16 |
-
* Logs with an arbitrary level.
|
17 |
-
*
|
18 |
-
* @param mixed $level
|
19 |
-
* @param string $message
|
20 |
-
* @param array $context
|
21 |
-
*
|
22 |
-
* @return void
|
23 |
-
*/
|
24 |
-
public function log($level, $message, array $context = array())
|
25 |
-
{
|
26 |
-
// noop
|
27 |
-
}
|
28 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php
DELETED
@@ -1,144 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Psr\Log\Test;
|
4 |
-
|
5 |
-
use Psr\Log\LoggerInterface;
|
6 |
-
use Psr\Log\LogLevel;
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Provides a base test class for ensuring compliance with the LoggerInterface.
|
10 |
-
*
|
11 |
-
* Implementors can extend the class and implement abstract methods to run this
|
12 |
-
* as part of their test suite.
|
13 |
-
*/
|
14 |
-
abstract class LoggerInterfaceTest extends \PHPUnit_Framework_TestCase
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* @return LoggerInterface
|
18 |
-
*/
|
19 |
-
abstract public function getLogger();
|
20 |
-
|
21 |
-
/**
|
22 |
-
* This must return the log messages in order.
|
23 |
-
*
|
24 |
-
* The simple formatting of the messages is: "<LOG LEVEL> <MESSAGE>".
|
25 |
-
*
|
26 |
-
* Example ->error('Foo') would yield "error Foo".
|
27 |
-
*
|
28 |
-
* @return string[]
|
29 |
-
*/
|
30 |
-
abstract public function getLogs();
|
31 |
-
|
32 |
-
public function testImplements()
|
33 |
-
{
|
34 |
-
$this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @dataProvider provideLevelsAndMessages
|
39 |
-
*/
|
40 |
-
public function testLogsAtAllLevels($level, $message)
|
41 |
-
{
|
42 |
-
$logger = $this->getLogger();
|
43 |
-
$logger->{$level}($message, array('user' => 'Bob'));
|
44 |
-
$logger->log($level, $message, array('user' => 'Bob'));
|
45 |
-
|
46 |
-
$expected = array(
|
47 |
-
$level.' message of level '.$level.' with context: Bob',
|
48 |
-
$level.' message of level '.$level.' with context: Bob',
|
49 |
-
);
|
50 |
-
$this->assertEquals($expected, $this->getLogs());
|
51 |
-
}
|
52 |
-
|
53 |
-
public function provideLevelsAndMessages()
|
54 |
-
{
|
55 |
-
return array(
|
56 |
-
LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'),
|
57 |
-
LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'),
|
58 |
-
LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'),
|
59 |
-
LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'),
|
60 |
-
LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'),
|
61 |
-
LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'),
|
62 |
-
LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'),
|
63 |
-
LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'),
|
64 |
-
);
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* @expectedException \Psr\Log\InvalidArgumentException
|
69 |
-
*/
|
70 |
-
public function testThrowsOnInvalidLevel()
|
71 |
-
{
|
72 |
-
$logger = $this->getLogger();
|
73 |
-
$logger->log('invalid level', 'Foo');
|
74 |
-
}
|
75 |
-
|
76 |
-
public function testContextReplacement()
|
77 |
-
{
|
78 |
-
$logger = $this->getLogger();
|
79 |
-
$logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
|
80 |
-
|
81 |
-
$expected = array('info {Message {nothing} Bob Bar a}');
|
82 |
-
$this->assertEquals($expected, $this->getLogs());
|
83 |
-
}
|
84 |
-
|
85 |
-
public function testObjectCastToString()
|
86 |
-
{
|
87 |
-
if (method_exists($this, 'createPartialMock')) {
|
88 |
-
$dummy = $this->createPartialMock('Psr\Log\Test\DummyTest', array('__toString'));
|
89 |
-
} else {
|
90 |
-
$dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString'));
|
91 |
-
}
|
92 |
-
$dummy->expects($this->once())
|
93 |
-
->method('__toString')
|
94 |
-
->will($this->returnValue('DUMMY'));
|
95 |
-
|
96 |
-
$this->getLogger()->warning($dummy);
|
97 |
-
|
98 |
-
$expected = array('warning DUMMY');
|
99 |
-
$this->assertEquals($expected, $this->getLogs());
|
100 |
-
}
|
101 |
-
|
102 |
-
public function testContextCanContainAnything()
|
103 |
-
{
|
104 |
-
$closed = fopen('php://memory', 'r');
|
105 |
-
fclose($closed);
|
106 |
-
|
107 |
-
$context = array(
|
108 |
-
'bool' => true,
|
109 |
-
'null' => null,
|
110 |
-
'string' => 'Foo',
|
111 |
-
'int' => 0,
|
112 |
-
'float' => 0.5,
|
113 |
-
'nested' => array('with object' => new DummyTest),
|
114 |
-
'object' => new \DateTime,
|
115 |
-
'resource' => fopen('php://memory', 'r'),
|
116 |
-
'closed' => $closed,
|
117 |
-
);
|
118 |
-
|
119 |
-
$this->getLogger()->warning('Crazy context data', $context);
|
120 |
-
|
121 |
-
$expected = array('warning Crazy context data');
|
122 |
-
$this->assertEquals($expected, $this->getLogs());
|
123 |
-
}
|
124 |
-
|
125 |
-
public function testContextExceptionKeyCanBeExceptionOrOtherValues()
|
126 |
-
{
|
127 |
-
$logger = $this->getLogger();
|
128 |
-
$logger->warning('Random message', array('exception' => 'oops'));
|
129 |
-
$logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
|
130 |
-
|
131 |
-
$expected = array(
|
132 |
-
'warning Random message',
|
133 |
-
'critical Uncaught Exception!'
|
134 |
-
);
|
135 |
-
$this->assertEquals($expected, $this->getLogs());
|
136 |
-
}
|
137 |
-
}
|
138 |
-
|
139 |
-
class DummyTest
|
140 |
-
{
|
141 |
-
public function __toString()
|
142 |
-
{
|
143 |
-
}
|
144 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/psr/log/Psr/Log/Test/TestLogger.php
DELETED
@@ -1,146 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Psr\Log\Test;
|
4 |
-
|
5 |
-
use Psr\Log\AbstractLogger;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Used for testing purposes.
|
9 |
-
*
|
10 |
-
* It records all records and gives you access to them for verification.
|
11 |
-
*
|
12 |
-
* @method bool hasEmergency($record)
|
13 |
-
* @method bool hasAlert($record)
|
14 |
-
* @method bool hasCritical($record)
|
15 |
-
* @method bool hasError($record)
|
16 |
-
* @method bool hasWarning($record)
|
17 |
-
* @method bool hasNotice($record)
|
18 |
-
* @method bool hasInfo($record)
|
19 |
-
* @method bool hasDebug($record)
|
20 |
-
*
|
21 |
-
* @method bool hasEmergencyRecords()
|
22 |
-
* @method bool hasAlertRecords()
|
23 |
-
* @method bool hasCriticalRecords()
|
24 |
-
* @method bool hasErrorRecords()
|
25 |
-
* @method bool hasWarningRecords()
|
26 |
-
* @method bool hasNoticeRecords()
|
27 |
-
* @method bool hasInfoRecords()
|
28 |
-
* @method bool hasDebugRecords()
|
29 |
-
*
|
30 |
-
* @method bool hasEmergencyThatContains($message)
|
31 |
-
* @method bool hasAlertThatContains($message)
|
32 |
-
* @method bool hasCriticalThatContains($message)
|
33 |
-
* @method bool hasErrorThatContains($message)
|
34 |
-
* @method bool hasWarningThatContains($message)
|
35 |
-
* @method bool hasNoticeThatContains($message)
|
36 |
-
* @method bool hasInfoThatContains($message)
|
37 |
-
* @method bool hasDebugThatContains($message)
|
38 |
-
*
|
39 |
-
* @method bool hasEmergencyThatMatches($message)
|
40 |
-
* @method bool hasAlertThatMatches($message)
|
41 |
-
* @method bool hasCriticalThatMatches($message)
|
42 |
-
* @method bool hasErrorThatMatches($message)
|
43 |
-
* @method bool hasWarningThatMatches($message)
|
44 |
-
* @method bool hasNoticeThatMatches($message)
|
45 |
-
* @method bool hasInfoThatMatches($message)
|
46 |
-
* @method bool hasDebugThatMatches($message)
|
47 |
-
*
|
48 |
-
* @method bool hasEmergencyThatPasses($message)
|
49 |
-
* @method bool hasAlertThatPasses($message)
|
50 |
-
* @method bool hasCriticalThatPasses($message)
|
51 |
-
* @method bool hasErrorThatPasses($message)
|
52 |
-
* @method bool hasWarningThatPasses($message)
|
53 |
-
* @method bool hasNoticeThatPasses($message)
|
54 |
-
* @method bool hasInfoThatPasses($message)
|
55 |
-
* @method bool hasDebugThatPasses($message)
|
56 |
-
*/
|
57 |
-
class TestLogger extends AbstractLogger
|
58 |
-
{
|
59 |
-
/**
|
60 |
-
* @var array
|
61 |
-
*/
|
62 |
-
public $records = [];
|
63 |
-
|
64 |
-
public $recordsByLevel = [];
|
65 |
-
|
66 |
-
/**
|
67 |
-
* @inheritdoc
|
68 |
-
*/
|
69 |
-
public function log($level, $message, array $context = [])
|
70 |
-
{
|
71 |
-
$record = [
|
72 |
-
'level' => $level,
|
73 |
-
'message' => $message,
|
74 |
-
'context' => $context,
|
75 |
-
];
|
76 |
-
|
77 |
-
$this->recordsByLevel[$record['level']][] = $record;
|
78 |
-
$this->records[] = $record;
|
79 |
-
}
|
80 |
-
|
81 |
-
public function hasRecords($level)
|
82 |
-
{
|
83 |
-
return isset($this->recordsByLevel[$level]);
|
84 |
-
}
|
85 |
-
|
86 |
-
public function hasRecord($record, $level)
|
87 |
-
{
|
88 |
-
if (is_string($record)) {
|
89 |
-
$record = ['message' => $record];
|
90 |
-
}
|
91 |
-
return $this->hasRecordThatPasses(function ($rec) use ($record) {
|
92 |
-
if ($rec['message'] !== $record['message']) {
|
93 |
-
return false;
|
94 |
-
}
|
95 |
-
if (isset($record['context']) && $rec['context'] !== $record['context']) {
|
96 |
-
return false;
|
97 |
-
}
|
98 |
-
return true;
|
99 |
-
}, $level);
|
100 |
-
}
|
101 |
-
|
102 |
-
public function hasRecordThatContains($message, $level)
|
103 |
-
{
|
104 |
-
return $this->hasRecordThatPasses(function ($rec) use ($message) {
|
105 |
-
return strpos($rec['message'], $message) !== false;
|
106 |
-
}, $level);
|
107 |
-
}
|
108 |
-
|
109 |
-
public function hasRecordThatMatches($regex, $level)
|
110 |
-
{
|
111 |
-
return $this->hasRecordThatPasses(function ($rec) use ($regex) {
|
112 |
-
return preg_match($regex, $rec['message']) > 0;
|
113 |
-
}, $level);
|
114 |
-
}
|
115 |
-
|
116 |
-
public function hasRecordThatPasses(callable $predicate, $level)
|
117 |
-
{
|
118 |
-
if (!isset($this->recordsByLevel[$level])) {
|
119 |
-
return false;
|
120 |
-
}
|
121 |
-
foreach ($this->recordsByLevel[$level] as $i => $rec) {
|
122 |
-
if (call_user_func($predicate, $rec, $i)) {
|
123 |
-
return true;
|
124 |
-
}
|
125 |
-
}
|
126 |
-
return false;
|
127 |
-
}
|
128 |
-
|
129 |
-
public function __call($method, $args)
|
130 |
-
{
|
131 |
-
if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
|
132 |
-
$genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3];
|
133 |
-
$level = strtolower($matches[2]);
|
134 |
-
if (method_exists($this, $genericMethod)) {
|
135 |
-
$args[] = $level;
|
136 |
-
return call_user_func_array([$this, $genericMethod], $args);
|
137 |
-
}
|
138 |
-
}
|
139 |
-
throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()');
|
140 |
-
}
|
141 |
-
|
142 |
-
public function reset()
|
143 |
-
{
|
144 |
-
$this->records = [];
|
145 |
-
}
|
146 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|