├── .gitignore
├── LICENSE
├── README.md
├── composer.json
├── composer.lock
├── form
├── field
│ └── list.php
└── rule
│ └── login.php
├── helper
├── asset.php
└── numbers.php
├── html
└── sample.php
├── language
├── en-GB
│ └── en-GB.lib_sample.ini
└── fr-FR
│ └── fr-FR.lib_sample.ini
├── library.php
├── media
└── sample
│ ├── css
│ ├── sample.css
│ └── vendor
│ │ └── font-awesome
│ │ ├── font-awesome.css
│ │ └── font-awesome.min.css
│ └── js
│ └── sample.js
├── sample.xml
├── src
├── App.php
├── Helper
│ └── Dummy.php
└── Monolog
│ └── PhpfileHandler.php
└── vendor
├── autoload.php
├── composer
├── ClassLoader.php
├── LICENSE
├── autoload_classmap.php
├── autoload_namespaces.php
├── autoload_psr4.php
├── autoload_real.php
├── autoload_static.php
└── installed.json
├── monolog
└── monolog
│ ├── .php_cs
│ ├── CHANGELOG.mdown
│ ├── LICENSE
│ ├── README.mdown
│ ├── composer.json
│ ├── doc
│ ├── 01-usage.md
│ ├── 02-handlers-formatters-processors.md
│ ├── 03-utilities.md
│ ├── 04-extending.md
│ └── sockets.md
│ ├── phpunit.xml.dist
│ ├── src
│ └── Monolog
│ │ ├── ErrorHandler.php
│ │ ├── Formatter
│ │ ├── ChromePHPFormatter.php
│ │ ├── ElasticaFormatter.php
│ │ ├── FlowdockFormatter.php
│ │ ├── FluentdFormatter.php
│ │ ├── FormatterInterface.php
│ │ ├── GelfMessageFormatter.php
│ │ ├── HtmlFormatter.php
│ │ ├── JsonFormatter.php
│ │ ├── LineFormatter.php
│ │ ├── LogglyFormatter.php
│ │ ├── LogstashFormatter.php
│ │ ├── MongoDBFormatter.php
│ │ ├── NormalizerFormatter.php
│ │ ├── ScalarFormatter.php
│ │ └── WildfireFormatter.php
│ │ ├── Handler
│ │ ├── AbstractHandler.php
│ │ ├── AbstractProcessingHandler.php
│ │ ├── AbstractSyslogHandler.php
│ │ ├── AmqpHandler.php
│ │ ├── BrowserConsoleHandler.php
│ │ ├── BufferHandler.php
│ │ ├── ChromePHPHandler.php
│ │ ├── CouchDBHandler.php
│ │ ├── CubeHandler.php
│ │ ├── Curl
│ │ │ └── Util.php
│ │ ├── DeduplicationHandler.php
│ │ ├── DoctrineCouchDBHandler.php
│ │ ├── DynamoDbHandler.php
│ │ ├── ElasticSearchHandler.php
│ │ ├── ErrorLogHandler.php
│ │ ├── FilterHandler.php
│ │ ├── FingersCrossed
│ │ │ ├── ActivationStrategyInterface.php
│ │ │ ├── ChannelLevelActivationStrategy.php
│ │ │ └── ErrorLevelActivationStrategy.php
│ │ ├── FingersCrossedHandler.php
│ │ ├── FirePHPHandler.php
│ │ ├── FleepHookHandler.php
│ │ ├── FlowdockHandler.php
│ │ ├── GelfHandler.php
│ │ ├── GroupHandler.php
│ │ ├── HandlerInterface.php
│ │ ├── HandlerWrapper.php
│ │ ├── HipChatHandler.php
│ │ ├── IFTTTHandler.php
│ │ ├── LogEntriesHandler.php
│ │ ├── LogglyHandler.php
│ │ ├── MailHandler.php
│ │ ├── MandrillHandler.php
│ │ ├── MissingExtensionException.php
│ │ ├── MongoDBHandler.php
│ │ ├── NativeMailerHandler.php
│ │ ├── NewRelicHandler.php
│ │ ├── NullHandler.php
│ │ ├── PHPConsoleHandler.php
│ │ ├── PsrHandler.php
│ │ ├── PushoverHandler.php
│ │ ├── RavenHandler.php
│ │ ├── RedisHandler.php
│ │ ├── RollbarHandler.php
│ │ ├── RotatingFileHandler.php
│ │ ├── SamplingHandler.php
│ │ ├── SlackHandler.php
│ │ ├── SocketHandler.php
│ │ ├── StreamHandler.php
│ │ ├── SwiftMailerHandler.php
│ │ ├── SyslogHandler.php
│ │ ├── SyslogUdp
│ │ │ └── UdpSocket.php
│ │ ├── SyslogUdpHandler.php
│ │ ├── TestHandler.php
│ │ ├── WhatFailureGroupHandler.php
│ │ └── ZendMonitorHandler.php
│ │ ├── Logger.php
│ │ ├── Processor
│ │ ├── GitProcessor.php
│ │ ├── IntrospectionProcessor.php
│ │ ├── MemoryPeakUsageProcessor.php
│ │ ├── MemoryProcessor.php
│ │ ├── MemoryUsageProcessor.php
│ │ ├── ProcessIdProcessor.php
│ │ ├── PsrLogMessageProcessor.php
│ │ ├── TagProcessor.php
│ │ ├── UidProcessor.php
│ │ └── WebProcessor.php
│ │ └── Registry.php
│ └── tests
│ └── Monolog
│ ├── ErrorHandlerTest.php
│ ├── Formatter
│ ├── ChromePHPFormatterTest.php
│ ├── ElasticaFormatterTest.php
│ ├── FlowdockFormatterTest.php
│ ├── FluentdFormatterTest.php
│ ├── GelfMessageFormatterTest.php
│ ├── JsonFormatterTest.php
│ ├── LineFormatterTest.php
│ ├── LogglyFormatterTest.php
│ ├── LogstashFormatterTest.php
│ ├── MongoDBFormatterTest.php
│ ├── NormalizerFormatterTest.php
│ ├── ScalarFormatterTest.php
│ └── WildfireFormatterTest.php
│ ├── Handler
│ ├── AbstractHandlerTest.php
│ ├── AbstractProcessingHandlerTest.php
│ ├── AmqpHandlerTest.php
│ ├── BrowserConsoleHandlerTest.php
│ ├── BufferHandlerTest.php
│ ├── ChromePHPHandlerTest.php
│ ├── CouchDBHandlerTest.php
│ ├── DeduplicationHandlerTest.php
│ ├── DoctrineCouchDBHandlerTest.php
│ ├── DynamoDbHandlerTest.php
│ ├── ElasticSearchHandlerTest.php
│ ├── ErrorLogHandlerTest.php
│ ├── FilterHandlerTest.php
│ ├── FingersCrossedHandlerTest.php
│ ├── FirePHPHandlerTest.php
│ ├── Fixtures
│ │ └── .gitkeep
│ ├── FleepHookHandlerTest.php
│ ├── FlowdockHandlerTest.php
│ ├── GelfHandlerLegacyTest.php
│ ├── GelfHandlerTest.php
│ ├── GelfMockMessagePublisher.php
│ ├── GroupHandlerTest.php
│ ├── HandlerWrapperTest.php
│ ├── HipChatHandlerTest.php
│ ├── LogEntriesHandlerTest.php
│ ├── MailHandlerTest.php
│ ├── MockRavenClient.php
│ ├── MongoDBHandlerTest.php
│ ├── NativeMailerHandlerTest.php
│ ├── NewRelicHandlerTest.php
│ ├── NullHandlerTest.php
│ ├── PHPConsoleHandlerTest.php
│ ├── PsrHandlerTest.php
│ ├── PushoverHandlerTest.php
│ ├── RavenHandlerTest.php
│ ├── RedisHandlerTest.php
│ ├── RotatingFileHandlerTest.php
│ ├── SamplingHandlerTest.php
│ ├── SlackHandlerTest.php
│ ├── SocketHandlerTest.php
│ ├── StreamHandlerTest.php
│ ├── SwiftMailerHandlerTest.php
│ ├── SyslogHandlerTest.php
│ ├── SyslogUdpHandlerTest.php
│ ├── TestHandlerTest.php
│ ├── UdpSocketTest.php
│ ├── WhatFailureGroupHandlerTest.php
│ └── ZendMonitorHandlerTest.php
│ ├── LoggerTest.php
│ ├── Processor
│ ├── GitProcessorTest.php
│ ├── IntrospectionProcessorTest.php
│ ├── MemoryPeakUsageProcessorTest.php
│ ├── MemoryUsageProcessorTest.php
│ ├── ProcessIdProcessorTest.php
│ ├── PsrLogMessageProcessorTest.php
│ ├── TagProcessorTest.php
│ ├── UidProcessorTest.php
│ └── WebProcessorTest.php
│ ├── PsrLogCompatTest.php
│ ├── RegistryTest.php
│ └── TestCase.php
└── psr
└── log
├── .gitignore
├── LICENSE
├── Psr
└── Log
│ ├── AbstractLogger.php
│ ├── InvalidArgumentException.php
│ ├── LogLevel.php
│ ├── LoggerAwareInterface.php
│ ├── LoggerAwareTrait.php
│ ├── LoggerInterface.php
│ ├── LoggerTrait.php
│ ├── NullLogger.php
│ └── Test
│ └── LoggerInterfaceTest.php
├── README.md
└── composer.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | .DS_Store
3 | ._*
4 | .Spotlight-V100
5 | .Trashes
6 |
7 | # Windows
8 | Thumbs.db
9 | Desktop.ini
10 |
11 | # PHPStorm
12 | .idea/
13 |
14 | # Sublime Text
15 | *.sublime*
16 |
17 | # Eclipse
18 | .buildpath
19 | .project
20 | .settings
21 |
22 | # Temp files
23 | *.tmp
24 | *.bak
25 | *.swp
26 | *~.nib
27 | *~
28 |
29 | # Never ignore
30 | !.gitignore
31 | !index.html
32 | !index.php
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name" : "phproberto/lib_sample",
3 | "description": "Sample library for Joomla",
4 | "license" : "GPL-2.0+",
5 | "require" : {
6 | "php": ">=5.3.10",
7 | "monolog/monolog": "^1.19"
8 | },
9 | "autoload": {
10 | "psr-4": {
11 | "Phproberto\\Sample\\": "src/"
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/form/field/list.php:
--------------------------------------------------------------------------------
1 | 'LIB_SAMPLE_FIELD_SAMPLE_OPTION1',
42 | 2 => 'LIB_SAMPLE_FIELD_SAMPLE_OPTION2'
43 | );
44 |
45 | /**
46 | * Translate options labels ?
47 | *
48 | * @var boolean
49 | */
50 | protected $translate = true;
51 |
52 | /**
53 | * Method to get the options to populate list
54 | *
55 | * @return array The field option objects.
56 | */
57 | protected function getOptions()
58 | {
59 | // Hash for caching
60 | $hash = md5($this->element);
61 | $type = strtolower($this->type);
62 |
63 | if (!isset(static::$options[$type][$hash]) && !empty($this->predefinedOptions))
64 | {
65 | static::$options[$type][$hash] = parent::getOptions();
66 |
67 | $options = array();
68 |
69 | // Allow to only use specific values of the predefined list
70 | $filter = isset($this->element['filter']) ? explode(',', $this->element['filter']) : array();
71 |
72 | foreach ($this->predefinedOptions as $value => $text)
73 | {
74 | if (empty($filter) || in_array($value, $filter))
75 | {
76 | $text = $this->translate ? JText::_($text) : $text;
77 |
78 | $options[] = (object) array(
79 | 'value' => $value,
80 | 'text' => $text
81 | );
82 | }
83 | }
84 |
85 | static::$options[$type][$hash] = array_merge(static::$options[$type][$hash], $options);
86 | }
87 |
88 | return static::$options[$type][$hash];
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/form/rule/login.php:
--------------------------------------------------------------------------------
1 | tag for the form field object.
25 | * @param mixed $value The form field value to validate.
26 | * @param string $group The field name group control value. This acts as as an array container for the field.
27 | * For example if the field has name="foo" and the group value is set to "bar" then the
28 | * full field name would end up being "bar[foo]".
29 | * @param JRegistry $input An optional JRegistry object with the entire data set to validate against the entire form.
30 | * @param JForm $form The form object for which the field is being tested.
31 | *
32 | * @return boolean True if the value is valid, false otherwise.
33 | *
34 | * @since 11.1
35 | */
36 | public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null)
37 | {
38 | // Get the database object and a new query object.
39 | $db = JFactory::getDbo();
40 | $query = $db->getQuery(true);
41 |
42 | // Build the query.
43 | $query->select('COUNT(*)')
44 | ->from('#__users')
45 | ->where('username = ' . $db->quote($value));
46 |
47 | // Get the extra field check attribute.
48 | $userId = ($form instanceof JForm) ? $form->getValue('id') : '';
49 | $query->where($db->quoteName('id') . ' <> ' . (int) $userId);
50 |
51 | // Set and query the database.
52 | $db->setQuery($query);
53 | $duplicate = (bool) $db->loadResult();
54 |
55 | if ($duplicate)
56 | {
57 | return false;
58 | }
59 |
60 | return true;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/helper/asset.php:
--------------------------------------------------------------------------------
1 | load('lib_sample', JPATH_SITE);
37 |
--------------------------------------------------------------------------------
/media/sample/css/sample.css:
--------------------------------------------------------------------------------
1 | div.sample {
2 | background-color: #f00;
3 | color: #fff;
4 | padding: 20px;
5 | font-size: 150%;
6 |
7 | }
--------------------------------------------------------------------------------
/media/sample/js/sample.js:
--------------------------------------------------------------------------------
1 | var dummyVar = 'sample var'
--------------------------------------------------------------------------------
/sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Sample - Library
4 | sample
5 | @phproberto
6 | roberto@phproberto.com
7 | www.phproberto.com
8 | Copyright (C) 2013 Roberto Segura. All rights reserved.
9 | December 2013
10 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
11 | 1.0.0
12 | Sample 3rd part library for Joomla!
13 |
14 | form
15 | helper
16 | html
17 | language
18 | src
19 | vendor
20 | LICENSE
21 | README.md
22 | library.php
23 |
24 |
25 |
26 |
27 | css
28 | js
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/App.php:
--------------------------------------------------------------------------------
1 | get('log_path');
43 |
44 | if (!is_writable($logDir))
45 | {
46 | throw new \RuntimeException("Cannot write to log folder. Check configuration");
47 | }
48 |
49 | $log = new Logger('sample');
50 | $log->pushHandler(new PhpfileHandler($logDir . '/sample.error.php', Logger::ERROR));
51 |
52 | static::$log = $log;
53 | }
54 |
55 | return static::$log;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/Helper/Dummy.php:
--------------------------------------------------------------------------------
1 | ';
31 | var_dump($bar);
32 | echo '';
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Monolog/PhpfileHandler.php:
--------------------------------------------------------------------------------
1 | isNewFile)
33 | {
34 | $extension = pathinfo($this->url, PATHINFO_EXTENSION);
35 |
36 | if ($extension === 'php')
37 | {
38 | file_put_contents($this->url, "#\n#\n" . file_get_contents($this->url));
39 | }
40 | }
41 | }
42 |
43 | /**
44 | * Write to the file
45 | *
46 | * @param array $record Record to write
47 | *
48 | * @return void
49 | */
50 | protected function write(array $record)
51 | {
52 | $this->isNewFile = !is_resource($this->stream) && !file_exists($this->url);
53 |
54 | parent::write($record);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/vendor/autoload.php:
--------------------------------------------------------------------------------
1 | array($vendorDir . '/psr/log'),
10 | );
11 |
--------------------------------------------------------------------------------
/vendor/composer/autoload_psr4.php:
--------------------------------------------------------------------------------
1 | array($baseDir . '/src'),
10 | 'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
11 | );
12 |
--------------------------------------------------------------------------------
/vendor/composer/autoload_real.php:
--------------------------------------------------------------------------------
1 | = 50600 && !defined('HHVM_VERSION');
27 | if ($useStaticLoader) {
28 | require_once __DIR__ . '/autoload_static.php';
29 |
30 | call_user_func(\Composer\Autoload\ComposerStaticInit1d1d5b7b0566f280230a085af2585375::getInitializer($loader));
31 | } else {
32 | $map = require __DIR__ . '/autoload_namespaces.php';
33 | foreach ($map as $namespace => $path) {
34 | $loader->set($namespace, $path);
35 | }
36 |
37 | $map = require __DIR__ . '/autoload_psr4.php';
38 | foreach ($map as $namespace => $path) {
39 | $loader->setPsr4($namespace, $path);
40 | }
41 |
42 | $classMap = require __DIR__ . '/autoload_classmap.php';
43 | if ($classMap) {
44 | $loader->addClassMap($classMap);
45 | }
46 | }
47 |
48 | $loader->register(true);
49 |
50 | return $loader;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/vendor/composer/autoload_static.php:
--------------------------------------------------------------------------------
1 |
11 | array (
12 | 'Phproberto\\Sample\\' => 18,
13 | ),
14 | 'M' =>
15 | array (
16 | 'Monolog\\' => 8,
17 | ),
18 | );
19 |
20 | public static $prefixDirsPsr4 = array (
21 | 'Phproberto\\Sample\\' =>
22 | array (
23 | 0 => __DIR__ . '/../..' . '/src',
24 | ),
25 | 'Monolog\\' =>
26 | array (
27 | 0 => __DIR__ . '/..' . '/monolog/monolog/src/Monolog',
28 | ),
29 | );
30 |
31 | public static $prefixesPsr0 = array (
32 | 'P' =>
33 | array (
34 | 'Psr\\Log\\' =>
35 | array (
36 | 0 => __DIR__ . '/..' . '/psr/log',
37 | ),
38 | ),
39 | );
40 |
41 | public static function getInitializer(ClassLoader $loader)
42 | {
43 | return \Closure::bind(function () use ($loader) {
44 | $loader->prefixLengthsPsr4 = ComposerStaticInit1d1d5b7b0566f280230a085af2585375::$prefixLengthsPsr4;
45 | $loader->prefixDirsPsr4 = ComposerStaticInit1d1d5b7b0566f280230a085af2585375::$prefixDirsPsr4;
46 | $loader->prefixesPsr0 = ComposerStaticInit1d1d5b7b0566f280230a085af2585375::$prefixesPsr0;
47 |
48 | }, null, ClassLoader::class);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/.php_cs:
--------------------------------------------------------------------------------
1 |
7 |
8 | For the full copyright and license information, please view the LICENSE
9 | file that was distributed with this source code.
10 | EOF;
11 |
12 | $finder = Symfony\CS\Finder::create()
13 | ->files()
14 | ->name('*.php')
15 | ->exclude('Fixtures')
16 | ->in(__DIR__.'/src')
17 | ->in(__DIR__.'/tests')
18 | ;
19 |
20 | return Symfony\CS\Config::create()
21 | ->setUsingCache(true)
22 | //->setUsingLinter(false)
23 | ->setRiskyAllowed(true)
24 | ->setRules(array(
25 | '@PSR2' => true,
26 | 'binary_operator_spaces' => true,
27 | 'blank_line_before_return' => true,
28 | 'header_comment' => array('header' => $header),
29 | 'include' => true,
30 | 'long_array_syntax' => true,
31 | 'method_separation' => true,
32 | 'no_blank_lines_after_class_opening' => true,
33 | 'no_blank_lines_after_phpdoc' => true,
34 | 'no_blank_lines_between_uses' => true,
35 | 'no_duplicate_semicolons' => true,
36 | 'no_extra_consecutive_blank_lines' => true,
37 | 'no_leading_import_slash' => true,
38 | 'no_leading_namespace_whitespace' => true,
39 | 'no_trailing_comma_in_singleline_array' => true,
40 | 'no_unused_imports' => true,
41 | 'object_operator_without_whitespace' => true,
42 | 'phpdoc_align' => true,
43 | 'phpdoc_indent' => true,
44 | 'phpdoc_no_access' => true,
45 | 'phpdoc_no_package' => true,
46 | 'phpdoc_order' => true,
47 | 'phpdoc_scalar' => true,
48 | 'phpdoc_trim' => true,
49 | 'phpdoc_type_to_var' => true,
50 | 'psr0' => true,
51 | 'single_blank_line_before_namespace' => true,
52 | 'spaces_cast' => true,
53 | 'standardize_not_equals' => true,
54 | 'ternary_operator_spaces' => true,
55 | 'trailing_comma_in_multiline_array' => true,
56 | 'whitespacy_lines' => true,
57 | ))
58 | ->finder($finder)
59 | ;
60 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/LICENSE:
--------------------------------------------------------------------------------
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.
20 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "monolog/monolog",
3 | "description": "Sends your logs to files, sockets, inboxes, databases and various web services",
4 | "keywords": ["log", "logging", "psr-3"],
5 | "homepage": "http://github.com/Seldaek/monolog",
6 | "type": "library",
7 | "license": "MIT",
8 | "authors": [
9 | {
10 | "name": "Jordi Boggiano",
11 | "email": "j.boggiano@seld.be",
12 | "homepage": "http://seld.be"
13 | }
14 | ],
15 | "require": {
16 | "php": ">=5.3.0",
17 | "psr/log": "~1.0"
18 | },
19 | "require-dev": {
20 | "phpunit/phpunit": "~4.5",
21 | "graylog2/gelf-php": "~1.0",
22 | "raven/raven": "^0.13",
23 | "ruflin/elastica": ">=0.90 <3.0",
24 | "doctrine/couchdb": "~1.0@dev",
25 | "aws/aws-sdk-php": "^2.4.9",
26 | "php-amqplib/php-amqplib": "~2.4",
27 | "swiftmailer/swiftmailer": "~5.3",
28 | "php-console/php-console": "^3.1.3",
29 | "phpunit/phpunit-mock-objects": "2.3.0",
30 | "jakub-onderka/php-parallel-lint": "0.9"
31 | },
32 | "_": "phpunit/phpunit-mock-objects required in 2.3.0 due to https://github.com/sebastianbergmann/phpunit-mock-objects/issues/223 - needs hhvm 3.8+ on travis",
33 | "suggest": {
34 | "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
35 | "raven/raven": "Allow sending log messages to a Sentry server",
36 | "doctrine/couchdb": "Allow sending log messages to a CouchDB server",
37 | "ruflin/elastica": "Allow sending log messages to an Elastic Search server",
38 | "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
39 | "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
40 | "ext-mongo": "Allow sending log messages to a MongoDB server",
41 | "mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
42 | "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
43 | "rollbar/rollbar": "Allow sending log messages to Rollbar",
44 | "php-console/php-console": "Allow sending log messages to Google Chrome"
45 | },
46 | "autoload": {
47 | "psr-4": {"Monolog\\": "src/Monolog"}
48 | },
49 | "autoload-dev": {
50 | "psr-4": {"Monolog\\": "tests/Monolog"}
51 | },
52 | "provide": {
53 | "psr/log-implementation": "1.0.0"
54 | },
55 | "extra": {
56 | "branch-alias": {
57 | "dev-master": "2.0.x-dev"
58 | }
59 | },
60 | "scripts": {
61 | "test": [
62 | "parallel-lint . --exclude vendor",
63 | "phpunit"
64 | ]
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/doc/03-utilities.md:
--------------------------------------------------------------------------------
1 | # Utilities
2 |
3 | - _Registry_: The `Monolog\Registry` class lets you configure global loggers that you
4 | can then statically access from anywhere. It is not really a best practice but can
5 | help in some older codebases or for ease of use.
6 | - _ErrorHandler_: The `Monolog\ErrorHandler` class allows you to easily register
7 | a Logger instance as an exception handler, error handler or fatal error handler.
8 | - _ErrorLevelActivationStrategy_: Activates a FingersCrossedHandler when a certain log
9 | level is reached.
10 | - _ChannelLevelActivationStrategy_: Activates a FingersCrossedHandler when a certain
11 | log level is reached, depending on which channel received the log record.
12 |
13 | ← [Handlers, Formatters and Processors](02-handlers-formatters-processors.md) | [Extending Monolog](04-extending.md) →
14 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/doc/04-extending.md:
--------------------------------------------------------------------------------
1 | # Extending Monolog
2 |
3 | Monolog is fully extensible, allowing you to adapt your logger to your needs.
4 |
5 | ## Writing your own handler
6 |
7 | Monolog provides many built-in handlers. But if the one you need does not
8 | exist, you can write it and use it in your logger. The only requirement is
9 | to implement `Monolog\Handler\HandlerInterface`.
10 |
11 | Let's write a PDOHandler to log records to a database. We will extend the
12 | abstract class provided by Monolog to keep things DRY.
13 |
14 | ```php
15 | pdo = $pdo;
29 | parent::__construct($level, $bubble);
30 | }
31 |
32 | protected function write(array $record)
33 | {
34 | if (!$this->initialized) {
35 | $this->initialize();
36 | }
37 |
38 | $this->statement->execute(array(
39 | 'channel' => $record['channel'],
40 | 'level' => $record['level'],
41 | 'message' => $record['formatted'],
42 | 'time' => $record['datetime']->format('U'),
43 | ));
44 | }
45 |
46 | private function initialize()
47 | {
48 | $this->pdo->exec(
49 | 'CREATE TABLE IF NOT EXISTS monolog '
50 | .'(channel VARCHAR(255), level INTEGER, message LONGTEXT, time INTEGER UNSIGNED)'
51 | );
52 | $this->statement = $this->pdo->prepare(
53 | 'INSERT INTO monolog (channel, level, message, time) VALUES (:channel, :level, :message, :time)'
54 | );
55 |
56 | $this->initialized = true;
57 | }
58 | }
59 | ```
60 |
61 | You can now use this handler in your logger:
62 |
63 | ```php
64 | pushHandler(new PDOHandler(new PDO('sqlite:logs.sqlite')));
67 |
68 | // You can now use your logger
69 | $logger->addInfo('My logger is now ready');
70 | ```
71 |
72 | The `Monolog\Handler\AbstractProcessingHandler` class provides most of the
73 | logic needed for the handler, including the use of processors and the formatting
74 | of the record (which is why we use ``$record['formatted']`` instead of ``$record['message']``).
75 |
76 | ← [Utility classes](03-utilities.md)
77 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/doc/sockets.md:
--------------------------------------------------------------------------------
1 | Sockets Handler
2 | ===============
3 |
4 | This handler allows you to write your logs to sockets using [fsockopen](http://php.net/fsockopen)
5 | or [pfsockopen](http://php.net/pfsockopen).
6 |
7 | Persistent sockets are mainly useful in web environments where you gain some performance not closing/opening
8 | the connections between requests.
9 |
10 | You can use a `unix://` prefix to access unix sockets and `udp://` to open UDP sockets instead of the default TCP.
11 |
12 | Basic Example
13 | -------------
14 |
15 | ```php
16 | setPersistent(true);
27 |
28 | // Now add the handler
29 | $logger->pushHandler($handler, Logger::DEBUG);
30 |
31 | // You can now use your logger
32 | $logger->addInfo('My logger is now ready');
33 |
34 | ```
35 |
36 | In this example, using syslog-ng, you should see the log on the log server:
37 |
38 | cweb1 [2012-02-26 00:12:03] my_logger.INFO: My logger is now ready [] []
39 |
40 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | tests/Monolog/
7 |
8 |
9 |
10 |
11 |
12 | src/Monolog/
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php:
--------------------------------------------------------------------------------
1 |
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
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 | }
79 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php:
--------------------------------------------------------------------------------
1 |
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
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 | }
90 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Formatter/FlowdockFormatter.php:
--------------------------------------------------------------------------------
1 |
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
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 | }
117 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php:
--------------------------------------------------------------------------------
1 |
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 | *
22 | * type unix
23 | * path /var/run/td-agent/td-agent.sock
24 | *
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
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 | 'extra' => $record['extra'],
66 | );
67 |
68 | if (!$this->levelTag) {
69 | $message['level'] = $record['level'];
70 | $message['level_name'] = $record['level_name'];
71 | }
72 |
73 | return json_encode(array($tag, $record['datetime']->getTimestamp(), $message));
74 | }
75 |
76 | public function formatBatch(array $records)
77 | {
78 | $message = '';
79 | foreach ($records as $record) {
80 | $message .= $this->format($record);
81 | }
82 |
83 | return $message;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Formatter/FormatterInterface.php:
--------------------------------------------------------------------------------
1 |
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
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 | }
37 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php:
--------------------------------------------------------------------------------
1 |
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
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 | }
48 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php:
--------------------------------------------------------------------------------
1 |
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
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 | }
49 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php:
--------------------------------------------------------------------------------
1 |
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 Handler class providing the Handler structure
16 | *
17 | * Classes extending it should (in most cases) only implement write($record)
18 | *
19 | * @author Jordi Boggiano
20 | * @author Christophe Coevoet
21 | */
22 | abstract class AbstractProcessingHandler extends AbstractHandler
23 | {
24 | /**
25 | * {@inheritdoc}
26 | */
27 | public function handle(array $record)
28 | {
29 | if (!$this->isHandling($record)) {
30 | return false;
31 | }
32 |
33 | $record = $this->processRecord($record);
34 |
35 | $record['formatted'] = $this->getFormatter()->format($record);
36 |
37 | $this->write($record);
38 |
39 | return false === $this->bubble;
40 | }
41 |
42 | /**
43 | * Writes the record down to the log of the implementing handler
44 | *
45 | * @param array $record
46 | * @return void
47 | */
48 | abstract protected function write(array $record);
49 |
50 | /**
51 | * Processes a record.
52 | *
53 | * @param array $record
54 | * @return array
55 | */
56 | protected function processRecord(array $record)
57 | {
58 | if ($this->processors) {
59 | foreach ($this->processors as $processor) {
60 | $record = call_user_func($processor, $record);
61 | }
62 | }
63 |
64 | return $record;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php:
--------------------------------------------------------------------------------
1 |
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
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 | }
73 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/Curl/Util.php:
--------------------------------------------------------------------------------
1 |
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 | }
58 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php:
--------------------------------------------------------------------------------
1 |
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
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 | }
46 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php:
--------------------------------------------------------------------------------
1 |
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\Common\Aws;
15 | use Aws\DynamoDb\DynamoDbClient;
16 | use Monolog\Formatter\ScalarFormatter;
17 | use Monolog\Logger;
18 |
19 | /**
20 | * Amazon DynamoDB handler (http://aws.amazon.com/dynamodb/)
21 | *
22 | * @link https://github.com/aws/aws-sdk-php/
23 | * @author Andrew Lawson
24 | */
25 | class DynamoDbHandler extends AbstractProcessingHandler
26 | {
27 | const DATE_FORMAT = 'Y-m-d\TH:i:s.uO';
28 |
29 | /**
30 | * @var DynamoDbClient
31 | */
32 | protected $client;
33 |
34 | /**
35 | * @var string
36 | */
37 | protected $table;
38 |
39 | /**
40 | * @param DynamoDbClient $client
41 | * @param string $table
42 | * @param int $level
43 | * @param bool $bubble
44 | */
45 | public function __construct(DynamoDbClient $client, $table, $level = Logger::DEBUG, $bubble = true)
46 | {
47 | if (!defined('Aws\Common\Aws::VERSION') || version_compare('3.0', Aws::VERSION, '<=')) {
48 | throw new \RuntimeException('The DynamoDbHandler is only known to work with the AWS SDK 2.x releases');
49 | }
50 |
51 | $this->client = $client;
52 | $this->table = $table;
53 |
54 | parent::__construct($level, $bubble);
55 | }
56 |
57 | /**
58 | * {@inheritdoc}
59 | */
60 | protected function write(array $record)
61 | {
62 | $filtered = $this->filterEmptyFields($record['formatted']);
63 | $formatted = $this->client->formatAttributes($filtered);
64 |
65 | $this->client->putItem(array(
66 | 'TableName' => $this->table,
67 | 'Item' => $formatted,
68 | ));
69 | }
70 |
71 | /**
72 | * @param array $record
73 | * @return array
74 | */
75 | protected function filterEmptyFields(array $record)
76 | {
77 | return array_filter($record, function ($value) {
78 | return !empty($value) || false === $value || 0 === $value;
79 | });
80 | }
81 |
82 | /**
83 | * {@inheritdoc}
84 | */
85 | protected function getDefaultFormatter()
86 | {
87 | return new ScalarFormatter(self::DATE_FORMAT);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php:
--------------------------------------------------------------------------------
1 |
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
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 Boolean $bubble Whether the messages that are handled can bubble up the stack or not
34 | * @param Boolean $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 | }
83 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php:
--------------------------------------------------------------------------------
1 |
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
18 | */
19 | interface ActivationStrategyInterface
20 | {
21 | /**
22 | * Returns whether the given record activates the handler.
23 | *
24 | * @param array $record
25 | * @return Boolean
26 | */
27 | public function isHandlerActivated(array $record);
28 | }
29 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php:
--------------------------------------------------------------------------------
1 |
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 | *
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 | *
33 | *
34 | * @author Mike Meessen
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 | }
60 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php:
--------------------------------------------------------------------------------
1 |
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
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 | }
35 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php:
--------------------------------------------------------------------------------
1 |
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
25 | * @author Benjamin Zikarsky
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 | public function close()
54 | {
55 | $this->publisher = null;
56 | }
57 |
58 | /**
59 | * {@inheritdoc}
60 | */
61 | protected function write(array $record)
62 | {
63 | $this->publisher->publish($record['formatted']);
64 | }
65 |
66 | /**
67 | * {@inheritDoc}
68 | */
69 | protected function getDefaultFormatter()
70 | {
71 | return new GelfMessageFormatter();
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php:
--------------------------------------------------------------------------------
1 |
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 | * Forwards records to multiple handlers
18 | *
19 | * @author Lenar Lõhmus
20 | */
21 | class GroupHandler extends AbstractHandler
22 | {
23 | protected $handlers;
24 |
25 | /**
26 | * @param array $handlers Array of Handlers.
27 | * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
28 | */
29 | public function __construct(array $handlers, $bubble = true)
30 | {
31 | foreach ($handlers as $handler) {
32 | if (!$handler instanceof HandlerInterface) {
33 | throw new \InvalidArgumentException('The first argument of the GroupHandler must be an array of HandlerInterface instances.');
34 | }
35 | }
36 |
37 | $this->handlers = $handlers;
38 | $this->bubble = $bubble;
39 | }
40 |
41 | /**
42 | * {@inheritdoc}
43 | */
44 | public function isHandling(array $record)
45 | {
46 | foreach ($this->handlers as $handler) {
47 | if ($handler->isHandling($record)) {
48 | return true;
49 | }
50 | }
51 |
52 | return false;
53 | }
54 |
55 | /**
56 | * {@inheritdoc}
57 | */
58 | public function handle(array $record)
59 | {
60 | if ($this->processors) {
61 | foreach ($this->processors as $processor) {
62 | $record = call_user_func($processor, $record);
63 | }
64 | }
65 |
66 | foreach ($this->handlers as $handler) {
67 | $handler->handle($record);
68 | }
69 |
70 | return false === $this->bubble;
71 | }
72 |
73 | /**
74 | * {@inheritdoc}
75 | */
76 | public function handleBatch(array $records)
77 | {
78 | foreach ($this->handlers as $handler) {
79 | $handler->handleBatch($records);
80 | }
81 | }
82 |
83 | /**
84 | * {@inheritdoc}
85 | */
86 | public function setFormatter(FormatterInterface $formatter)
87 | {
88 | foreach ($this->handlers as $handler) {
89 | $handler->setFormatter($formatter);
90 | }
91 |
92 | return $this;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php:
--------------------------------------------------------------------------------
1 |
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
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 Boolean
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 Boolean 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 | }
91 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php:
--------------------------------------------------------------------------------
1 |
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 | * This simple wrapper class can be used to extend handlers functionality.
18 | *
19 | * Example: A filtering handle. Inherit from this class, override isHandling() like this
20 | *
21 | * public function isHandling(array $record)
22 | * {
23 | * if ($record meets certain conditions) {
24 | * return false;
25 | * }
26 | * return $this->handler->isHandling($record);
27 | * }
28 | *
29 | * @author Alexey Karapetov
30 | */
31 | class HandlerWrapper implements HandlerInterface
32 | {
33 | /**
34 | * @var HandlerInterface
35 | */
36 | private $handler;
37 |
38 | /**
39 | * HandlerWrapper constructor.
40 | * @param HandlerInterface $handler
41 | */
42 | public function __construct(HandlerInterface $handler)
43 | {
44 | $this->handler = $handler;
45 | }
46 |
47 | /**
48 | * {@inheritdoc}
49 | */
50 | public function isHandling(array $record)
51 | {
52 | return $this->handler->isHandling($record);
53 | }
54 |
55 | /**
56 | * {@inheritdoc}
57 | */
58 | public function handle(array $record)
59 | {
60 | return $this->handler->handle($record);
61 | }
62 |
63 | /**
64 | * {@inheritdoc}
65 | */
66 | public function handleBatch(array $records)
67 | {
68 | return $this->handler->handleBatch($records);
69 | }
70 |
71 | /**
72 | * {@inheritdoc}
73 | */
74 | public function pushProcessor($callback)
75 | {
76 | $this->handler->pushProcessor($callback);
77 |
78 | return $this;
79 | }
80 |
81 | /**
82 | * {@inheritdoc}
83 | */
84 | public function popProcessor()
85 | {
86 | return $this->handler->popProcessor();
87 | }
88 |
89 | /**
90 | * {@inheritdoc}
91 | */
92 | public function setFormatter(FormatterInterface $formatter)
93 | {
94 | $this->handler->setFormatter($formatter);
95 |
96 | return $this;
97 | }
98 |
99 | /**
100 | * {@inheritdoc}
101 | */
102 | public function getFormatter()
103 | {
104 | return $this->handler->getFormatter();
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php:
--------------------------------------------------------------------------------
1 |
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
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 Boolean $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 | }
70 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php:
--------------------------------------------------------------------------------
1 |
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
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)
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://data.logentries.com:443' : 'data.logentries.com: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 | }
56 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php:
--------------------------------------------------------------------------------
1 |
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
21 | * @author Adam Pancutt
22 | * @author Gregory Barchard
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 | }
103 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php:
--------------------------------------------------------------------------------
1 |
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 | }
68 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php:
--------------------------------------------------------------------------------
1 |
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
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 Boolean $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 | }
69 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/MissingExtensionException.php:
--------------------------------------------------------------------------------
1 |
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
18 | */
19 | class MissingExtensionException extends \Exception
20 | {
21 | }
22 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php:
--------------------------------------------------------------------------------
1 |
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
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 | }
60 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php:
--------------------------------------------------------------------------------
1 |
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
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 | }
46 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php:
--------------------------------------------------------------------------------
1 |
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
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 Boolean $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 | }
57 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php:
--------------------------------------------------------------------------------
1 |
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
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 | }
98 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php:
--------------------------------------------------------------------------------
1 |
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 | * @author Paul Statezny
25 | */
26 | class RollbarHandler extends AbstractProcessingHandler
27 | {
28 | /**
29 | * Rollbar notifier
30 | *
31 | * @var RollbarNotifier
32 | */
33 | protected $rollbarNotifier;
34 |
35 | /**
36 | * Records whether any log records have been added since the last flush of the rollbar notifier
37 | *
38 | * @var bool
39 | */
40 | private $hasRecords = false;
41 |
42 | /**
43 | * @param RollbarNotifier $rollbarNotifier RollbarNotifier object constructed with valid token
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 | */
47 | public function __construct(RollbarNotifier $rollbarNotifier, $level = Logger::ERROR, $bubble = true)
48 | {
49 | $this->rollbarNotifier = $rollbarNotifier;
50 |
51 | parent::__construct($level, $bubble);
52 | }
53 |
54 | /**
55 | * {@inheritdoc}
56 | */
57 | protected function write(array $record)
58 | {
59 | if (isset($record['context']['exception']) && $record['context']['exception'] instanceof Exception) {
60 | $context = $record['context'];
61 | $exception = $context['exception'];
62 | unset($context['exception']);
63 |
64 | $payload = array();
65 | if (isset($context['payload'])) {
66 | $payload = $context['payload'];
67 | unset($context['payload']);
68 | }
69 |
70 | $this->rollbarNotifier->report_exception($exception, $context, $payload);
71 | } else {
72 | $extraData = array(
73 | 'level' => $record['level'],
74 | 'channel' => $record['channel'],
75 | 'datetime' => $record['datetime']->format('U'),
76 | );
77 |
78 | $context = $record['context'];
79 | $payload = array();
80 | if (isset($context['payload'])) {
81 | $payload = $context['payload'];
82 | unset($context['payload']);
83 | }
84 |
85 | $this->rollbarNotifier->report_message(
86 | $record['message'],
87 | $record['level_name'],
88 | array_merge($record['context'], $record['extra'], $extraData),
89 | $payload
90 | );
91 | }
92 |
93 | $this->hasRecords = true;
94 | }
95 |
96 | /**
97 | * {@inheritdoc}
98 | */
99 | public function close()
100 | {
101 | if ($this->hasRecords) {
102 | $this->rollbarNotifier->flush();
103 | $this->hasRecords = false;
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/SamplingHandler.php:
--------------------------------------------------------------------------------
1 |
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
26 | * @author Kunal Mehta
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 | }
83 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php:
--------------------------------------------------------------------------------
1 |
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 | * SwiftMailerHandler uses Swift_Mailer to send the emails
19 | *
20 | * @author Gyula Sallai
21 | */
22 | class SwiftMailerHandler extends MailHandler
23 | {
24 | protected $mailer;
25 | private $messageTemplate;
26 |
27 | /**
28 | * @param \Swift_Mailer $mailer The mailer to use
29 | * @param callable|\Swift_Message $message An example message for real messages, only the body will be replaced
30 | * @param int $level The minimum logging level at which this handler will be triggered
31 | * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
32 | */
33 | public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, $bubble = true)
34 | {
35 | parent::__construct($level, $bubble);
36 |
37 | $this->mailer = $mailer;
38 | $this->messageTemplate = $message;
39 | }
40 |
41 | /**
42 | * {@inheritdoc}
43 | */
44 | protected function send($content, array $records)
45 | {
46 | $this->mailer->send($this->buildMessage($content, $records));
47 | }
48 |
49 | /**
50 | * Creates instance of Swift_Message to be sent
51 | *
52 | * @param string $content formatted email body to be sent
53 | * @param array $records Log records that formed the content
54 | * @return \Swift_Message
55 | */
56 | protected function buildMessage($content, array $records)
57 | {
58 | $message = null;
59 | if ($this->messageTemplate instanceof \Swift_Message) {
60 | $message = clone $this->messageTemplate;
61 | $message->generateId();
62 | } elseif (is_callable($this->messageTemplate)) {
63 | $message = call_user_func($this->messageTemplate, $content, $records);
64 | }
65 |
66 | if (!$message instanceof \Swift_Message) {
67 | throw new \InvalidArgumentException('Could not resolve message as instance of Swift_Message or a callable returning it');
68 | }
69 |
70 | if ($records) {
71 | $subjectFormatter = new LineFormatter($message->getSubject());
72 | $message->setSubject($subjectFormatter->format($this->getHighestRecord($records)));
73 | }
74 |
75 | $message->setBody($content);
76 | $message->setDate(time());
77 |
78 | return $message;
79 | }
80 |
81 | /**
82 | * BC getter, to be removed in 2.0
83 | */
84 | public function __get($name)
85 | {
86 | if ($name === 'message') {
87 | trigger_error('SwiftMailerHandler->message is deprecated, use ->buildMessage() instead to retrieve the message', E_USER_DEPRECATED);
88 |
89 | return $this->buildMessage(null, array());
90 | }
91 |
92 | throw new \InvalidArgumentException('Invalid property '.$name);
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php:
--------------------------------------------------------------------------------
1 |
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
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 Boolean $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 | }
68 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php:
--------------------------------------------------------------------------------
1 |
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 | }
57 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php:
--------------------------------------------------------------------------------
1 |
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
21 | */
22 | class SyslogUdpHandler extends AbstractSyslogHandler
23 | {
24 | protected $socket;
25 |
26 | /**
27 | * @param string $host
28 | * @param int $port
29 | * @param mixed $facility
30 | * @param int $level The minimum logging level at which this handler will be triggered
31 | * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
32 | */
33 | public function __construct($host, $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true)
34 | {
35 | parent::__construct($facility, $level, $bubble);
36 |
37 | $this->socket = new UdpSocket($host, $port ?: 514);
38 | }
39 |
40 | protected function write(array $record)
41 | {
42 | $lines = $this->splitMessageIntoLines($record['formatted']);
43 |
44 | $header = $this->makeCommonSyslogHeader($this->logLevels[$record['level']]);
45 |
46 | foreach ($lines as $line) {
47 | $this->socket->write($line, $header);
48 | }
49 | }
50 |
51 | public function close()
52 | {
53 | $this->socket->close();
54 | }
55 |
56 | private function splitMessageIntoLines($message)
57 | {
58 | if (is_array($message)) {
59 | $message = implode("\n", $message);
60 | }
61 |
62 | return preg_split('/$\R?^/m', $message);
63 | }
64 |
65 | /**
66 | * Make common syslog header (see rfc5424)
67 | */
68 | protected function makeCommonSyslogHeader($severity)
69 | {
70 | $priority = $severity + $this->facility;
71 |
72 | return "<$priority>1 ";
73 | }
74 |
75 | /**
76 | * Inject your own socket, mainly used for testing
77 | */
78 | public function setSocket($socket)
79 | {
80 | $this->socket = $socket;
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php:
--------------------------------------------------------------------------------
1 |
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
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 | }
39 | }
40 |
41 | return false === $this->bubble;
42 | }
43 |
44 | /**
45 | * {@inheritdoc}
46 | */
47 | public function handleBatch(array $records)
48 | {
49 | foreach ($this->handlers as $handler) {
50 | try {
51 | $handler->handleBatch($records);
52 | } catch (\Exception $e) {
53 | // What failure?
54 | }
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php:
--------------------------------------------------------------------------------
1 |
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
20 | */
21 | class ZendMonitorHandler extends AbstractProcessingHandler
22 | {
23 | /**
24 | * Monolog level / ZendMonitor Custom Event priority map
25 | *
26 | * @var array
27 | */
28 | protected $levelMap = array(
29 | Logger::DEBUG => 1,
30 | Logger::INFO => 2,
31 | Logger::NOTICE => 3,
32 | Logger::WARNING => 4,
33 | Logger::ERROR => 5,
34 | Logger::CRITICAL => 6,
35 | Logger::ALERT => 7,
36 | Logger::EMERGENCY => 0,
37 | );
38 |
39 | /**
40 | * Construct
41 | *
42 | * @param int $level
43 | * @param bool $bubble
44 | * @throws MissingExtensionException
45 | */
46 | public function __construct($level = Logger::DEBUG, $bubble = true)
47 | {
48 | if (!function_exists('zend_monitor_custom_event')) {
49 | throw new MissingExtensionException('You must have Zend Server installed in order to use this handler');
50 | }
51 | parent::__construct($level, $bubble);
52 | }
53 |
54 | /**
55 | * {@inheritdoc}
56 | */
57 | protected function write(array $record)
58 | {
59 | $this->writeZendMonitorCustomEvent(
60 | $this->levelMap[$record['level']],
61 | $record['message'],
62 | $record['formatted']
63 | );
64 | }
65 |
66 | /**
67 | * Write a record to Zend Monitor
68 | *
69 | * @param int $level
70 | * @param string $message
71 | * @param array $formatted
72 | */
73 | protected function writeZendMonitorCustomEvent($level, $message, $formatted)
74 | {
75 | zend_monitor_custom_event($level, $message, $formatted);
76 | }
77 |
78 | /**
79 | * {@inheritdoc}
80 | */
81 | public function getDefaultFormatter()
82 | {
83 | return new NormalizerFormatter();
84 | }
85 |
86 | /**
87 | * Get the level map
88 | *
89 | * @return array
90 | */
91 | public function getLevelMap()
92 | {
93 | return $this->levelMap;
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php:
--------------------------------------------------------------------------------
1 |
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
21 | */
22 | class GitProcessor
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 | }
65 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php:
--------------------------------------------------------------------------------
1 |
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 | }
36 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php:
--------------------------------------------------------------------------------
1 |
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
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 = (boolean) $realUsage;
38 | $this->useFormatting = (boolean) $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 | }
64 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php:
--------------------------------------------------------------------------------
1 |
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 | }
36 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php:
--------------------------------------------------------------------------------
1 |
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
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 | }
32 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php:
--------------------------------------------------------------------------------
1 |
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 | * Processes a record's message according to PSR-3 rules
16 | *
17 | * It replaces {foo} with the value from $context['foo']
18 | *
19 | * @author Jordi Boggiano
20 | */
21 | class PsrLogMessageProcessor
22 | {
23 | /**
24 | * @param array $record
25 | * @return array
26 | */
27 | public function __invoke(array $record)
28 | {
29 | if (false === strpos($record['message'], '{')) {
30 | return $record;
31 | }
32 |
33 | $replacements = array();
34 | foreach ($record['context'] as $key => $val) {
35 | if (is_null($val) || is_scalar($val) || (is_object($val) && method_exists($val, "__toString"))) {
36 | $replacements['{'.$key.'}'] = $val;
37 | } elseif (is_object($val)) {
38 | $replacements['{'.$key.'}'] = '[object '.get_class($val).']';
39 | } else {
40 | $replacements['{'.$key.'}'] = '['.gettype($val).']';
41 | }
42 | }
43 |
44 | $record['message'] = strtr($record['message'], $replacements);
45 |
46 | return $record;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php:
--------------------------------------------------------------------------------
1 |
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
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 | }
45 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php:
--------------------------------------------------------------------------------
1 |
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 unique identifier into records
16 | *
17 | * @author Simon Mönch
18 | */
19 | class UidProcessor
20 | {
21 | private $uid;
22 |
23 | public function __construct($length = 7)
24 | {
25 | if (!is_int($length) || $length > 32 || $length < 1) {
26 | throw new \InvalidArgumentException('The uid length must be an integer between 1 and 32');
27 | }
28 |
29 | $this->uid = substr(hash('md5', uniqid('', true)), 0, $length);
30 | }
31 |
32 | public function __invoke(array $record)
33 | {
34 | $record['extra']['uid'] = $this->uid;
35 |
36 | return $record;
37 | }
38 |
39 | /**
40 | * @return string
41 | */
42 | public function getUid()
43 | {
44 | return $this->uid;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php:
--------------------------------------------------------------------------------
1 |
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
18 | */
19 | class WebProcessor
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 | }
114 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/ErrorHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\TestHandler;
15 |
16 | class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
17 | {
18 | public function testHandleError()
19 | {
20 | $logger = new Logger('test', array($handler = new TestHandler));
21 | $errHandler = new ErrorHandler($logger);
22 |
23 | $errHandler->registerErrorHandler(array(E_USER_NOTICE => Logger::EMERGENCY), false);
24 | trigger_error('Foo', E_USER_ERROR);
25 | $this->assertCount(1, $handler->getRecords());
26 | $this->assertTrue($handler->hasErrorRecords());
27 | trigger_error('Foo', E_USER_NOTICE);
28 | $this->assertCount(2, $handler->getRecords());
29 | $this->assertTrue($handler->hasEmergencyRecords());
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Formatter/ElasticaFormatterTest.php:
--------------------------------------------------------------------------------
1 |
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 | class ElasticaFormatterTest extends \PHPUnit_Framework_TestCase
17 | {
18 | public function setUp()
19 | {
20 | if (!class_exists("Elastica\Document")) {
21 | $this->markTestSkipped("ruflin/elastica not installed");
22 | }
23 | }
24 |
25 | /**
26 | * @covers Monolog\Formatter\ElasticaFormatter::__construct
27 | * @covers Monolog\Formatter\ElasticaFormatter::format
28 | * @covers Monolog\Formatter\ElasticaFormatter::getDocument
29 | */
30 | public function testFormat()
31 | {
32 | // test log message
33 | $msg = array(
34 | 'level' => Logger::ERROR,
35 | 'level_name' => 'ERROR',
36 | 'channel' => 'meh',
37 | 'context' => array('foo' => 7, 'bar', 'class' => new \stdClass),
38 | 'datetime' => new \DateTime("@0"),
39 | 'extra' => array(),
40 | 'message' => 'log',
41 | );
42 |
43 | // expected values
44 | $expected = $msg;
45 | $expected['datetime'] = '1970-01-01T00:00:00.000000+00:00';
46 | $expected['context'] = array(
47 | 'class' => '[object] (stdClass: {})',
48 | 'foo' => 7,
49 | 0 => 'bar',
50 | );
51 |
52 | // format log message
53 | $formatter = new ElasticaFormatter('my_index', 'doc_type');
54 | $doc = $formatter->format($msg);
55 | $this->assertInstanceOf('Elastica\Document', $doc);
56 |
57 | // Document parameters
58 | $params = $doc->getParams();
59 | $this->assertEquals('my_index', $params['_index']);
60 | $this->assertEquals('doc_type', $params['_type']);
61 |
62 | // Document data values
63 | $data = $doc->getData();
64 | foreach (array_keys($expected) as $key) {
65 | $this->assertEquals($expected[$key], $data[$key]);
66 | }
67 | }
68 |
69 | /**
70 | * @covers Monolog\Formatter\ElasticaFormatter::getIndex
71 | * @covers Monolog\Formatter\ElasticaFormatter::getType
72 | */
73 | public function testGetters()
74 | {
75 | $formatter = new ElasticaFormatter('my_index', 'doc_type');
76 | $this->assertEquals('my_index', $formatter->getIndex());
77 | $this->assertEquals('doc_type', $formatter->getType());
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Formatter/FlowdockFormatterTest.php:
--------------------------------------------------------------------------------
1 |
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 Monolog\TestCase;
16 |
17 | class FlowdockFormatterTest extends TestCase
18 | {
19 | /**
20 | * @covers Monolog\Formatter\FlowdockFormatter::format
21 | */
22 | public function testFormat()
23 | {
24 | $formatter = new FlowdockFormatter('test_source', 'source@test.com');
25 | $record = $this->getRecord();
26 |
27 | $expected = array(
28 | 'source' => 'test_source',
29 | 'from_address' => 'source@test.com',
30 | 'subject' => 'in test_source: WARNING - test',
31 | 'content' => 'test',
32 | 'tags' => array('#logs', '#warning', '#test'),
33 | 'project' => 'test_source',
34 | );
35 | $formatted = $formatter->format($record);
36 |
37 | $this->assertEquals($expected, $formatted['flowdock']);
38 | }
39 |
40 | /**
41 | * @ covers Monolog\Formatter\FlowdockFormatter::formatBatch
42 | */
43 | public function testFormatBatch()
44 | {
45 | $formatter = new FlowdockFormatter('test_source', 'source@test.com');
46 | $records = array(
47 | $this->getRecord(Logger::WARNING),
48 | $this->getRecord(Logger::DEBUG),
49 | );
50 | $formatted = $formatter->formatBatch($records);
51 |
52 | $this->assertArrayHasKey('flowdock', $formatted[0]);
53 | $this->assertArrayHasKey('flowdock', $formatted[1]);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Formatter/FluentdFormatterTest.php:
--------------------------------------------------------------------------------
1 |
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 Monolog\TestCase;
16 |
17 | class FluentdFormatterTest extends TestCase
18 | {
19 | /**
20 | * @covers Monolog\Formatter\FluentdFormatter::__construct
21 | * @covers Monolog\Formatter\FluentdFormatter::isUsingLevelsInTag
22 | */
23 | public function testConstruct()
24 | {
25 | $formatter = new FluentdFormatter();
26 | $this->assertEquals(false, $formatter->isUsingLevelsInTag());
27 | $formatter = new FluentdFormatter(false);
28 | $this->assertEquals(false, $formatter->isUsingLevelsInTag());
29 | $formatter = new FluentdFormatter(true);
30 | $this->assertEquals(true, $formatter->isUsingLevelsInTag());
31 | }
32 |
33 | /**
34 | * @covers Monolog\Formatter\FluentdFormatter::format
35 | */
36 | public function testFormat()
37 | {
38 | $record = $this->getRecord(Logger::WARNING);
39 | $record['datetime'] = new \DateTime("@0");
40 |
41 | $formatter = new FluentdFormatter();
42 | $this->assertEquals(
43 | '["test",0,{"message":"test","extra":[],"level":300,"level_name":"WARNING"}]',
44 | $formatter->format($record)
45 | );
46 | }
47 |
48 | /**
49 | * @covers Monolog\Formatter\FluentdFormatter::format
50 | */
51 | public function testFormatWithTag()
52 | {
53 | $record = $this->getRecord(Logger::ERROR);
54 | $record['datetime'] = new \DateTime("@0");
55 |
56 | $formatter = new FluentdFormatter(true);
57 | $this->assertEquals(
58 | '["test.error",0,{"message":"test","extra":[]}]',
59 | $formatter->format($record)
60 | );
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Formatter/LogglyFormatterTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 |
16 | class LogglyFormatterTest extends TestCase
17 | {
18 | /**
19 | * @covers Monolog\Formatter\LogglyFormatter::__construct
20 | */
21 | public function testConstruct()
22 | {
23 | $formatter = new LogglyFormatter();
24 | $this->assertEquals(LogglyFormatter::BATCH_MODE_NEWLINES, $formatter->getBatchMode());
25 | $formatter = new LogglyFormatter(LogglyFormatter::BATCH_MODE_JSON);
26 | $this->assertEquals(LogglyFormatter::BATCH_MODE_JSON, $formatter->getBatchMode());
27 | }
28 |
29 | /**
30 | * @covers Monolog\Formatter\LogglyFormatter::format
31 | */
32 | public function testFormat()
33 | {
34 | $formatter = new LogglyFormatter();
35 | $record = $this->getRecord();
36 | $formatted_decoded = json_decode($formatter->format($record), true);
37 | $this->assertArrayHasKey("timestamp", $formatted_decoded);
38 | $this->assertEquals(new \DateTime($formatted_decoded["timestamp"]), $record["datetime"]);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 | use Monolog\Logger;
16 | use Monolog\Processor\WebProcessor;
17 |
18 | class AbstractProcessingHandlerTest extends TestCase
19 | {
20 | /**
21 | * @covers Monolog\Handler\AbstractProcessingHandler::handle
22 | */
23 | public function testHandleLowerLevelMessage()
24 | {
25 | $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, true));
26 | $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
27 | }
28 |
29 | /**
30 | * @covers Monolog\Handler\AbstractProcessingHandler::handle
31 | */
32 | public function testHandleBubbling()
33 | {
34 | $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, true));
35 | $this->assertFalse($handler->handle($this->getRecord()));
36 | }
37 |
38 | /**
39 | * @covers Monolog\Handler\AbstractProcessingHandler::handle
40 | */
41 | public function testHandleNotBubbling()
42 | {
43 | $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, false));
44 | $this->assertTrue($handler->handle($this->getRecord()));
45 | }
46 |
47 | /**
48 | * @covers Monolog\Handler\AbstractProcessingHandler::handle
49 | */
50 | public function testHandleIsFalseWhenNotHandled()
51 | {
52 | $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, false));
53 | $this->assertTrue($handler->handle($this->getRecord()));
54 | $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
55 | }
56 |
57 | /**
58 | * @covers Monolog\Handler\AbstractProcessingHandler::processRecord
59 | */
60 | public function testProcessRecord()
61 | {
62 | $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler');
63 | $handler->pushProcessor(new WebProcessor(array(
64 | 'REQUEST_URI' => '',
65 | 'REQUEST_METHOD' => '',
66 | 'REMOTE_ADDR' => '',
67 | 'SERVER_NAME' => '',
68 | 'UNIQUE_ID' => '',
69 | )));
70 | $handledRecord = null;
71 | $handler->expects($this->once())
72 | ->method('write')
73 | ->will($this->returnCallback(function ($record) use (&$handledRecord) {
74 | $handledRecord = $record;
75 | }))
76 | ;
77 | $handler->handle($this->getRecord());
78 | $this->assertEquals(6, count($handledRecord['extra']));
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/CouchDBHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 | use Monolog\Logger;
16 |
17 | class CouchDBHandlerTest extends TestCase
18 | {
19 | public function testHandle()
20 | {
21 | $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
22 |
23 | $handler = new CouchDBHandler();
24 |
25 | try {
26 | $handler->handle($record);
27 | } catch (\RuntimeException $e) {
28 | $this->markTestSkipped('Could not connect to couchdb server on http://localhost:5984');
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 | use Monolog\Logger;
16 |
17 | class DoctrineCouchDBHandlerTest extends TestCase
18 | {
19 | protected function setup()
20 | {
21 | if (!class_exists('Doctrine\CouchDB\CouchDBClient')) {
22 | $this->markTestSkipped('The "doctrine/couchdb" package is not installed');
23 | }
24 | }
25 |
26 | public function testHandle()
27 | {
28 | $client = $this->getMockBuilder('Doctrine\\CouchDB\\CouchDBClient')
29 | ->setMethods(array('postDocument'))
30 | ->disableOriginalConstructor()
31 | ->getMock();
32 |
33 | $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
34 |
35 | $expected = array(
36 | 'message' => 'test',
37 | 'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34),
38 | 'level' => Logger::WARNING,
39 | 'level_name' => 'WARNING',
40 | 'channel' => 'test',
41 | 'datetime' => $record['datetime']->format('Y-m-d H:i:s'),
42 | 'extra' => array(),
43 | );
44 |
45 | $client->expects($this->once())
46 | ->method('postDocument')
47 | ->with($expected);
48 |
49 | $handler = new DoctrineCouchDBHandler($client);
50 | $handler->handle($record);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/DynamoDbHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 |
16 | class DynamoDbHandlerTest extends TestCase
17 | {
18 | private $client;
19 |
20 | public function setUp()
21 | {
22 | if (!class_exists('Aws\DynamoDb\DynamoDbClient')) {
23 | $this->markTestSkipped('aws/aws-sdk-php not installed');
24 | }
25 |
26 | $this->client = $this->getMockBuilder('Aws\DynamoDb\DynamoDbClient')
27 | ->setMethods(array('formatAttributes', '__call'))
28 | ->disableOriginalConstructor()->getMock();
29 | }
30 |
31 | public function testConstruct()
32 | {
33 | $this->assertInstanceOf('Monolog\Handler\DynamoDbHandler', new DynamoDbHandler($this->client, 'foo'));
34 | }
35 |
36 | public function testInterface()
37 | {
38 | $this->assertInstanceOf('Monolog\Handler\HandlerInterface', new DynamoDbHandler($this->client, 'foo'));
39 | }
40 |
41 | public function testGetFormatter()
42 | {
43 | $handler = new DynamoDbHandler($this->client, 'foo');
44 | $this->assertInstanceOf('Monolog\Formatter\ScalarFormatter', $handler->getFormatter());
45 | }
46 |
47 | public function testHandle()
48 | {
49 | $record = $this->getRecord();
50 | $formatter = $this->getMock('Monolog\Formatter\FormatterInterface');
51 | $formatted = array('foo' => 1, 'bar' => 2);
52 | $handler = new DynamoDbHandler($this->client, 'foo');
53 | $handler->setFormatter($formatter);
54 |
55 | $formatter
56 | ->expects($this->once())
57 | ->method('format')
58 | ->with($record)
59 | ->will($this->returnValue($formatted));
60 | $this->client
61 | ->expects($this->once())
62 | ->method('formatAttributes')
63 | ->with($this->isType('array'))
64 | ->will($this->returnValue($formatted));
65 | $this->client
66 | ->expects($this->once())
67 | ->method('__call')
68 | ->with('putItem', array(array(
69 | 'TableName' => 'foo',
70 | 'Item' => $formatted,
71 | )));
72 |
73 | $handler->handle($record);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/ErrorLogHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 | use Monolog\Logger;
16 | use Monolog\Formatter\LineFormatter;
17 |
18 | function error_log()
19 | {
20 | $GLOBALS['error_log'][] = func_get_args();
21 | }
22 |
23 | class ErrorLogHandlerTest extends TestCase
24 | {
25 | protected function setUp()
26 | {
27 | $GLOBALS['error_log'] = array();
28 | }
29 |
30 | /**
31 | * @covers Monolog\Handler\ErrorLogHandler::__construct
32 | * @expectedException InvalidArgumentException
33 | * @expectedExceptionMessage The given message type "42" is not supported
34 | */
35 | public function testShouldNotAcceptAnInvalidTypeOnContructor()
36 | {
37 | new ErrorLogHandler(42);
38 | }
39 |
40 | /**
41 | * @covers Monolog\Handler\ErrorLogHandler::write
42 | */
43 | public function testShouldLogMessagesUsingErrorLogFuncion()
44 | {
45 | $type = ErrorLogHandler::OPERATING_SYSTEM;
46 | $handler = new ErrorLogHandler($type);
47 | $handler->setFormatter(new LineFormatter('%channel%.%level_name%: %message% %context% %extra%', null, true));
48 | $handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
49 |
50 | $this->assertSame("test.ERROR: Foo\nBar\r\n\r\nBaz [] []", $GLOBALS['error_log'][0][0]);
51 | $this->assertSame($GLOBALS['error_log'][0][1], $type);
52 |
53 | $handler = new ErrorLogHandler($type, Logger::DEBUG, true, true);
54 | $handler->setFormatter(new LineFormatter(null, null, true));
55 | $handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
56 |
57 | $this->assertStringMatchesFormat('[%s] test.ERROR: Foo', $GLOBALS['error_log'][1][0]);
58 | $this->assertSame($GLOBALS['error_log'][1][1], $type);
59 |
60 | $this->assertStringMatchesFormat('Bar', $GLOBALS['error_log'][2][0]);
61 | $this->assertSame($GLOBALS['error_log'][2][1], $type);
62 |
63 | $this->assertStringMatchesFormat('Baz [] []', $GLOBALS['error_log'][3][0]);
64 | $this->assertSame($GLOBALS['error_log'][3][1], $type);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 | use Monolog\Logger;
16 |
17 | /**
18 | * @covers Monolog\Handler\FirePHPHandler
19 | */
20 | class FirePHPHandlerTest extends TestCase
21 | {
22 | public function setUp()
23 | {
24 | TestFirePHPHandler::reset();
25 | $_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; FirePHP/1.0';
26 | }
27 |
28 | public function testHeaders()
29 | {
30 | $handler = new TestFirePHPHandler;
31 | $handler->setFormatter($this->getIdentityFormatter());
32 | $handler->handle($this->getRecord(Logger::DEBUG));
33 | $handler->handle($this->getRecord(Logger::WARNING));
34 |
35 | $expected = array(
36 | 'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2',
37 | 'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1',
38 | 'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3',
39 | 'X-Wf-1-1-1-1' => 'test',
40 | 'X-Wf-1-1-1-2' => 'test',
41 | );
42 |
43 | $this->assertEquals($expected, $handler->getHeaders());
44 | }
45 |
46 | public function testConcurrentHandlers()
47 | {
48 | $handler = new TestFirePHPHandler;
49 | $handler->setFormatter($this->getIdentityFormatter());
50 | $handler->handle($this->getRecord(Logger::DEBUG));
51 | $handler->handle($this->getRecord(Logger::WARNING));
52 |
53 | $handler2 = new TestFirePHPHandler;
54 | $handler2->setFormatter($this->getIdentityFormatter());
55 | $handler2->handle($this->getRecord(Logger::DEBUG));
56 | $handler2->handle($this->getRecord(Logger::WARNING));
57 |
58 | $expected = array(
59 | 'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2',
60 | 'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1',
61 | 'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3',
62 | 'X-Wf-1-1-1-1' => 'test',
63 | 'X-Wf-1-1-1-2' => 'test',
64 | );
65 |
66 | $expected2 = array(
67 | 'X-Wf-1-1-1-3' => 'test',
68 | 'X-Wf-1-1-1-4' => 'test',
69 | );
70 |
71 | $this->assertEquals($expected, $handler->getHeaders());
72 | $this->assertEquals($expected2, $handler2->getHeaders());
73 | }
74 | }
75 |
76 | class TestFirePHPHandler extends FirePHPHandler
77 | {
78 | protected $headers = array();
79 |
80 | public static function reset()
81 | {
82 | self::$initialized = false;
83 | self::$sendHeaders = true;
84 | self::$messageIndex = 1;
85 | }
86 |
87 | protected function sendHeader($header, $content)
88 | {
89 | $this->headers[$header] = $content;
90 | }
91 |
92 | public function getHeaders()
93 | {
94 | return $this->headers;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/Fixtures/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phproberto/lib_sample/f44d0c17e13355140a2450b00a027305e7776ffc/vendor/monolog/monolog/tests/Monolog/Handler/Fixtures/.gitkeep
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/FleepHookHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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 | use Monolog\TestCase;
17 |
18 | /**
19 | * @coversDefaultClass \Monolog\Handler\FleepHookHandler
20 | */
21 | class FleepHookHandlerTest extends TestCase
22 | {
23 | /**
24 | * Default token to use in tests
25 | */
26 | const TOKEN = '123abc';
27 |
28 | /**
29 | * @var FleepHookHandler
30 | */
31 | private $handler;
32 |
33 | public function setUp()
34 | {
35 | parent::setUp();
36 |
37 | if (!extension_loaded('openssl')) {
38 | $this->markTestSkipped('This test requires openssl extension to run');
39 | }
40 |
41 | // Create instances of the handler and logger for convenience
42 | $this->handler = new FleepHookHandler(self::TOKEN);
43 | }
44 |
45 | /**
46 | * @covers ::__construct
47 | */
48 | public function testConstructorSetsExpectedDefaults()
49 | {
50 | $this->assertEquals(Logger::DEBUG, $this->handler->getLevel());
51 | $this->assertEquals(true, $this->handler->getBubble());
52 | }
53 |
54 | /**
55 | * @covers ::getDefaultFormatter
56 | */
57 | public function testHandlerUsesLineFormatterWhichIgnoresEmptyArrays()
58 | {
59 | $record = array(
60 | 'message' => 'msg',
61 | 'context' => array(),
62 | 'level' => Logger::DEBUG,
63 | 'level_name' => Logger::getLevelName(Logger::DEBUG),
64 | 'channel' => 'channel',
65 | 'datetime' => new \DateTime(),
66 | 'extra' => array(),
67 | );
68 |
69 | $expectedFormatter = new LineFormatter(null, null, true, true);
70 | $expected = $expectedFormatter->format($record);
71 |
72 | $handlerFormatter = $this->handler->getFormatter();
73 | $actual = $handlerFormatter->format($record);
74 |
75 | $this->assertEquals($expected, $actual, 'Empty context and extra arrays should not be rendered');
76 | }
77 |
78 | /**
79 | * @covers ::__construct
80 | */
81 | public function testConnectionStringisConstructedCorrectly()
82 | {
83 | $this->assertEquals('ssl://' . FleepHookHandler::FLEEP_HOST . ':443', $this->handler->getConnectionString());
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/FlowdockHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\FlowdockFormatter;
15 | use Monolog\TestCase;
16 | use Monolog\Logger;
17 |
18 | /**
19 | * @author Dominik Liebler
20 | * @see https://www.hipchat.com/docs/api
21 | */
22 | class FlowdockHandlerTest extends TestCase
23 | {
24 | /**
25 | * @var resource
26 | */
27 | private $res;
28 |
29 | /**
30 | * @var FlowdockHandler
31 | */
32 | private $handler;
33 |
34 | public function setUp()
35 | {
36 | if (!extension_loaded('openssl')) {
37 | $this->markTestSkipped('This test requires openssl to run');
38 | }
39 | }
40 |
41 | public function testWriteHeader()
42 | {
43 | $this->createHandler();
44 | $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
45 | fseek($this->res, 0);
46 | $content = fread($this->res, 1024);
47 |
48 | $this->assertRegexp('/POST \/v1\/messages\/team_inbox\/.* HTTP\/1.1\\r\\nHost: api.flowdock.com\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
49 |
50 | return $content;
51 | }
52 |
53 | /**
54 | * @depends testWriteHeader
55 | */
56 | public function testWriteContent($content)
57 | {
58 | $this->assertRegexp('/"source":"test_source"/', $content);
59 | $this->assertRegexp('/"from_address":"source@test\.com"/', $content);
60 | }
61 |
62 | private function createHandler($token = 'myToken')
63 | {
64 | $constructorArgs = array($token, Logger::DEBUG);
65 | $this->res = fopen('php://memory', 'a');
66 | $this->handler = $this->getMock(
67 | '\Monolog\Handler\FlowdockHandler',
68 | array('fsockopen', 'streamSetTimeout', 'closeSocket'),
69 | $constructorArgs
70 | );
71 |
72 | $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
73 | $reflectionProperty->setAccessible(true);
74 | $reflectionProperty->setValue($this->handler, 'localhost:1234');
75 |
76 | $this->handler->expects($this->any())
77 | ->method('fsockopen')
78 | ->will($this->returnValue($this->res));
79 | $this->handler->expects($this->any())
80 | ->method('streamSetTimeout')
81 | ->will($this->returnValue(true));
82 | $this->handler->expects($this->any())
83 | ->method('closeSocket')
84 | ->will($this->returnValue(true));
85 |
86 | $this->handler->setFormatter(new FlowdockFormatter('test_source', 'source@test.com'));
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerLegacyTest.php:
--------------------------------------------------------------------------------
1 |
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\Message;
15 | use Monolog\TestCase;
16 | use Monolog\Logger;
17 | use Monolog\Formatter\GelfMessageFormatter;
18 |
19 | class GelfHandlerLegacyTest extends TestCase
20 | {
21 | public function setUp()
22 | {
23 | if (!class_exists('Gelf\MessagePublisher') || !class_exists('Gelf\Message')) {
24 | $this->markTestSkipped("mlehner/gelf-php not installed");
25 | }
26 |
27 | require_once __DIR__ . '/GelfMockMessagePublisher.php';
28 | }
29 |
30 | /**
31 | * @covers Monolog\Handler\GelfHandler::__construct
32 | */
33 | public function testConstruct()
34 | {
35 | $handler = new GelfHandler($this->getMessagePublisher());
36 | $this->assertInstanceOf('Monolog\Handler\GelfHandler', $handler);
37 | }
38 |
39 | protected function getHandler($messagePublisher)
40 | {
41 | $handler = new GelfHandler($messagePublisher);
42 |
43 | return $handler;
44 | }
45 |
46 | protected function getMessagePublisher()
47 | {
48 | return new GelfMockMessagePublisher('localhost');
49 | }
50 |
51 | public function testDebug()
52 | {
53 | $messagePublisher = $this->getMessagePublisher();
54 | $handler = $this->getHandler($messagePublisher);
55 |
56 | $record = $this->getRecord(Logger::DEBUG, "A test debug message");
57 | $handler->handle($record);
58 |
59 | $this->assertEquals(7, $messagePublisher->lastMessage->getLevel());
60 | $this->assertEquals('test', $messagePublisher->lastMessage->getFacility());
61 | $this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage());
62 | $this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage());
63 | }
64 |
65 | public function testWarning()
66 | {
67 | $messagePublisher = $this->getMessagePublisher();
68 | $handler = $this->getHandler($messagePublisher);
69 |
70 | $record = $this->getRecord(Logger::WARNING, "A test warning message");
71 | $handler->handle($record);
72 |
73 | $this->assertEquals(4, $messagePublisher->lastMessage->getLevel());
74 | $this->assertEquals('test', $messagePublisher->lastMessage->getFacility());
75 | $this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage());
76 | $this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage());
77 | }
78 |
79 | public function testInjectedGelfMessageFormatter()
80 | {
81 | $messagePublisher = $this->getMessagePublisher();
82 | $handler = $this->getHandler($messagePublisher);
83 |
84 | $handler->setFormatter(new GelfMessageFormatter('mysystem', 'EXT', 'CTX'));
85 |
86 | $record = $this->getRecord(Logger::WARNING, "A test warning message");
87 | $record['extra']['blarg'] = 'yep';
88 | $record['context']['from'] = 'logger';
89 | $handler->handle($record);
90 |
91 | $this->assertEquals('mysystem', $messagePublisher->lastMessage->getHost());
92 | $this->assertArrayHasKey('_EXTblarg', $messagePublisher->lastMessage->toArray());
93 | $this->assertArrayHasKey('_CTXfrom', $messagePublisher->lastMessage->toArray());
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/GelfMockMessagePublisher.php:
--------------------------------------------------------------------------------
1 |
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\MessagePublisher;
15 | use Gelf\Message;
16 |
17 | class GelfMockMessagePublisher extends MessagePublisher
18 | {
19 | public function publish(Message $message)
20 | {
21 | $this->lastMessage = $message;
22 | }
23 |
24 | public $lastMessage = null;
25 | }
26 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/GroupHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 | use Monolog\Logger;
16 |
17 | class GroupHandlerTest extends TestCase
18 | {
19 | /**
20 | * @covers Monolog\Handler\GroupHandler::__construct
21 | * @expectedException InvalidArgumentException
22 | */
23 | public function testConstructorOnlyTakesHandler()
24 | {
25 | new GroupHandler(array(new TestHandler(), "foo"));
26 | }
27 |
28 | /**
29 | * @covers Monolog\Handler\GroupHandler::__construct
30 | * @covers Monolog\Handler\GroupHandler::handle
31 | */
32 | public function testHandle()
33 | {
34 | $testHandlers = array(new TestHandler(), new TestHandler());
35 | $handler = new GroupHandler($testHandlers);
36 | $handler->handle($this->getRecord(Logger::DEBUG));
37 | $handler->handle($this->getRecord(Logger::INFO));
38 | foreach ($testHandlers as $test) {
39 | $this->assertTrue($test->hasDebugRecords());
40 | $this->assertTrue($test->hasInfoRecords());
41 | $this->assertTrue(count($test->getRecords()) === 2);
42 | }
43 | }
44 |
45 | /**
46 | * @covers Monolog\Handler\GroupHandler::handleBatch
47 | */
48 | public function testHandleBatch()
49 | {
50 | $testHandlers = array(new TestHandler(), new TestHandler());
51 | $handler = new GroupHandler($testHandlers);
52 | $handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO)));
53 | foreach ($testHandlers as $test) {
54 | $this->assertTrue($test->hasDebugRecords());
55 | $this->assertTrue($test->hasInfoRecords());
56 | $this->assertTrue(count($test->getRecords()) === 2);
57 | }
58 | }
59 |
60 | /**
61 | * @covers Monolog\Handler\GroupHandler::isHandling
62 | */
63 | public function testIsHandling()
64 | {
65 | $testHandlers = array(new TestHandler(Logger::ERROR), new TestHandler(Logger::WARNING));
66 | $handler = new GroupHandler($testHandlers);
67 | $this->assertTrue($handler->isHandling($this->getRecord(Logger::ERROR)));
68 | $this->assertTrue($handler->isHandling($this->getRecord(Logger::WARNING)));
69 | $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
70 | }
71 |
72 | /**
73 | * @covers Monolog\Handler\GroupHandler::handle
74 | */
75 | public function testHandleUsesProcessors()
76 | {
77 | $test = new TestHandler();
78 | $handler = new GroupHandler(array($test));
79 | $handler->pushProcessor(function ($record) {
80 | $record['extra']['foo'] = true;
81 |
82 | return $record;
83 | });
84 | $handler->handle($this->getRecord(Logger::WARNING));
85 | $this->assertTrue($test->hasWarningRecords());
86 | $records = $test->getRecords();
87 | $this->assertTrue($records[0]['extra']['foo']);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/LogEntriesHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 | use Monolog\Logger;
16 |
17 | /**
18 | * @author Robert Kaufmann III
19 | */
20 | class LogEntriesHandlerTest extends TestCase
21 | {
22 | /**
23 | * @var resource
24 | */
25 | private $res;
26 |
27 | /**
28 | * @var LogEntriesHandler
29 | */
30 | private $handler;
31 |
32 | public function testWriteContent()
33 | {
34 | $this->createHandler();
35 | $this->handler->handle($this->getRecord(Logger::CRITICAL, 'Critical write test'));
36 |
37 | fseek($this->res, 0);
38 | $content = fread($this->res, 1024);
39 |
40 | $this->assertRegexp('/testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] test.CRITICAL: Critical write test/', $content);
41 | }
42 |
43 | public function testWriteBatchContent()
44 | {
45 | $records = array(
46 | $this->getRecord(),
47 | $this->getRecord(),
48 | $this->getRecord(),
49 | );
50 | $this->createHandler();
51 | $this->handler->handleBatch($records);
52 |
53 | fseek($this->res, 0);
54 | $content = fread($this->res, 1024);
55 |
56 | $this->assertRegexp('/(testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] .* \[\] \[\]\n){3}/', $content);
57 | }
58 |
59 | private function createHandler()
60 | {
61 | $useSSL = extension_loaded('openssl');
62 | $args = array('testToken', $useSSL, Logger::DEBUG, true);
63 | $this->res = fopen('php://memory', 'a');
64 | $this->handler = $this->getMock(
65 | '\Monolog\Handler\LogEntriesHandler',
66 | array('fsockopen', 'streamSetTimeout', 'closeSocket'),
67 | $args
68 | );
69 |
70 | $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
71 | $reflectionProperty->setAccessible(true);
72 | $reflectionProperty->setValue($this->handler, 'localhost:1234');
73 |
74 | $this->handler->expects($this->any())
75 | ->method('fsockopen')
76 | ->will($this->returnValue($this->res));
77 | $this->handler->expects($this->any())
78 | ->method('streamSetTimeout')
79 | ->will($this->returnValue(true));
80 | $this->handler->expects($this->any())
81 | ->method('closeSocket')
82 | ->will($this->returnValue(true));
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/MailHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
16 |
17 | class MailHandlerTest extends TestCase
18 | {
19 | /**
20 | * @covers Monolog\Handler\MailHandler::handleBatch
21 | */
22 | public function testHandleBatch()
23 | {
24 | $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
25 | $formatter->expects($this->once())
26 | ->method('formatBatch'); // Each record is formatted
27 |
28 | $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
29 | $handler->expects($this->once())
30 | ->method('send');
31 | $handler->expects($this->never())
32 | ->method('write'); // write is for individual records
33 |
34 | $handler->setFormatter($formatter);
35 |
36 | $handler->handleBatch($this->getMultipleRecords());
37 | }
38 |
39 | /**
40 | * @covers Monolog\Handler\MailHandler::handleBatch
41 | */
42 | public function testHandleBatchNotSendsMailIfMessagesAreBelowLevel()
43 | {
44 | $records = array(
45 | $this->getRecord(Logger::DEBUG, 'debug message 1'),
46 | $this->getRecord(Logger::DEBUG, 'debug message 2'),
47 | $this->getRecord(Logger::INFO, 'information'),
48 | );
49 |
50 | $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
51 | $handler->expects($this->never())
52 | ->method('send');
53 | $handler->setLevel(Logger::ERROR);
54 |
55 | $handler->handleBatch($records);
56 | }
57 |
58 | /**
59 | * @covers Monolog\Handler\MailHandler::write
60 | */
61 | public function testHandle()
62 | {
63 | $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
64 |
65 | $record = $this->getRecord();
66 | $records = array($record);
67 | $records[0]['formatted'] = '['.$record['datetime']->format('Y-m-d H:i:s').'] test.WARNING: test [] []'."\n";
68 |
69 | $handler->expects($this->once())
70 | ->method('send')
71 | ->with($records[0]['formatted'], $records);
72 |
73 | $handler->handle($record);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/MockRavenClient.php:
--------------------------------------------------------------------------------
1 |
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 Raven_Client;
15 |
16 | class MockRavenClient extends Raven_Client
17 | {
18 | public function capture($data, $stack, $vars = null)
19 | {
20 | $data = array_merge($this->get_user_data(), $data);
21 | $this->lastData = $data;
22 | $this->lastStack = $stack;
23 | }
24 |
25 | public $lastData;
26 | public $lastStack;
27 | }
28 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 | use Monolog\Logger;
16 |
17 | class MongoDBHandlerTest extends TestCase
18 | {
19 | /**
20 | * @expectedException InvalidArgumentException
21 | */
22 | public function testConstructorShouldThrowExceptionForInvalidMongo()
23 | {
24 | new MongoDBHandler(new \stdClass(), 'DB', 'Collection');
25 | }
26 |
27 | public function testHandle()
28 | {
29 | $mongo = $this->getMock('Mongo', array('selectCollection'), array(), '', false);
30 | $collection = $this->getMock('stdClass', array('save'));
31 |
32 | $mongo->expects($this->once())
33 | ->method('selectCollection')
34 | ->with('DB', 'Collection')
35 | ->will($this->returnValue($collection));
36 |
37 | $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
38 |
39 | $expected = array(
40 | 'message' => 'test',
41 | 'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34),
42 | 'level' => Logger::WARNING,
43 | 'level_name' => 'WARNING',
44 | 'channel' => 'test',
45 | 'datetime' => $record['datetime']->format('Y-m-d H:i:s'),
46 | 'extra' => array(),
47 | );
48 |
49 | $collection->expects($this->once())
50 | ->method('save')
51 | ->with($expected);
52 |
53 | $handler = new MongoDBHandler($mongo, 'DB', 'Collection');
54 | $handler->handle($record);
55 | }
56 | }
57 |
58 | if (!class_exists('Mongo')) {
59 | class Mongo
60 | {
61 | public function selectCollection()
62 | {
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/NullHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 | use Monolog\Logger;
16 |
17 | /**
18 | * @covers Monolog\Handler\NullHandler::handle
19 | */
20 | class NullHandlerTest extends TestCase
21 | {
22 | public function testHandle()
23 | {
24 | $handler = new NullHandler();
25 | $this->assertTrue($handler->handle($this->getRecord()));
26 | }
27 |
28 | public function testHandleLowerLevelRecord()
29 | {
30 | $handler = new NullHandler(Logger::WARNING);
31 | $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/PsrHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 | use Monolog\Logger;
16 |
17 | /**
18 | * @covers Monolog\Handler\PsrHandler::handle
19 | */
20 | class PsrHandlerTest extends TestCase
21 | {
22 | public function logLevelProvider()
23 | {
24 | $levels = array();
25 | $monologLogger = new Logger('');
26 |
27 | foreach ($monologLogger->getLevels() as $levelName => $level) {
28 | $levels[] = array($levelName, $level);
29 | }
30 |
31 | return $levels;
32 | }
33 |
34 | /**
35 | * @dataProvider logLevelProvider
36 | */
37 | public function testHandlesAllLevels($levelName, $level)
38 | {
39 | $message = 'Hello, world! ' . $level;
40 | $context = array('foo' => 'bar', 'level' => $level);
41 |
42 | $psrLogger = $this->getMock('Psr\Log\NullLogger');
43 | $psrLogger->expects($this->once())
44 | ->method('log')
45 | ->with(strtolower($levelName), $message, $context);
46 |
47 | $handler = new PsrHandler($psrLogger);
48 | $handler->handle(array('level' => $level, 'level_name' => $levelName, 'message' => $message, 'context' => $context));
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 |
16 | /**
17 | * @covers Monolog\Handler\RotatingFileHandler
18 | */
19 | class RotatingFileHandlerTest extends TestCase
20 | {
21 | public function setUp()
22 | {
23 | $dir = __DIR__.'/Fixtures';
24 | chmod($dir, 0777);
25 | if (!is_writable($dir)) {
26 | $this->markTestSkipped($dir.' must be writeable to test the RotatingFileHandler.');
27 | }
28 | }
29 |
30 | public function testRotationCreatesNewFile()
31 | {
32 | touch(__DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400).'.rot');
33 |
34 | $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot');
35 | $handler->setFormatter($this->getIdentityFormatter());
36 | $handler->handle($this->getRecord());
37 |
38 | $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot';
39 | $this->assertTrue(file_exists($log));
40 | $this->assertEquals('test', file_get_contents($log));
41 | }
42 |
43 | /**
44 | * @dataProvider rotationTests
45 | */
46 | public function testRotation($createFile)
47 | {
48 | touch($old1 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400).'.rot');
49 | touch($old2 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400 * 2).'.rot');
50 | touch($old3 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400 * 3).'.rot');
51 | touch($old4 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400 * 4).'.rot');
52 |
53 | $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot';
54 |
55 | if ($createFile) {
56 | touch($log);
57 | }
58 |
59 | $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2);
60 | $handler->setFormatter($this->getIdentityFormatter());
61 | $handler->handle($this->getRecord());
62 |
63 | $handler->close();
64 |
65 | $this->assertTrue(file_exists($log));
66 | $this->assertTrue(file_exists($old1));
67 | $this->assertEquals($createFile, file_exists($old2));
68 | $this->assertEquals($createFile, file_exists($old3));
69 | $this->assertEquals($createFile, file_exists($old4));
70 | $this->assertEquals('test', file_get_contents($log));
71 | }
72 |
73 | public function rotationTests()
74 | {
75 | return array(
76 | 'Rotation is triggered when the file of the current day is not present'
77 | => array(true),
78 | 'Rotation is not triggered when the file is already present'
79 | => array(false),
80 | );
81 | }
82 |
83 | public function testReuseCurrentFile()
84 | {
85 | $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot';
86 | file_put_contents($log, "foo");
87 | $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot');
88 | $handler->setFormatter($this->getIdentityFormatter());
89 | $handler->handle($this->getRecord());
90 | $this->assertEquals('footest', file_get_contents($log));
91 | }
92 |
93 | public function tearDown()
94 | {
95 | foreach (glob(__DIR__.'/Fixtures/*.rot') as $file) {
96 | unlink($file);
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/SamplingHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 |
16 | /**
17 | * @covers Monolog\Handler\SamplingHandler::handle
18 | */
19 | class SamplingHandlerTest extends TestCase
20 | {
21 | public function testHandle()
22 | {
23 | $testHandler = new TestHandler();
24 | $handler = new SamplingHandler($testHandler, 2);
25 | for ($i = 0; $i < 10000; $i++) {
26 | $handler->handle($this->getRecord());
27 | }
28 | $count = count($testHandler->getRecords());
29 | // $count should be half of 10k, so between 4k and 6k
30 | $this->assertLessThan(6000, $count);
31 | $this->assertGreaterThan(4000, $count);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/SyslogHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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 | class SyslogHandlerTest extends \PHPUnit_Framework_TestCase
17 | {
18 | /**
19 | * @covers Monolog\Handler\SyslogHandler::__construct
20 | */
21 | public function testConstruct()
22 | {
23 | $handler = new SyslogHandler('test');
24 | $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
25 |
26 | $handler = new SyslogHandler('test', LOG_USER);
27 | $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
28 |
29 | $handler = new SyslogHandler('test', 'user');
30 | $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
31 |
32 | $handler = new SyslogHandler('test', LOG_USER, Logger::DEBUG, true, LOG_PERROR);
33 | $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
34 | }
35 |
36 | /**
37 | * @covers Monolog\Handler\SyslogHandler::__construct
38 | */
39 | public function testConstructInvalidFacility()
40 | {
41 | $this->setExpectedException('UnexpectedValueException');
42 | $handler = new SyslogHandler('test', 'unknown');
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/SyslogUdpHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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 | * @requires extension sockets
16 | */
17 | class SyslogUdpHandlerTest extends \PHPUnit_Framework_TestCase
18 | {
19 | /**
20 | * @expectedException UnexpectedValueException
21 | */
22 | public function testWeValidateFacilities()
23 | {
24 | $handler = new SyslogUdpHandler("ip", null, "invalidFacility");
25 | }
26 |
27 | public function testWeSplitIntoLines()
28 | {
29 | $handler = new SyslogUdpHandler("127.0.0.1", 514, "authpriv");
30 | $handler->setFormatter(new \Monolog\Formatter\ChromePHPFormatter());
31 |
32 | $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('write'), array('lol', 'lol'));
33 | $socket->expects($this->at(0))
34 | ->method('write')
35 | ->with("lol", "<".(LOG_AUTHPRIV + LOG_WARNING).">1 ");
36 | $socket->expects($this->at(1))
37 | ->method('write')
38 | ->with("hej", "<".(LOG_AUTHPRIV + LOG_WARNING).">1 ");
39 |
40 | $handler->setSocket($socket);
41 |
42 | $handler->handle($this->getRecordWithMessage("hej\nlol"));
43 | }
44 |
45 | protected function getRecordWithMessage($msg)
46 | {
47 | return array('message' => $msg, 'level' => \Monolog\Logger::WARNING, 'context' => null, 'extra' => array(), 'channel' => 'lol');
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 | use Monolog\Logger;
16 |
17 | /**
18 | * @covers Monolog\Handler\TestHandler
19 | */
20 | class TestHandlerTest extends TestCase
21 | {
22 | /**
23 | * @dataProvider methodProvider
24 | */
25 | public function testHandler($method, $level)
26 | {
27 | $handler = new TestHandler;
28 | $record = $this->getRecord($level, 'test'.$method);
29 | $this->assertFalse($handler->{'has'.$method}($record), 'has'.$method);
30 | $this->assertFalse($handler->{'has'.$method.'ThatContains'}('test'), 'has'.$method.'ThatContains');
31 | $this->assertFalse($handler->{'has'.$method.'ThatPasses'}(function ($rec) {
32 | return true;
33 | }), 'has'.$method.'ThatPasses');
34 | $this->assertFalse($handler->{'has'.$method.'ThatMatches'}('/test\w+/'));
35 | $this->assertFalse($handler->{'has'.$method.'Records'}(), 'has'.$method.'Records');
36 | $handler->handle($record);
37 |
38 | $this->assertFalse($handler->{'has'.$method}('bar'), 'has'.$method);
39 | $this->assertTrue($handler->{'has'.$method}($record), 'has'.$method);
40 | $this->assertTrue($handler->{'has'.$method}('test'.$method), 'has'.$method);
41 | $this->assertTrue($handler->{'has'.$method.'ThatContains'}('test'), 'has'.$method.'ThatContains');
42 | $this->assertTrue($handler->{'has'.$method.'ThatPasses'}(function ($rec) {
43 | return true;
44 | }), 'has'.$method.'ThatPasses');
45 | $this->assertTrue($handler->{'has'.$method.'ThatMatches'}('/test\w+/'));
46 | $this->assertTrue($handler->{'has'.$method.'Records'}(), 'has'.$method.'Records');
47 |
48 | $records = $handler->getRecords();
49 | unset($records[0]['formatted']);
50 | $this->assertEquals(array($record), $records);
51 | }
52 |
53 | public function methodProvider()
54 | {
55 | return array(
56 | array('Emergency', Logger::EMERGENCY),
57 | array('Alert' , Logger::ALERT),
58 | array('Critical' , Logger::CRITICAL),
59 | array('Error' , Logger::ERROR),
60 | array('Warning' , Logger::WARNING),
61 | array('Info' , Logger::INFO),
62 | array('Notice' , Logger::NOTICE),
63 | array('Debug' , Logger::DEBUG),
64 | );
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/UdpSocketTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 | use Monolog\Handler\SyslogUdp\UdpSocket;
16 |
17 | /**
18 | * @requires extension sockets
19 | */
20 | class UdpSocketTest extends TestCase
21 | {
22 | public function testWeDoNotTruncateShortMessages()
23 | {
24 | $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol'));
25 |
26 | $socket->expects($this->at(0))
27 | ->method('send')
28 | ->with("HEADER: The quick brown fox jumps over the lazy dog");
29 |
30 | $socket->write("The quick brown fox jumps over the lazy dog", "HEADER: ");
31 | }
32 |
33 | public function testLongMessagesAreTruncated()
34 | {
35 | $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol'));
36 |
37 | $truncatedString = str_repeat("derp", 16254).'d';
38 |
39 | $socket->expects($this->exactly(1))
40 | ->method('send')
41 | ->with("HEADER" . $truncatedString);
42 |
43 | $longString = str_repeat("derp", 20000);
44 |
45 | $socket->write($longString, "HEADER");
46 | }
47 |
48 | public function testDoubleCloseDoesNotError()
49 | {
50 | $socket = new UdpSocket('127.0.0.1', 514);
51 | $socket->close();
52 | $socket->close();
53 | }
54 |
55 | /**
56 | * @expectedException LogicException
57 | */
58 | public function testWriteAfterCloseErrors()
59 | {
60 | $socket = new UdpSocket('127.0.0.1', 514);
61 | $socket->close();
62 | $socket->write('foo', "HEADER");
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Handler/ZendMonitorHandlerTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
14 |
15 | class ZendMonitorHandlerTest extends TestCase
16 | {
17 | protected $zendMonitorHandler;
18 |
19 | public function setUp()
20 | {
21 | if (!function_exists('zend_monitor_custom_event')) {
22 | $this->markTestSkipped('ZendServer is not installed');
23 | }
24 | }
25 |
26 | /**
27 | * @covers Monolog\Handler\ZendMonitorHandler::write
28 | */
29 | public function testWrite()
30 | {
31 | $record = $this->getRecord();
32 | $formatterResult = array(
33 | 'message' => $record['message'],
34 | );
35 |
36 | $zendMonitor = $this->getMockBuilder('Monolog\Handler\ZendMonitorHandler')
37 | ->setMethods(array('writeZendMonitorCustomEvent', 'getDefaultFormatter'))
38 | ->getMock();
39 |
40 | $formatterMock = $this->getMockBuilder('Monolog\Formatter\NormalizerFormatter')
41 | ->disableOriginalConstructor()
42 | ->getMock();
43 |
44 | $formatterMock->expects($this->once())
45 | ->method('format')
46 | ->will($this->returnValue($formatterResult));
47 |
48 | $zendMonitor->expects($this->once())
49 | ->method('getDefaultFormatter')
50 | ->will($this->returnValue($formatterMock));
51 |
52 | $levelMap = $zendMonitor->getLevelMap();
53 |
54 | $zendMonitor->expects($this->once())
55 | ->method('writeZendMonitorCustomEvent')
56 | ->with($levelMap[$record['level']], $record['message'], $formatterResult);
57 |
58 | $zendMonitor->handle($record);
59 | }
60 |
61 | /**
62 | * @covers Monolog\Handler\ZendMonitorHandler::getDefaultFormatter
63 | */
64 | public function testGetDefaultFormatterReturnsNormalizerFormatter()
65 | {
66 | $zendMonitor = new ZendMonitorHandler();
67 | $this->assertInstanceOf('Monolog\Formatter\NormalizerFormatter', $zendMonitor->getDefaultFormatter());
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Processor/GitProcessorTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 |
16 | class GitProcessorTest extends TestCase
17 | {
18 | /**
19 | * @covers Monolog\Processor\GitProcessor::__invoke
20 | */
21 | public function testProcessor()
22 | {
23 | $processor = new GitProcessor();
24 | $record = $processor($this->getRecord());
25 |
26 | $this->assertArrayHasKey('git', $record['extra']);
27 | $this->assertTrue(!is_array($record['extra']['git']['branch']));
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 |
16 | class MemoryPeakUsageProcessorTest extends TestCase
17 | {
18 | /**
19 | * @covers Monolog\Processor\MemoryPeakUsageProcessor::__invoke
20 | * @covers Monolog\Processor\MemoryProcessor::formatBytes
21 | */
22 | public function testProcessor()
23 | {
24 | $processor = new MemoryPeakUsageProcessor();
25 | $record = $processor($this->getRecord());
26 | $this->assertArrayHasKey('memory_peak_usage', $record['extra']);
27 | $this->assertRegExp('#[0-9.]+ (M|K)?B$#', $record['extra']['memory_peak_usage']);
28 | }
29 |
30 | /**
31 | * @covers Monolog\Processor\MemoryPeakUsageProcessor::__invoke
32 | * @covers Monolog\Processor\MemoryProcessor::formatBytes
33 | */
34 | public function testProcessorWithoutFormatting()
35 | {
36 | $processor = new MemoryPeakUsageProcessor(true, false);
37 | $record = $processor($this->getRecord());
38 | $this->assertArrayHasKey('memory_peak_usage', $record['extra']);
39 | $this->assertInternalType('int', $record['extra']['memory_peak_usage']);
40 | $this->assertGreaterThan(0, $record['extra']['memory_peak_usage']);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Processor/MemoryUsageProcessorTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 |
16 | class MemoryUsageProcessorTest extends TestCase
17 | {
18 | /**
19 | * @covers Monolog\Processor\MemoryUsageProcessor::__invoke
20 | * @covers Monolog\Processor\MemoryProcessor::formatBytes
21 | */
22 | public function testProcessor()
23 | {
24 | $processor = new MemoryUsageProcessor();
25 | $record = $processor($this->getRecord());
26 | $this->assertArrayHasKey('memory_usage', $record['extra']);
27 | $this->assertRegExp('#[0-9.]+ (M|K)?B$#', $record['extra']['memory_usage']);
28 | }
29 |
30 | /**
31 | * @covers Monolog\Processor\MemoryUsageProcessor::__invoke
32 | * @covers Monolog\Processor\MemoryProcessor::formatBytes
33 | */
34 | public function testProcessorWithoutFormatting()
35 | {
36 | $processor = new MemoryUsageProcessor(true, false);
37 | $record = $processor($this->getRecord());
38 | $this->assertArrayHasKey('memory_usage', $record['extra']);
39 | $this->assertInternalType('int', $record['extra']['memory_usage']);
40 | $this->assertGreaterThan(0, $record['extra']['memory_usage']);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Processor/ProcessIdProcessorTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 |
16 | class ProcessIdProcessorTest extends TestCase
17 | {
18 | /**
19 | * @covers Monolog\Processor\ProcessIdProcessor::__invoke
20 | */
21 | public function testProcessor()
22 | {
23 | $processor = new ProcessIdProcessor();
24 | $record = $processor($this->getRecord());
25 | $this->assertArrayHasKey('process_id', $record['extra']);
26 | $this->assertInternalType('int', $record['extra']['process_id']);
27 | $this->assertGreaterThan(0, $record['extra']['process_id']);
28 | $this->assertEquals(getmypid(), $record['extra']['process_id']);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Processor/PsrLogMessageProcessorTest.php:
--------------------------------------------------------------------------------
1 |
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 | class PsrLogMessageProcessorTest extends \PHPUnit_Framework_TestCase
15 | {
16 | /**
17 | * @dataProvider getPairs
18 | */
19 | public function testReplacement($val, $expected)
20 | {
21 | $proc = new PsrLogMessageProcessor;
22 |
23 | $message = $proc(array(
24 | 'message' => '{foo}',
25 | 'context' => array('foo' => $val),
26 | ));
27 | $this->assertEquals($expected, $message['message']);
28 | }
29 |
30 | public function getPairs()
31 | {
32 | return array(
33 | array('foo', 'foo'),
34 | array('3', '3'),
35 | array(3, '3'),
36 | array(null, ''),
37 | array(true, '1'),
38 | array(false, ''),
39 | array(new \stdClass, '[object stdClass]'),
40 | array(array(), '[array]'),
41 | );
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Processor/TagProcessorTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 |
16 | class TagProcessorTest extends TestCase
17 | {
18 | /**
19 | * @covers Monolog\Processor\TagProcessor::__invoke
20 | */
21 | public function testProcessor()
22 | {
23 | $tags = array(1, 2, 3);
24 | $processor = new TagProcessor($tags);
25 | $record = $processor($this->getRecord());
26 |
27 | $this->assertEquals($tags, $record['extra']['tags']);
28 | }
29 |
30 | /**
31 | * @covers Monolog\Processor\TagProcessor::__invoke
32 | */
33 | public function testProcessorTagModification()
34 | {
35 | $tags = array(1, 2, 3);
36 | $processor = new TagProcessor($tags);
37 |
38 | $record = $processor($this->getRecord());
39 | $this->assertEquals($tags, $record['extra']['tags']);
40 |
41 | $processor->setTags(array('a', 'b'));
42 | $record = $processor($this->getRecord());
43 | $this->assertEquals(array('a', 'b'), $record['extra']['tags']);
44 |
45 | $processor->addTags(array('a', 'c', 'foo' => 'bar'));
46 | $record = $processor($this->getRecord());
47 | $this->assertEquals(array('a', 'b', 'a', 'c', 'foo' => 'bar'), $record['extra']['tags']);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/Processor/UidProcessorTest.php:
--------------------------------------------------------------------------------
1 |
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\TestCase;
15 |
16 | class UidProcessorTest extends TestCase
17 | {
18 | /**
19 | * @covers Monolog\Processor\UidProcessor::__invoke
20 | */
21 | public function testProcessor()
22 | {
23 | $processor = new UidProcessor();
24 | $record = $processor($this->getRecord());
25 | $this->assertArrayHasKey('uid', $record['extra']);
26 | }
27 |
28 | public function testGetUid()
29 | {
30 | $processor = new UidProcessor(10);
31 | $this->assertEquals(10, strlen($processor->getUid()));
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php:
--------------------------------------------------------------------------------
1 |
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\TestHandler;
15 | use Monolog\Formatter\LineFormatter;
16 | use Monolog\Processor\PsrLogMessageProcessor;
17 | use Psr\Log\Test\LoggerInterfaceTest;
18 |
19 | class PsrLogCompatTest extends LoggerInterfaceTest
20 | {
21 | private $handler;
22 |
23 | public function getLogger()
24 | {
25 | $logger = new Logger('foo');
26 | $logger->pushHandler($handler = new TestHandler);
27 | $logger->pushProcessor(new PsrLogMessageProcessor);
28 | $handler->setFormatter(new LineFormatter('%level_name% %message%'));
29 |
30 | $this->handler = $handler;
31 |
32 | return $logger;
33 | }
34 |
35 | public function getLogs()
36 | {
37 | $convert = function ($record) {
38 | $lower = function ($match) {
39 | return strtolower($match[0]);
40 | };
41 |
42 | return preg_replace_callback('{^[A-Z]+}', $lower, $record['formatted']);
43 | };
44 |
45 | return array_map($convert, $this->handler->getRecords());
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/vendor/monolog/monolog/tests/Monolog/TestCase.php:
--------------------------------------------------------------------------------
1 |
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 TestCase extends \PHPUnit_Framework_TestCase
15 | {
16 | /**
17 | * @return array Record
18 | */
19 | protected function getRecord($level = Logger::WARNING, $message = 'test', $context = array())
20 | {
21 | return array(
22 | 'message' => $message,
23 | 'context' => $context,
24 | 'level' => $level,
25 | 'level_name' => Logger::getLevelName($level),
26 | 'channel' => 'test',
27 | 'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true))),
28 | 'extra' => array(),
29 | );
30 | }
31 |
32 | /**
33 | * @return array
34 | */
35 | protected function getMultipleRecords()
36 | {
37 | return array(
38 | $this->getRecord(Logger::DEBUG, 'debug message 1'),
39 | $this->getRecord(Logger::DEBUG, 'debug message 2'),
40 | $this->getRecord(Logger::INFO, 'information'),
41 | $this->getRecord(Logger::WARNING, 'warning'),
42 | $this->getRecord(Logger::ERROR, 'error'),
43 | );
44 | }
45 |
46 | /**
47 | * @return Monolog\Formatter\FormatterInterface
48 | */
49 | protected function getIdentityFormatter()
50 | {
51 | $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
52 | $formatter->expects($this->any())
53 | ->method('format')
54 | ->will($this->returnCallback(function ($record) { return $record['message']; }));
55 |
56 | return $formatter;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/vendor/psr/log/.gitignore:
--------------------------------------------------------------------------------
1 | vendor
2 |
--------------------------------------------------------------------------------
/vendor/psr/log/LICENSE:
--------------------------------------------------------------------------------
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.
20 |
--------------------------------------------------------------------------------
/vendor/psr/log/Psr/Log/AbstractLogger.php:
--------------------------------------------------------------------------------
1 | log(LogLevel::EMERGENCY, $message, $context);
24 | }
25 |
26 | /**
27 | * Action must be taken immediately.
28 | *
29 | * Example: Entire website down, database unavailable, etc. This should
30 | * trigger the SMS alerts and wake you up.
31 | *
32 | * @param string $message
33 | * @param array $context
34 | * @return null
35 | */
36 | public function alert($message, array $context = array())
37 | {
38 | $this->log(LogLevel::ALERT, $message, $context);
39 | }
40 |
41 | /**
42 | * Critical conditions.
43 | *
44 | * Example: Application component unavailable, unexpected exception.
45 | *
46 | * @param string $message
47 | * @param array $context
48 | * @return null
49 | */
50 | public function critical($message, array $context = array())
51 | {
52 | $this->log(LogLevel::CRITICAL, $message, $context);
53 | }
54 |
55 | /**
56 | * Runtime errors that do not require immediate action but should typically
57 | * be logged and monitored.
58 | *
59 | * @param string $message
60 | * @param array $context
61 | * @return null
62 | */
63 | public function error($message, array $context = array())
64 | {
65 | $this->log(LogLevel::ERROR, $message, $context);
66 | }
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 | * @return null
77 | */
78 | public function warning($message, array $context = array())
79 | {
80 | $this->log(LogLevel::WARNING, $message, $context);
81 | }
82 |
83 | /**
84 | * Normal but significant events.
85 | *
86 | * @param string $message
87 | * @param array $context
88 | * @return null
89 | */
90 | public function notice($message, array $context = array())
91 | {
92 | $this->log(LogLevel::NOTICE, $message, $context);
93 | }
94 |
95 | /**
96 | * Interesting events.
97 | *
98 | * Example: User logs in, SQL logs.
99 | *
100 | * @param string $message
101 | * @param array $context
102 | * @return null
103 | */
104 | public function info($message, array $context = array())
105 | {
106 | $this->log(LogLevel::INFO, $message, $context);
107 | }
108 |
109 | /**
110 | * Detailed debug information.
111 | *
112 | * @param string $message
113 | * @param array $context
114 | * @return null
115 | */
116 | public function debug($message, array $context = array())
117 | {
118 | $this->log(LogLevel::DEBUG, $message, $context);
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/vendor/psr/log/Psr/Log/InvalidArgumentException.php:
--------------------------------------------------------------------------------
1 | logger = $logger;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/vendor/psr/log/Psr/Log/LoggerInterface.php:
--------------------------------------------------------------------------------
1 | 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 | * @return null
22 | */
23 | public function log($level, $message, array $context = array())
24 | {
25 | // noop
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/vendor/psr/log/README.md:
--------------------------------------------------------------------------------
1 | PSR Log
2 | =======
3 |
4 | This repository holds all interfaces/classes/traits related to
5 | [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md).
6 |
7 | Note that this is not a logger of its own. It is merely an interface that
8 | describes a logger. See the specification for more details.
9 |
10 | Usage
11 | -----
12 |
13 | If you need a logger, you can use the interface like this:
14 |
15 | ```php
16 | logger = $logger;
27 | }
28 |
29 | public function doSomething()
30 | {
31 | if ($this->logger) {
32 | $this->logger->info('Doing work');
33 | }
34 |
35 | // do something useful
36 | }
37 | }
38 | ```
39 |
40 | You can then pick one of the implementations of the interface to get a logger.
41 |
42 | If you want to implement the interface, you can require this package and
43 | implement `Psr\Log\LoggerInterface` in your code. Please read the
44 | [specification text](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
45 | for details.
46 |
--------------------------------------------------------------------------------
/vendor/psr/log/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "psr/log",
3 | "description": "Common interface for logging libraries",
4 | "keywords": ["psr", "psr-3", "log"],
5 | "license": "MIT",
6 | "authors": [
7 | {
8 | "name": "PHP-FIG",
9 | "homepage": "http://www.php-fig.org/"
10 | }
11 | ],
12 | "autoload": {
13 | "psr-0": {
14 | "Psr\\Log\\": ""
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------