Add/update benchmark/NYU_CTF_Bench (part 4)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +4 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw.tar.gz +3 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Formatter/ChromePHPFormatterTest.php +158 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Formatter/GelfMessageFormatterTest.php +158 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php +41 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Formatter/LineFormatterTest.php +164 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Formatter/LogstashFormatterTest.php +160 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php +160 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Formatter/WildfireFormatterTest.php +111 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/AbstractHandlerTest.php +104 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php +79 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/AmqpExchangeMock.php +38 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/AmqpHandlerTest.php +74 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/BufferHandlerTest.php +149 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php +139 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/CouchDBHandlerTest.php +41 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php +52 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php +169 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php +94 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerTest.php +94 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/GelfMocks.php +25 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/GroupHandlerTest.php +89 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/MailHandlerTest.php +75 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/MockRavenClient.php +26 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php +63 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/NativeMailerHandlerTest.php +43 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/NullHandlerTest.php +33 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/PushoverHandlerTest.php +108 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php +95 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/RedisHandlerTest.php +71 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php +99 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php +283 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/StreamHandlerTest.php +88 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/LoggerTest.php +409 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php +47 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/TestCase.php +58 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/bootstrap.php +13 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/.gitignore +1 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/LICENSE +19 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/AbstractLogger.php +120 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/InvalidArgumentException.php +7 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/LogLevel.php +18 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/LoggerAwareInterface.php +17 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/LoggerAwareTrait.php +22 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/LoggerInterface.php +114 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/LoggerTrait.php +131 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/NullLogger.php +27 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php +116 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/README.md +45 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/composer.json +17 -0
.gitattributes
CHANGED
|
@@ -2221,3 +2221,7 @@ benchmark/NYU_CTF_Bench/test/2018/CSAW-Quals/rev/kvm/kvm/payload.o filter=lfs di
|
|
| 2221 |
*.dex filter=lfs diff=lfs merge=lfs -text
|
| 2222 |
*.whl filter=lfs diff=lfs merge=lfs -text
|
| 2223 |
*.mat filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2221 |
*.dex filter=lfs diff=lfs merge=lfs -text
|
| 2222 |
*.whl filter=lfs diff=lfs merge=lfs -text
|
| 2223 |
*.mat filter=lfs diff=lfs merge=lfs -text
|
| 2224 |
+
benchmark/NYU_CTF_Bench/development/2013/CSAW-Quals/crypto/onlythisprogram/input/shannon1948.pdf filter=lfs diff=lfs merge=lfs -text
|
| 2225 |
+
benchmark/NYU_CTF_Bench/development/2013/CSAW-Quals/crypto/onlythisprogram/output/file3.enc filter=lfs diff=lfs merge=lfs -text
|
| 2226 |
+
benchmark/NYU_CTF_Bench/development/2013/CSAW-Quals/crypto/onlythisprogram/output/file5.enc filter=lfs diff=lfs merge=lfs -text
|
| 2227 |
+
benchmark/NYU_CTF_Bench/development/2013/CSAW-Quals/crypto/onlythisprogram/output/file8.enc filter=lfs diff=lfs merge=lfs -text
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b52815289e719d451764e8f38d9c6d7deb6c23c1d0e9e687eb63e363d2a14055
|
| 3 |
+
size 1671568
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Formatter/ChromePHPFormatterTest.php
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Formatter;
|
| 13 |
+
|
| 14 |
+
use Monolog\Logger;
|
| 15 |
+
|
| 16 |
+
class ChromePHPFormatterTest extends \PHPUnit_Framework_TestCase
|
| 17 |
+
{
|
| 18 |
+
/**
|
| 19 |
+
* @covers Monolog\Formatter\ChromePHPFormatter::format
|
| 20 |
+
*/
|
| 21 |
+
public function testDefaultFormat()
|
| 22 |
+
{
|
| 23 |
+
$formatter = new ChromePHPFormatter();
|
| 24 |
+
$record = array(
|
| 25 |
+
'level' => Logger::ERROR,
|
| 26 |
+
'level_name' => 'ERROR',
|
| 27 |
+
'channel' => 'meh',
|
| 28 |
+
'context' => array('from' => 'logger'),
|
| 29 |
+
'datetime' => new \DateTime("@0"),
|
| 30 |
+
'extra' => array('ip' => '127.0.0.1'),
|
| 31 |
+
'message' => 'log',
|
| 32 |
+
);
|
| 33 |
+
|
| 34 |
+
$message = $formatter->format($record);
|
| 35 |
+
|
| 36 |
+
$this->assertEquals(
|
| 37 |
+
array(
|
| 38 |
+
'meh',
|
| 39 |
+
array(
|
| 40 |
+
'message' => 'log',
|
| 41 |
+
'context' => array('from' => 'logger'),
|
| 42 |
+
'extra' => array('ip' => '127.0.0.1'),
|
| 43 |
+
),
|
| 44 |
+
'unknown',
|
| 45 |
+
'error'
|
| 46 |
+
),
|
| 47 |
+
$message
|
| 48 |
+
);
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* @covers Monolog\Formatter\ChromePHPFormatter::format
|
| 53 |
+
*/
|
| 54 |
+
public function testFormatWithFileAndLine()
|
| 55 |
+
{
|
| 56 |
+
$formatter = new ChromePHPFormatter();
|
| 57 |
+
$record = array(
|
| 58 |
+
'level' => Logger::CRITICAL,
|
| 59 |
+
'level_name' => 'CRITICAL',
|
| 60 |
+
'channel' => 'meh',
|
| 61 |
+
'context' => array('from' => 'logger'),
|
| 62 |
+
'datetime' => new \DateTime("@0"),
|
| 63 |
+
'extra' => array('ip' => '127.0.0.1', 'file' => 'test', 'line' => 14),
|
| 64 |
+
'message' => 'log',
|
| 65 |
+
);
|
| 66 |
+
|
| 67 |
+
$message = $formatter->format($record);
|
| 68 |
+
|
| 69 |
+
$this->assertEquals(
|
| 70 |
+
array(
|
| 71 |
+
'meh',
|
| 72 |
+
array(
|
| 73 |
+
'message' => 'log',
|
| 74 |
+
'context' => array('from' => 'logger'),
|
| 75 |
+
'extra' => array('ip' => '127.0.0.1'),
|
| 76 |
+
),
|
| 77 |
+
'test : 14',
|
| 78 |
+
'error'
|
| 79 |
+
),
|
| 80 |
+
$message
|
| 81 |
+
);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* @covers Monolog\Formatter\ChromePHPFormatter::format
|
| 86 |
+
*/
|
| 87 |
+
public function testFormatWithoutContext()
|
| 88 |
+
{
|
| 89 |
+
$formatter = new ChromePHPFormatter();
|
| 90 |
+
$record = array(
|
| 91 |
+
'level' => Logger::DEBUG,
|
| 92 |
+
'level_name' => 'DEBUG',
|
| 93 |
+
'channel' => 'meh',
|
| 94 |
+
'context' => array(),
|
| 95 |
+
'datetime' => new \DateTime("@0"),
|
| 96 |
+
'extra' => array(),
|
| 97 |
+
'message' => 'log',
|
| 98 |
+
);
|
| 99 |
+
|
| 100 |
+
$message = $formatter->format($record);
|
| 101 |
+
|
| 102 |
+
$this->assertEquals(
|
| 103 |
+
array(
|
| 104 |
+
'meh',
|
| 105 |
+
'log',
|
| 106 |
+
'unknown',
|
| 107 |
+
'log'
|
| 108 |
+
),
|
| 109 |
+
$message
|
| 110 |
+
);
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
/**
|
| 114 |
+
* @covers Monolog\Formatter\ChromePHPFormatter::formatBatch
|
| 115 |
+
*/
|
| 116 |
+
public function testBatchFormatThrowException()
|
| 117 |
+
{
|
| 118 |
+
$formatter = new ChromePHPFormatter();
|
| 119 |
+
$records = array(
|
| 120 |
+
array(
|
| 121 |
+
'level' => Logger::INFO,
|
| 122 |
+
'level_name' => 'INFO',
|
| 123 |
+
'channel' => 'meh',
|
| 124 |
+
'context' => array(),
|
| 125 |
+
'datetime' => new \DateTime("@0"),
|
| 126 |
+
'extra' => array(),
|
| 127 |
+
'message' => 'log',
|
| 128 |
+
),
|
| 129 |
+
array(
|
| 130 |
+
'level' => Logger::WARNING,
|
| 131 |
+
'level_name' => 'WARNING',
|
| 132 |
+
'channel' => 'foo',
|
| 133 |
+
'context' => array(),
|
| 134 |
+
'datetime' => new \DateTime("@0"),
|
| 135 |
+
'extra' => array(),
|
| 136 |
+
'message' => 'log2',
|
| 137 |
+
),
|
| 138 |
+
);
|
| 139 |
+
|
| 140 |
+
$this->assertEquals(
|
| 141 |
+
array(
|
| 142 |
+
array(
|
| 143 |
+
'meh',
|
| 144 |
+
'log',
|
| 145 |
+
'unknown',
|
| 146 |
+
'info'
|
| 147 |
+
),
|
| 148 |
+
array(
|
| 149 |
+
'foo',
|
| 150 |
+
'log2',
|
| 151 |
+
'unknown',
|
| 152 |
+
'warn'
|
| 153 |
+
),
|
| 154 |
+
),
|
| 155 |
+
$formatter->formatBatch($records)
|
| 156 |
+
);
|
| 157 |
+
}
|
| 158 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Formatter/GelfMessageFormatterTest.php
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Formatter;
|
| 13 |
+
|
| 14 |
+
use Monolog\Logger;
|
| 15 |
+
use Monolog\Formatter\GelfMessageFormatter;
|
| 16 |
+
|
| 17 |
+
class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
|
| 18 |
+
{
|
| 19 |
+
public function setUp()
|
| 20 |
+
{
|
| 21 |
+
if (!class_exists("Gelf\Message")) {
|
| 22 |
+
$this->markTestSkipped("mlehner/gelf-php not installed");
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* @covers Monolog\Formatter\GelfMessageFormatter::format
|
| 28 |
+
*/
|
| 29 |
+
public function testDefaultFormatter()
|
| 30 |
+
{
|
| 31 |
+
$formatter = new GelfMessageFormatter();
|
| 32 |
+
$record = array(
|
| 33 |
+
'level' => Logger::ERROR,
|
| 34 |
+
'level_name' => 'ERROR',
|
| 35 |
+
'channel' => 'meh',
|
| 36 |
+
'context' => array(),
|
| 37 |
+
'datetime' => new \DateTime("@0"),
|
| 38 |
+
'extra' => array(),
|
| 39 |
+
'message' => 'log',
|
| 40 |
+
);
|
| 41 |
+
|
| 42 |
+
$message = $formatter->format($record);
|
| 43 |
+
|
| 44 |
+
$this->assertInstanceOf('Gelf\Message', $message);
|
| 45 |
+
$this->assertEquals(0, $message->getTimestamp());
|
| 46 |
+
$this->assertEquals('log', $message->getShortMessage());
|
| 47 |
+
$this->assertEquals('meh', $message->getFacility());
|
| 48 |
+
$this->assertEquals(null, $message->getLine());
|
| 49 |
+
$this->assertEquals(null, $message->getFile());
|
| 50 |
+
$this->assertEquals(3, $message->getLevel());
|
| 51 |
+
$this->assertNotEmpty($message->getHost());
|
| 52 |
+
|
| 53 |
+
$formatter = new GelfMessageFormatter('mysystem');
|
| 54 |
+
|
| 55 |
+
$message = $formatter->format($record);
|
| 56 |
+
|
| 57 |
+
$this->assertInstanceOf('Gelf\Message', $message);
|
| 58 |
+
$this->assertEquals('mysystem', $message->getHost());
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* @covers Monolog\Formatter\GelfMessageFormatter::format
|
| 63 |
+
*/
|
| 64 |
+
public function testFormatWithFileAndLine()
|
| 65 |
+
{
|
| 66 |
+
$formatter = new GelfMessageFormatter();
|
| 67 |
+
$record = array(
|
| 68 |
+
'level' => Logger::ERROR,
|
| 69 |
+
'level_name' => 'ERROR',
|
| 70 |
+
'channel' => 'meh',
|
| 71 |
+
'context' => array('from' => 'logger'),
|
| 72 |
+
'datetime' => new \DateTime("@0"),
|
| 73 |
+
'extra' => array('file' => 'test', 'line' => 14),
|
| 74 |
+
'message' => 'log',
|
| 75 |
+
);
|
| 76 |
+
|
| 77 |
+
$message = $formatter->format($record);
|
| 78 |
+
|
| 79 |
+
$this->assertInstanceOf('Gelf\Message', $message);
|
| 80 |
+
$this->assertEquals('test', $message->getFile());
|
| 81 |
+
$this->assertEquals(14, $message->getLine());
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* @covers Monolog\Formatter\GelfMessageFormatter::format
|
| 86 |
+
*/
|
| 87 |
+
public function testFormatWithContext()
|
| 88 |
+
{
|
| 89 |
+
$formatter = new GelfMessageFormatter();
|
| 90 |
+
$record = array(
|
| 91 |
+
'level' => Logger::ERROR,
|
| 92 |
+
'level_name' => 'ERROR',
|
| 93 |
+
'channel' => 'meh',
|
| 94 |
+
'context' => array('from' => 'logger'),
|
| 95 |
+
'datetime' => new \DateTime("@0"),
|
| 96 |
+
'extra' => array('key' => 'pair'),
|
| 97 |
+
'message' => 'log'
|
| 98 |
+
);
|
| 99 |
+
|
| 100 |
+
$message = $formatter->format($record);
|
| 101 |
+
|
| 102 |
+
$this->assertInstanceOf('Gelf\Message', $message);
|
| 103 |
+
|
| 104 |
+
$message_array = $message->toArray();
|
| 105 |
+
|
| 106 |
+
$this->assertArrayHasKey('_ctxt_from', $message_array);
|
| 107 |
+
$this->assertEquals('logger', $message_array['_ctxt_from']);
|
| 108 |
+
|
| 109 |
+
// Test with extraPrefix
|
| 110 |
+
$formatter = new GelfMessageFormatter(null, null, 'CTX');
|
| 111 |
+
$message = $formatter->format($record);
|
| 112 |
+
|
| 113 |
+
$this->assertInstanceOf('Gelf\Message', $message);
|
| 114 |
+
|
| 115 |
+
$message_array = $message->toArray();
|
| 116 |
+
|
| 117 |
+
$this->assertArrayHasKey('_CTXfrom', $message_array);
|
| 118 |
+
$this->assertEquals('logger', $message_array['_CTXfrom']);
|
| 119 |
+
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
/**
|
| 123 |
+
* @covers Monolog\Formatter\GelfMessageFormatter::format
|
| 124 |
+
*/
|
| 125 |
+
public function testFormatWithExtra()
|
| 126 |
+
{
|
| 127 |
+
$formatter = new GelfMessageFormatter();
|
| 128 |
+
$record = array(
|
| 129 |
+
'level' => Logger::ERROR,
|
| 130 |
+
'level_name' => 'ERROR',
|
| 131 |
+
'channel' => 'meh',
|
| 132 |
+
'context' => array('from' => 'logger'),
|
| 133 |
+
'datetime' => new \DateTime("@0"),
|
| 134 |
+
'extra' => array('key' => 'pair'),
|
| 135 |
+
'message' => 'log'
|
| 136 |
+
);
|
| 137 |
+
|
| 138 |
+
$message = $formatter->format($record);
|
| 139 |
+
|
| 140 |
+
$this->assertInstanceOf('Gelf\Message', $message);
|
| 141 |
+
|
| 142 |
+
$message_array = $message->toArray();
|
| 143 |
+
|
| 144 |
+
$this->assertArrayHasKey('_key', $message_array);
|
| 145 |
+
$this->assertEquals('pair', $message_array['_key']);
|
| 146 |
+
|
| 147 |
+
// Test with extraPrefix
|
| 148 |
+
$formatter = new GelfMessageFormatter(null, 'EXT');
|
| 149 |
+
$message = $formatter->format($record);
|
| 150 |
+
|
| 151 |
+
$this->assertInstanceOf('Gelf\Message', $message);
|
| 152 |
+
|
| 153 |
+
$message_array = $message->toArray();
|
| 154 |
+
|
| 155 |
+
$this->assertArrayHasKey('_EXTkey', $message_array);
|
| 156 |
+
$this->assertEquals('pair', $message_array['_EXTkey']);
|
| 157 |
+
}
|
| 158 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Formatter;
|
| 13 |
+
|
| 14 |
+
use Monolog\Logger;
|
| 15 |
+
use Monolog\TestCase;
|
| 16 |
+
|
| 17 |
+
class JsonFormatterTest extends TestCase
|
| 18 |
+
{
|
| 19 |
+
/**
|
| 20 |
+
* @covers Monolog\Formatter\JsonFormatter::format
|
| 21 |
+
*/
|
| 22 |
+
public function testFormat()
|
| 23 |
+
{
|
| 24 |
+
$formatter = new JsonFormatter();
|
| 25 |
+
$record = $this->getRecord();
|
| 26 |
+
$this->assertEquals(json_encode($record), $formatter->format($record));
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* @covers Monolog\Formatter\JsonFormatter::formatBatch
|
| 31 |
+
*/
|
| 32 |
+
public function testFormatBatch()
|
| 33 |
+
{
|
| 34 |
+
$formatter = new JsonFormatter();
|
| 35 |
+
$records = array(
|
| 36 |
+
$this->getRecord(Logger::WARNING),
|
| 37 |
+
$this->getRecord(Logger::DEBUG),
|
| 38 |
+
);
|
| 39 |
+
$this->assertEquals(json_encode($records), $formatter->formatBatch($records));
|
| 40 |
+
}
|
| 41 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Formatter/LineFormatterTest.php
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Formatter;
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* @covers Monolog\Formatter\LineFormatter
|
| 16 |
+
*/
|
| 17 |
+
class LineFormatterTest extends \PHPUnit_Framework_TestCase
|
| 18 |
+
{
|
| 19 |
+
public function testDefFormatWithString()
|
| 20 |
+
{
|
| 21 |
+
$formatter = new LineFormatter(null, 'Y-m-d');
|
| 22 |
+
$message = $formatter->format(array(
|
| 23 |
+
'level_name' => 'WARNING',
|
| 24 |
+
'channel' => 'log',
|
| 25 |
+
'context' => array(),
|
| 26 |
+
'message' => 'foo',
|
| 27 |
+
'datetime' => new \DateTime,
|
| 28 |
+
'extra' => array(),
|
| 29 |
+
));
|
| 30 |
+
$this->assertEquals('['.date('Y-m-d').'] log.WARNING: foo [] []'."\n", $message);
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
public function testDefFormatWithArrayContext()
|
| 34 |
+
{
|
| 35 |
+
$formatter = new LineFormatter(null, 'Y-m-d');
|
| 36 |
+
$message = $formatter->format(array(
|
| 37 |
+
'level_name' => 'ERROR',
|
| 38 |
+
'channel' => 'meh',
|
| 39 |
+
'message' => 'foo',
|
| 40 |
+
'datetime' => new \DateTime,
|
| 41 |
+
'extra' => array(),
|
| 42 |
+
'context' => array(
|
| 43 |
+
'foo' => 'bar',
|
| 44 |
+
'baz' => 'qux',
|
| 45 |
+
)
|
| 46 |
+
));
|
| 47 |
+
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foo {"foo":"bar","baz":"qux"} []'."\n", $message);
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
public function testDefFormatExtras()
|
| 51 |
+
{
|
| 52 |
+
$formatter = new LineFormatter(null, 'Y-m-d');
|
| 53 |
+
$message = $formatter->format(array(
|
| 54 |
+
'level_name' => 'ERROR',
|
| 55 |
+
'channel' => 'meh',
|
| 56 |
+
'context' => array(),
|
| 57 |
+
'datetime' => new \DateTime,
|
| 58 |
+
'extra' => array('ip' => '127.0.0.1'),
|
| 59 |
+
'message' => 'log',
|
| 60 |
+
));
|
| 61 |
+
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log [] {"ip":"127.0.0.1"}'."\n", $message);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
public function testFormatExtras()
|
| 65 |
+
{
|
| 66 |
+
$formatter = new LineFormatter("[%datetime%] %channel%.%level_name%: %message% %context% %extra.file% %extra%\n", 'Y-m-d');
|
| 67 |
+
$message = $formatter->format(array(
|
| 68 |
+
'level_name' => 'ERROR',
|
| 69 |
+
'channel' => 'meh',
|
| 70 |
+
'context' => array(),
|
| 71 |
+
'datetime' => new \DateTime,
|
| 72 |
+
'extra' => array('ip' => '127.0.0.1', 'file' => 'test'),
|
| 73 |
+
'message' => 'log',
|
| 74 |
+
));
|
| 75 |
+
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log [] test {"ip":"127.0.0.1"}'."\n", $message);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
public function testDefFormatWithObject()
|
| 79 |
+
{
|
| 80 |
+
$formatter = new LineFormatter(null, 'Y-m-d');
|
| 81 |
+
$message = $formatter->format(array(
|
| 82 |
+
'level_name' => 'ERROR',
|
| 83 |
+
'channel' => 'meh',
|
| 84 |
+
'context' => array(),
|
| 85 |
+
'datetime' => new \DateTime,
|
| 86 |
+
'extra' => array('foo' => new TestFoo, 'bar' => new TestBar, 'baz' => array(), 'res' => fopen('php://memory', 'rb')),
|
| 87 |
+
'message' => 'foobar',
|
| 88 |
+
));
|
| 89 |
+
|
| 90 |
+
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foobar [] {"foo":"[object] (Monolog\\\\Formatter\\\\TestFoo: {\\"foo\\":\\"foo\\"})","bar":"[object] (Monolog\\\\Formatter\\\\TestBar: {})","baz":[],"res":"[resource]"}'."\n", $message);
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
public function testDefFormatWithException()
|
| 94 |
+
{
|
| 95 |
+
$formatter = new LineFormatter(null, 'Y-m-d');
|
| 96 |
+
$message = $formatter->format(array(
|
| 97 |
+
'level_name' => 'CRITICAL',
|
| 98 |
+
'channel' => 'core',
|
| 99 |
+
'context' => array('exception' => new \RuntimeException('Foo')),
|
| 100 |
+
'datetime' => new \DateTime,
|
| 101 |
+
'extra' => array(),
|
| 102 |
+
'message' => 'foobar',
|
| 103 |
+
));
|
| 104 |
+
|
| 105 |
+
$path = str_replace('\\/', '/', json_encode(__FILE__));
|
| 106 |
+
|
| 107 |
+
$this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException: Foo at '.substr($path, 1, -1).':'.(__LINE__-8).')"} []'."\n", $message);
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
public function testDefFormatWithPreviousException()
|
| 111 |
+
{
|
| 112 |
+
$formatter = new LineFormatter(null, 'Y-m-d');
|
| 113 |
+
$previous = new \LogicException('Wut?');
|
| 114 |
+
$message = $formatter->format(array(
|
| 115 |
+
'level_name' => 'CRITICAL',
|
| 116 |
+
'channel' => 'core',
|
| 117 |
+
'context' => array('exception' => new \RuntimeException('Foo', 0, $previous)),
|
| 118 |
+
'datetime' => new \DateTime,
|
| 119 |
+
'extra' => array(),
|
| 120 |
+
'message' => 'foobar',
|
| 121 |
+
));
|
| 122 |
+
|
| 123 |
+
$path = str_replace('\\/', '/', json_encode(__FILE__));
|
| 124 |
+
|
| 125 |
+
$this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException: Foo at '.substr($path, 1, -1).':'.(__LINE__-8).', LogicException: Wut? at '.substr($path, 1, -1).':'.(__LINE__-12).')"} []'."\n", $message);
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
public function testBatchFormat()
|
| 129 |
+
{
|
| 130 |
+
$formatter = new LineFormatter(null, 'Y-m-d');
|
| 131 |
+
$message = $formatter->formatBatch(array(
|
| 132 |
+
array(
|
| 133 |
+
'level_name' => 'CRITICAL',
|
| 134 |
+
'channel' => 'test',
|
| 135 |
+
'message' => 'bar',
|
| 136 |
+
'context' => array(),
|
| 137 |
+
'datetime' => new \DateTime,
|
| 138 |
+
'extra' => array(),
|
| 139 |
+
),
|
| 140 |
+
array(
|
| 141 |
+
'level_name' => 'WARNING',
|
| 142 |
+
'channel' => 'log',
|
| 143 |
+
'message' => 'foo',
|
| 144 |
+
'context' => array(),
|
| 145 |
+
'datetime' => new \DateTime,
|
| 146 |
+
'extra' => array(),
|
| 147 |
+
),
|
| 148 |
+
));
|
| 149 |
+
$this->assertEquals('['.date('Y-m-d').'] test.CRITICAL: bar [] []'."\n".'['.date('Y-m-d').'] log.WARNING: foo [] []'."\n", $message);
|
| 150 |
+
}
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
class TestFoo
|
| 154 |
+
{
|
| 155 |
+
public $foo = 'foo';
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
class TestBar
|
| 159 |
+
{
|
| 160 |
+
public function __toString()
|
| 161 |
+
{
|
| 162 |
+
return 'bar';
|
| 163 |
+
}
|
| 164 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Formatter/LogstashFormatterTest.php
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Formatter;
|
| 13 |
+
|
| 14 |
+
use Monolog\Logger;
|
| 15 |
+
use Monolog\Formatter\LogstashFormatter;
|
| 16 |
+
|
| 17 |
+
class LogstashFormatterTest extends \PHPUnit_Framework_TestCase
|
| 18 |
+
{
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* @covers Monolog\Formatter\LogstashFormatter::format
|
| 22 |
+
*/
|
| 23 |
+
public function testDefaultFormatter()
|
| 24 |
+
{
|
| 25 |
+
$formatter = new LogstashFormatter('test', 'hostname');
|
| 26 |
+
$record = array(
|
| 27 |
+
'level' => Logger::ERROR,
|
| 28 |
+
'level_name' => 'ERROR',
|
| 29 |
+
'channel' => 'meh',
|
| 30 |
+
'context' => array(),
|
| 31 |
+
'datetime' => new \DateTime("@0"),
|
| 32 |
+
'extra' => array(),
|
| 33 |
+
'message' => 'log',
|
| 34 |
+
);
|
| 35 |
+
|
| 36 |
+
$message = json_decode($formatter->format($record), true);
|
| 37 |
+
|
| 38 |
+
$this->assertEquals("1970-01-01T00:00:00+00:00", $message['@timestamp']);
|
| 39 |
+
$this->assertEquals('log', $message['@message']);
|
| 40 |
+
$this->assertEquals('meh', $message['@fields']['channel']);
|
| 41 |
+
$this->assertContains('meh', $message['@tags']);
|
| 42 |
+
$this->assertEquals(Logger::ERROR, $message['@fields']['level']);
|
| 43 |
+
$this->assertEquals('test', $message['@type']);
|
| 44 |
+
$this->assertEquals('hostname', $message['@source']);
|
| 45 |
+
|
| 46 |
+
$formatter = new LogstashFormatter('mysystem');
|
| 47 |
+
|
| 48 |
+
$message = json_decode($formatter->format($record), true);
|
| 49 |
+
|
| 50 |
+
$this->assertEquals('mysystem', $message['@type']);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* @covers Monolog\Formatter\LogstashFormatter::format
|
| 55 |
+
*/
|
| 56 |
+
public function testFormatWithFileAndLine()
|
| 57 |
+
{
|
| 58 |
+
$formatter = new LogstashFormatter('test');
|
| 59 |
+
$record = array(
|
| 60 |
+
'level' => Logger::ERROR,
|
| 61 |
+
'level_name' => 'ERROR',
|
| 62 |
+
'channel' => 'meh',
|
| 63 |
+
'context' => array('from' => 'logger'),
|
| 64 |
+
'datetime' => new \DateTime("@0"),
|
| 65 |
+
'extra' => array('file' => 'test', 'line' => 14),
|
| 66 |
+
'message' => 'log',
|
| 67 |
+
);
|
| 68 |
+
|
| 69 |
+
$message = json_decode($formatter->format($record), true);
|
| 70 |
+
|
| 71 |
+
$this->assertEquals('test', $message['@fields']['file']);
|
| 72 |
+
$this->assertEquals(14, $message['@fields']['line']);
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
/**
|
| 76 |
+
* @covers Monolog\Formatter\LogstashFormatter::format
|
| 77 |
+
*/
|
| 78 |
+
public function testFormatWithContext()
|
| 79 |
+
{
|
| 80 |
+
$formatter = new LogstashFormatter('test');
|
| 81 |
+
$record = array(
|
| 82 |
+
'level' => Logger::ERROR,
|
| 83 |
+
'level_name' => 'ERROR',
|
| 84 |
+
'channel' => 'meh',
|
| 85 |
+
'context' => array('from' => 'logger'),
|
| 86 |
+
'datetime' => new \DateTime("@0"),
|
| 87 |
+
'extra' => array('key' => 'pair'),
|
| 88 |
+
'message' => 'log'
|
| 89 |
+
);
|
| 90 |
+
|
| 91 |
+
$message = json_decode($formatter->format($record), true);
|
| 92 |
+
|
| 93 |
+
$message_array = $message['@fields'];
|
| 94 |
+
|
| 95 |
+
$this->assertArrayHasKey('ctxt_from', $message_array);
|
| 96 |
+
$this->assertEquals('logger', $message_array['ctxt_from']);
|
| 97 |
+
|
| 98 |
+
// Test with extraPrefix
|
| 99 |
+
$formatter = new LogstashFormatter('test', null, null, 'CTX');
|
| 100 |
+
$message = json_decode($formatter->format($record), true);
|
| 101 |
+
|
| 102 |
+
$message_array = $message['@fields'];
|
| 103 |
+
|
| 104 |
+
$this->assertArrayHasKey('CTXfrom', $message_array);
|
| 105 |
+
$this->assertEquals('logger', $message_array['CTXfrom']);
|
| 106 |
+
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
/**
|
| 110 |
+
* @covers Monolog\Formatter\LogstashFormatter::format
|
| 111 |
+
*/
|
| 112 |
+
public function testFormatWithExtra()
|
| 113 |
+
{
|
| 114 |
+
$formatter = new LogstashFormatter('test');
|
| 115 |
+
$record = array(
|
| 116 |
+
'level' => Logger::ERROR,
|
| 117 |
+
'level_name' => 'ERROR',
|
| 118 |
+
'channel' => 'meh',
|
| 119 |
+
'context' => array('from' => 'logger'),
|
| 120 |
+
'datetime' => new \DateTime("@0"),
|
| 121 |
+
'extra' => array('key' => 'pair'),
|
| 122 |
+
'message' => 'log'
|
| 123 |
+
);
|
| 124 |
+
|
| 125 |
+
$message = json_decode($formatter->format($record), true);
|
| 126 |
+
|
| 127 |
+
$message_array = $message['@fields'];
|
| 128 |
+
|
| 129 |
+
$this->assertArrayHasKey('key', $message_array);
|
| 130 |
+
$this->assertEquals('pair', $message_array['key']);
|
| 131 |
+
|
| 132 |
+
// Test with extraPrefix
|
| 133 |
+
$formatter = new LogstashFormatter('test', null, 'EXT');
|
| 134 |
+
$message = json_decode($formatter->format($record), true);
|
| 135 |
+
|
| 136 |
+
$message_array = $message['@fields'];
|
| 137 |
+
|
| 138 |
+
$this->assertArrayHasKey('EXTkey', $message_array);
|
| 139 |
+
$this->assertEquals('pair', $message_array['EXTkey']);
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
public function testFormatWithApplicationName()
|
| 143 |
+
{
|
| 144 |
+
$formatter = new LogstashFormatter('app', 'test');
|
| 145 |
+
$record = array(
|
| 146 |
+
'level' => Logger::ERROR,
|
| 147 |
+
'level_name' => 'ERROR',
|
| 148 |
+
'channel' => 'meh',
|
| 149 |
+
'context' => array('from' => 'logger'),
|
| 150 |
+
'datetime' => new \DateTime("@0"),
|
| 151 |
+
'extra' => array('key' => 'pair'),
|
| 152 |
+
'message' => 'log'
|
| 153 |
+
);
|
| 154 |
+
|
| 155 |
+
$message = json_decode($formatter->format($record), true);
|
| 156 |
+
|
| 157 |
+
$this->assertArrayHasKey('@type', $message);
|
| 158 |
+
$this->assertEquals('app', $message['@type']);
|
| 159 |
+
}
|
| 160 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Formatter;
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* @covers Monolog\Formatter\NormalizerFormatter
|
| 16 |
+
*/
|
| 17 |
+
class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
|
| 18 |
+
{
|
| 19 |
+
public function testFormat()
|
| 20 |
+
{
|
| 21 |
+
$formatter = new NormalizerFormatter('Y-m-d');
|
| 22 |
+
$formatted = $formatter->format(array(
|
| 23 |
+
'level_name' => 'ERROR',
|
| 24 |
+
'channel' => 'meh',
|
| 25 |
+
'message' => 'foo',
|
| 26 |
+
'datetime' => new \DateTime,
|
| 27 |
+
'extra' => array('foo' => new TestFooNorm, 'bar' => new TestBarNorm, 'baz' => array(), 'res' => fopen('php://memory', 'rb')),
|
| 28 |
+
'context' => array(
|
| 29 |
+
'foo' => 'bar',
|
| 30 |
+
'baz' => 'qux',
|
| 31 |
+
)
|
| 32 |
+
));
|
| 33 |
+
|
| 34 |
+
$this->assertEquals(array(
|
| 35 |
+
'level_name' => 'ERROR',
|
| 36 |
+
'channel' => 'meh',
|
| 37 |
+
'message' => 'foo',
|
| 38 |
+
'datetime' => date('Y-m-d'),
|
| 39 |
+
'extra' => array(
|
| 40 |
+
'foo' => '[object] (Monolog\\Formatter\\TestFooNorm: {"foo":"foo"})',
|
| 41 |
+
'bar' => '[object] (Monolog\\Formatter\\TestBarNorm: {})',
|
| 42 |
+
'baz' => array(),
|
| 43 |
+
'res' => '[resource]',
|
| 44 |
+
),
|
| 45 |
+
'context' => array(
|
| 46 |
+
'foo' => 'bar',
|
| 47 |
+
'baz' => 'qux',
|
| 48 |
+
)
|
| 49 |
+
), $formatted);
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
public function testBatchFormat()
|
| 53 |
+
{
|
| 54 |
+
$formatter = new NormalizerFormatter('Y-m-d');
|
| 55 |
+
$formatted = $formatter->formatBatch(array(
|
| 56 |
+
array(
|
| 57 |
+
'level_name' => 'CRITICAL',
|
| 58 |
+
'channel' => 'test',
|
| 59 |
+
'message' => 'bar',
|
| 60 |
+
'context' => array(),
|
| 61 |
+
'datetime' => new \DateTime,
|
| 62 |
+
'extra' => array(),
|
| 63 |
+
),
|
| 64 |
+
array(
|
| 65 |
+
'level_name' => 'WARNING',
|
| 66 |
+
'channel' => 'log',
|
| 67 |
+
'message' => 'foo',
|
| 68 |
+
'context' => array(),
|
| 69 |
+
'datetime' => new \DateTime,
|
| 70 |
+
'extra' => array(),
|
| 71 |
+
),
|
| 72 |
+
));
|
| 73 |
+
$this->assertEquals(array(
|
| 74 |
+
array(
|
| 75 |
+
'level_name' => 'CRITICAL',
|
| 76 |
+
'channel' => 'test',
|
| 77 |
+
'message' => 'bar',
|
| 78 |
+
'context' => array(),
|
| 79 |
+
'datetime' => date('Y-m-d'),
|
| 80 |
+
'extra' => array(),
|
| 81 |
+
),
|
| 82 |
+
array(
|
| 83 |
+
'level_name' => 'WARNING',
|
| 84 |
+
'channel' => 'log',
|
| 85 |
+
'message' => 'foo',
|
| 86 |
+
'context' => array(),
|
| 87 |
+
'datetime' => date('Y-m-d'),
|
| 88 |
+
'extra' => array(),
|
| 89 |
+
),
|
| 90 |
+
), $formatted);
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
/**
|
| 94 |
+
* Test issue #137
|
| 95 |
+
*/
|
| 96 |
+
public function testIgnoresRecursiveObjectReferences()
|
| 97 |
+
{
|
| 98 |
+
// set up the recursion
|
| 99 |
+
$foo = new \stdClass();
|
| 100 |
+
$bar = new \stdClass();
|
| 101 |
+
|
| 102 |
+
$foo->bar = $bar;
|
| 103 |
+
$bar->foo = $foo;
|
| 104 |
+
|
| 105 |
+
// set an error handler to assert that the error is not raised anymore
|
| 106 |
+
$that = $this;
|
| 107 |
+
set_error_handler(function ($level, $message, $file, $line, $context) use ($that) {
|
| 108 |
+
if (error_reporting() & $level) {
|
| 109 |
+
restore_error_handler();
|
| 110 |
+
$that->fail("$message should not be raised");
|
| 111 |
+
}
|
| 112 |
+
});
|
| 113 |
+
|
| 114 |
+
$formatter = new NormalizerFormatter();
|
| 115 |
+
$reflMethod = new \ReflectionMethod($formatter, 'toJson');
|
| 116 |
+
$reflMethod->setAccessible(true);
|
| 117 |
+
$res = $reflMethod->invoke($formatter, array($foo, $bar), true);
|
| 118 |
+
|
| 119 |
+
restore_error_handler();
|
| 120 |
+
|
| 121 |
+
$this->assertEquals(@json_encode(array($foo, $bar)), $res);
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
public function testIgnoresInvalidTypes()
|
| 125 |
+
{
|
| 126 |
+
// set up the recursion
|
| 127 |
+
$resource = fopen(__FILE__, 'r');
|
| 128 |
+
|
| 129 |
+
// set an error handler to assert that the error is not raised anymore
|
| 130 |
+
$that = $this;
|
| 131 |
+
set_error_handler(function ($level, $message, $file, $line, $context) use ($that) {
|
| 132 |
+
if (error_reporting() & $level) {
|
| 133 |
+
restore_error_handler();
|
| 134 |
+
$that->fail("$message should not be raised");
|
| 135 |
+
}
|
| 136 |
+
});
|
| 137 |
+
|
| 138 |
+
$formatter = new NormalizerFormatter();
|
| 139 |
+
$reflMethod = new \ReflectionMethod($formatter, 'toJson');
|
| 140 |
+
$reflMethod->setAccessible(true);
|
| 141 |
+
$res = $reflMethod->invoke($formatter, array($resource), true);
|
| 142 |
+
|
| 143 |
+
restore_error_handler();
|
| 144 |
+
|
| 145 |
+
$this->assertEquals(@json_encode(array($resource)), $res);
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
class TestFooNorm
|
| 150 |
+
{
|
| 151 |
+
public $foo = 'foo';
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
class TestBarNorm
|
| 155 |
+
{
|
| 156 |
+
public function __toString()
|
| 157 |
+
{
|
| 158 |
+
return 'bar';
|
| 159 |
+
}
|
| 160 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Formatter/WildfireFormatterTest.php
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Formatter;
|
| 13 |
+
|
| 14 |
+
use Monolog\Logger;
|
| 15 |
+
|
| 16 |
+
class WildfireFormatterTest extends \PHPUnit_Framework_TestCase
|
| 17 |
+
{
|
| 18 |
+
/**
|
| 19 |
+
* @covers Monolog\Formatter\WildfireFormatter::format
|
| 20 |
+
*/
|
| 21 |
+
public function testDefaultFormat()
|
| 22 |
+
{
|
| 23 |
+
$wildfire = new WildfireFormatter();
|
| 24 |
+
$record = array(
|
| 25 |
+
'level' => Logger::ERROR,
|
| 26 |
+
'level_name' => 'ERROR',
|
| 27 |
+
'channel' => 'meh',
|
| 28 |
+
'context' => array('from' => 'logger'),
|
| 29 |
+
'datetime' => new \DateTime("@0"),
|
| 30 |
+
'extra' => array('ip' => '127.0.0.1'),
|
| 31 |
+
'message' => 'log',
|
| 32 |
+
);
|
| 33 |
+
|
| 34 |
+
$message = $wildfire->format($record);
|
| 35 |
+
|
| 36 |
+
$this->assertEquals(
|
| 37 |
+
'125|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},'
|
| 38 |
+
.'{"message":"log","context":{"from":"logger"},"extra":{"ip":"127.0.0.1"}}]|',
|
| 39 |
+
$message
|
| 40 |
+
);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* @covers Monolog\Formatter\WildfireFormatter::format
|
| 45 |
+
*/
|
| 46 |
+
public function testFormatWithFileAndLine()
|
| 47 |
+
{
|
| 48 |
+
$wildfire = new WildfireFormatter();
|
| 49 |
+
$record = array(
|
| 50 |
+
'level' => Logger::ERROR,
|
| 51 |
+
'level_name' => 'ERROR',
|
| 52 |
+
'channel' => 'meh',
|
| 53 |
+
'context' => array('from' => 'logger'),
|
| 54 |
+
'datetime' => new \DateTime("@0"),
|
| 55 |
+
'extra' => array('ip' => '127.0.0.1', 'file' => 'test', 'line' => 14),
|
| 56 |
+
'message' => 'log',
|
| 57 |
+
);
|
| 58 |
+
|
| 59 |
+
$message = $wildfire->format($record);
|
| 60 |
+
|
| 61 |
+
$this->assertEquals(
|
| 62 |
+
'129|[{"Type":"ERROR","File":"test","Line":14,"Label":"meh"},'
|
| 63 |
+
.'{"message":"log","context":{"from":"logger"},"extra":{"ip":"127.0.0.1"}}]|',
|
| 64 |
+
$message
|
| 65 |
+
);
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* @covers Monolog\Formatter\WildfireFormatter::format
|
| 70 |
+
*/
|
| 71 |
+
public function testFormatWithoutContext()
|
| 72 |
+
{
|
| 73 |
+
$wildfire = new WildfireFormatter();
|
| 74 |
+
$record = array(
|
| 75 |
+
'level' => Logger::ERROR,
|
| 76 |
+
'level_name' => 'ERROR',
|
| 77 |
+
'channel' => 'meh',
|
| 78 |
+
'context' => array(),
|
| 79 |
+
'datetime' => new \DateTime("@0"),
|
| 80 |
+
'extra' => array(),
|
| 81 |
+
'message' => 'log',
|
| 82 |
+
);
|
| 83 |
+
|
| 84 |
+
$message = $wildfire->format($record);
|
| 85 |
+
|
| 86 |
+
$this->assertEquals(
|
| 87 |
+
'58|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},"log"]|',
|
| 88 |
+
$message
|
| 89 |
+
);
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
/**
|
| 93 |
+
* @covers Monolog\Formatter\WildfireFormatter::formatBatch
|
| 94 |
+
* @expectedException BadMethodCallException
|
| 95 |
+
*/
|
| 96 |
+
public function testBatchFormatThrowException()
|
| 97 |
+
{
|
| 98 |
+
$wildfire = new WildfireFormatter();
|
| 99 |
+
$record = array(
|
| 100 |
+
'level' => Logger::ERROR,
|
| 101 |
+
'level_name' => 'ERROR',
|
| 102 |
+
'channel' => 'meh',
|
| 103 |
+
'context' => array(),
|
| 104 |
+
'datetime' => new \DateTime("@0"),
|
| 105 |
+
'extra' => array(),
|
| 106 |
+
'message' => 'log',
|
| 107 |
+
);
|
| 108 |
+
|
| 109 |
+
$wildfire->formatBatch(array($record));
|
| 110 |
+
}
|
| 111 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/AbstractHandlerTest.php
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\TestCase;
|
| 15 |
+
use Monolog\Logger;
|
| 16 |
+
use Monolog\Formatter\LineFormatter;
|
| 17 |
+
use Monolog\Processor\WebProcessor;
|
| 18 |
+
|
| 19 |
+
class AbstractHandlerTest extends TestCase
|
| 20 |
+
{
|
| 21 |
+
/**
|
| 22 |
+
* @covers Monolog\Handler\AbstractHandler::__construct
|
| 23 |
+
* @covers Monolog\Handler\AbstractHandler::getLevel
|
| 24 |
+
* @covers Monolog\Handler\AbstractHandler::setLevel
|
| 25 |
+
* @covers Monolog\Handler\AbstractHandler::getBubble
|
| 26 |
+
* @covers Monolog\Handler\AbstractHandler::setBubble
|
| 27 |
+
* @covers Monolog\Handler\AbstractHandler::getFormatter
|
| 28 |
+
* @covers Monolog\Handler\AbstractHandler::setFormatter
|
| 29 |
+
*/
|
| 30 |
+
public function testConstructAndGetSet()
|
| 31 |
+
{
|
| 32 |
+
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false));
|
| 33 |
+
$this->assertEquals(Logger::WARNING, $handler->getLevel());
|
| 34 |
+
$this->assertEquals(false, $handler->getBubble());
|
| 35 |
+
|
| 36 |
+
$handler->setLevel(Logger::ERROR);
|
| 37 |
+
$handler->setBubble(true);
|
| 38 |
+
$handler->setFormatter($formatter = new LineFormatter);
|
| 39 |
+
$this->assertEquals(Logger::ERROR, $handler->getLevel());
|
| 40 |
+
$this->assertEquals(true, $handler->getBubble());
|
| 41 |
+
$this->assertSame($formatter, $handler->getFormatter());
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* @covers Monolog\Handler\AbstractHandler::handleBatch
|
| 46 |
+
*/
|
| 47 |
+
public function testHandleBatch()
|
| 48 |
+
{
|
| 49 |
+
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
|
| 50 |
+
$handler->expects($this->exactly(2))
|
| 51 |
+
->method('handle');
|
| 52 |
+
$handler->handleBatch(array($this->getRecord(), $this->getRecord()));
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* @covers Monolog\Handler\AbstractHandler::isHandling
|
| 57 |
+
*/
|
| 58 |
+
public function testIsHandling()
|
| 59 |
+
{
|
| 60 |
+
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false));
|
| 61 |
+
$this->assertTrue($handler->isHandling($this->getRecord()));
|
| 62 |
+
$this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* @covers Monolog\Handler\AbstractHandler::getFormatter
|
| 67 |
+
* @covers Monolog\Handler\AbstractHandler::getDefaultFormatter
|
| 68 |
+
*/
|
| 69 |
+
public function testGetFormatterInitializesDefault()
|
| 70 |
+
{
|
| 71 |
+
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
|
| 72 |
+
$this->assertInstanceOf('Monolog\Formatter\LineFormatter', $handler->getFormatter());
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
/**
|
| 76 |
+
* @covers Monolog\Handler\AbstractHandler::pushProcessor
|
| 77 |
+
* @covers Monolog\Handler\AbstractHandler::popProcessor
|
| 78 |
+
* @expectedException LogicException
|
| 79 |
+
*/
|
| 80 |
+
public function testPushPopProcessor()
|
| 81 |
+
{
|
| 82 |
+
$logger = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
|
| 83 |
+
$processor1 = new WebProcessor;
|
| 84 |
+
$processor2 = new WebProcessor;
|
| 85 |
+
|
| 86 |
+
$logger->pushProcessor($processor1);
|
| 87 |
+
$logger->pushProcessor($processor2);
|
| 88 |
+
|
| 89 |
+
$this->assertEquals($processor2, $logger->popProcessor());
|
| 90 |
+
$this->assertEquals($processor1, $logger->popProcessor());
|
| 91 |
+
$logger->popProcessor();
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
* @covers Monolog\Handler\AbstractHandler::pushProcessor
|
| 96 |
+
* @expectedException InvalidArgumentException
|
| 97 |
+
*/
|
| 98 |
+
public function testPushProcessorWithNonCallable()
|
| 99 |
+
{
|
| 100 |
+
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
|
| 101 |
+
|
| 102 |
+
$handler->pushProcessor(new \stdClass());
|
| 103 |
+
}
|
| 104 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\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 |
+
)));
|
| 69 |
+
$handledRecord = null;
|
| 70 |
+
$handler->expects($this->once())
|
| 71 |
+
->method('write')
|
| 72 |
+
->will($this->returnCallback(function($record) use (&$handledRecord) {
|
| 73 |
+
$handledRecord = $record;
|
| 74 |
+
}))
|
| 75 |
+
;
|
| 76 |
+
$handler->handle($this->getRecord());
|
| 77 |
+
$this->assertEquals(5, count($handledRecord['extra']));
|
| 78 |
+
}
|
| 79 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/AmqpExchangeMock.php
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
class AmqpExchangeMock extends \AMQPExchange
|
| 15 |
+
{
|
| 16 |
+
protected $messages = array();
|
| 17 |
+
|
| 18 |
+
public function __construct()
|
| 19 |
+
{
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
public function publish($message, $routing_key, $params = 0, $attributes = array())
|
| 23 |
+
{
|
| 24 |
+
$this->messages[] = array($message, $routing_key, $params, $attributes);
|
| 25 |
+
|
| 26 |
+
return true;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
public function getMessages()
|
| 30 |
+
{
|
| 31 |
+
return $this->messages;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
public function setName($name)
|
| 35 |
+
{
|
| 36 |
+
return true;
|
| 37 |
+
}
|
| 38 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/AmqpHandlerTest.php
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\TestCase;
|
| 15 |
+
use Monolog\Logger;
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* @covers Monolog\Handler\RotatingFileHandler
|
| 19 |
+
*/
|
| 20 |
+
class AmqpHandlerTest extends TestCase
|
| 21 |
+
{
|
| 22 |
+
public function setUp()
|
| 23 |
+
{
|
| 24 |
+
if (!class_exists('AMQPConnection') || !class_exists('AMQPExchange')) {
|
| 25 |
+
$this->markTestSkipped("amqp-php not installed");
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
if (!class_exists('AMQPChannel')) {
|
| 29 |
+
$this->markTestSkipped("Please update AMQP to version >= 1.0");
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
public function testHandle()
|
| 34 |
+
{
|
| 35 |
+
$exchange = $this->getExchange();
|
| 36 |
+
|
| 37 |
+
$handler = new AmqpHandler($exchange, 'log');
|
| 38 |
+
|
| 39 |
+
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
| 40 |
+
|
| 41 |
+
$expected = array(
|
| 42 |
+
array(
|
| 43 |
+
'message' => 'test',
|
| 44 |
+
'context' => array(
|
| 45 |
+
'data' => array(),
|
| 46 |
+
'foo' => 34,
|
| 47 |
+
),
|
| 48 |
+
'level' => 300,
|
| 49 |
+
'level_name' => 'WARNING',
|
| 50 |
+
'channel' => 'test',
|
| 51 |
+
'extra' => array(),
|
| 52 |
+
),
|
| 53 |
+
'warn.test',
|
| 54 |
+
0,
|
| 55 |
+
array(
|
| 56 |
+
'delivery_mode' => 2,
|
| 57 |
+
'Content-type' => 'application/json'
|
| 58 |
+
)
|
| 59 |
+
);
|
| 60 |
+
|
| 61 |
+
$handler->handle($record);
|
| 62 |
+
|
| 63 |
+
$messages = $exchange->getMessages();
|
| 64 |
+
$this->assertCount(1, $messages);
|
| 65 |
+
$messages[0][0] = json_decode($messages[0][0], true);
|
| 66 |
+
unset($messages[0][0]['datetime']);
|
| 67 |
+
$this->assertEquals($expected, $messages[0]);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
protected function getExchange()
|
| 71 |
+
{
|
| 72 |
+
return new AmqpExchangeMock();
|
| 73 |
+
}
|
| 74 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/BufferHandlerTest.php
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\TestCase;
|
| 15 |
+
use Monolog\Logger;
|
| 16 |
+
|
| 17 |
+
class BufferHandlerTest extends TestCase
|
| 18 |
+
{
|
| 19 |
+
/**
|
| 20 |
+
* @covers Monolog\Handler\BufferHandler::__construct
|
| 21 |
+
* @covers Monolog\Handler\BufferHandler::handle
|
| 22 |
+
* @covers Monolog\Handler\BufferHandler::close
|
| 23 |
+
*/
|
| 24 |
+
public function testHandleBuffers()
|
| 25 |
+
{
|
| 26 |
+
$test = new TestHandler();
|
| 27 |
+
$handler = new BufferHandler($test);
|
| 28 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 29 |
+
$handler->handle($this->getRecord(Logger::INFO));
|
| 30 |
+
$this->assertFalse($test->hasDebugRecords());
|
| 31 |
+
$this->assertFalse($test->hasInfoRecords());
|
| 32 |
+
$handler->close();
|
| 33 |
+
$this->assertTrue($test->hasInfoRecords());
|
| 34 |
+
$this->assertTrue(count($test->getRecords()) === 2);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* @covers Monolog\Handler\BufferHandler::close
|
| 39 |
+
* @covers Monolog\Handler\BufferHandler::flush
|
| 40 |
+
*/
|
| 41 |
+
public function testDestructPropagatesRecords()
|
| 42 |
+
{
|
| 43 |
+
$test = new TestHandler();
|
| 44 |
+
$handler = new BufferHandler($test);
|
| 45 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 46 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 47 |
+
$handler->__destruct();
|
| 48 |
+
$this->assertTrue($test->hasWarningRecords());
|
| 49 |
+
$this->assertTrue($test->hasDebugRecords());
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
/**
|
| 53 |
+
* @covers Monolog\Handler\BufferHandler::handle
|
| 54 |
+
*/
|
| 55 |
+
public function testHandleBufferLimit()
|
| 56 |
+
{
|
| 57 |
+
$test = new TestHandler();
|
| 58 |
+
$handler = new BufferHandler($test, 2);
|
| 59 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 60 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 61 |
+
$handler->handle($this->getRecord(Logger::INFO));
|
| 62 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 63 |
+
$handler->close();
|
| 64 |
+
$this->assertTrue($test->hasWarningRecords());
|
| 65 |
+
$this->assertTrue($test->hasInfoRecords());
|
| 66 |
+
$this->assertFalse($test->hasDebugRecords());
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* @covers Monolog\Handler\BufferHandler::handle
|
| 71 |
+
*/
|
| 72 |
+
public function testHandleBufferLimitWithFlushOnOverflow()
|
| 73 |
+
{
|
| 74 |
+
$test = new TestHandler();
|
| 75 |
+
$handler = new BufferHandler($test, 3, Logger::DEBUG, true, true);
|
| 76 |
+
|
| 77 |
+
// send two records
|
| 78 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 79 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 80 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 81 |
+
$this->assertFalse($test->hasDebugRecords());
|
| 82 |
+
$this->assertCount(0, $test->getRecords());
|
| 83 |
+
|
| 84 |
+
// overflow
|
| 85 |
+
$handler->handle($this->getRecord(Logger::INFO));
|
| 86 |
+
$this->assertTrue($test->hasDebugRecords());
|
| 87 |
+
$this->assertCount(3, $test->getRecords());
|
| 88 |
+
|
| 89 |
+
// should buffer again
|
| 90 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 91 |
+
$this->assertCount(3, $test->getRecords());
|
| 92 |
+
|
| 93 |
+
$handler->close();
|
| 94 |
+
$this->assertCount(5, $test->getRecords());
|
| 95 |
+
$this->assertTrue($test->hasWarningRecords());
|
| 96 |
+
$this->assertTrue($test->hasInfoRecords());
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
* @covers Monolog\Handler\BufferHandler::handle
|
| 101 |
+
*/
|
| 102 |
+
public function testHandleLevel()
|
| 103 |
+
{
|
| 104 |
+
$test = new TestHandler();
|
| 105 |
+
$handler = new BufferHandler($test, 0, Logger::INFO);
|
| 106 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 107 |
+
$handler->handle($this->getRecord(Logger::INFO));
|
| 108 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 109 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 110 |
+
$handler->close();
|
| 111 |
+
$this->assertTrue($test->hasWarningRecords());
|
| 112 |
+
$this->assertTrue($test->hasInfoRecords());
|
| 113 |
+
$this->assertFalse($test->hasDebugRecords());
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
/**
|
| 117 |
+
* @covers Monolog\Handler\BufferHandler::flush
|
| 118 |
+
*/
|
| 119 |
+
public function testFlush()
|
| 120 |
+
{
|
| 121 |
+
$test = new TestHandler();
|
| 122 |
+
$handler = new BufferHandler($test, 0);
|
| 123 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 124 |
+
$handler->handle($this->getRecord(Logger::INFO));
|
| 125 |
+
$handler->flush();
|
| 126 |
+
$this->assertTrue($test->hasInfoRecords());
|
| 127 |
+
$this->assertTrue($test->hasDebugRecords());
|
| 128 |
+
$this->assertFalse($test->hasWarningRecords());
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
/**
|
| 132 |
+
* @covers Monolog\Handler\BufferHandler::handle
|
| 133 |
+
*/
|
| 134 |
+
public function testHandleUsesProcessors()
|
| 135 |
+
{
|
| 136 |
+
$test = new TestHandler();
|
| 137 |
+
$handler = new BufferHandler($test);
|
| 138 |
+
$handler->pushProcessor(function ($record) {
|
| 139 |
+
$record['extra']['foo'] = true;
|
| 140 |
+
|
| 141 |
+
return $record;
|
| 142 |
+
});
|
| 143 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 144 |
+
$handler->flush();
|
| 145 |
+
$this->assertTrue($test->hasWarningRecords());
|
| 146 |
+
$records = $test->getRecords();
|
| 147 |
+
$this->assertTrue($records[0]['extra']['foo']);
|
| 148 |
+
}
|
| 149 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\TestCase;
|
| 15 |
+
use Monolog\Logger;
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* @covers Monolog\Handler\ChromePHPHandler
|
| 19 |
+
*/
|
| 20 |
+
class ChromePHPHandlerTest extends TestCase
|
| 21 |
+
{
|
| 22 |
+
protected function setUp()
|
| 23 |
+
{
|
| 24 |
+
TestChromePHPHandler::reset();
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
public function testHeaders()
|
| 28 |
+
{
|
| 29 |
+
$handler = new TestChromePHPHandler();
|
| 30 |
+
$handler->setFormatter($this->getIdentityFormatter());
|
| 31 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 32 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 33 |
+
|
| 34 |
+
$expected = array(
|
| 35 |
+
'X-ChromePhp-Data' => base64_encode(utf8_encode(json_encode(array(
|
| 36 |
+
'version' => ChromePHPHandler::VERSION,
|
| 37 |
+
'columns' => array('label', 'log', 'backtrace', 'type'),
|
| 38 |
+
'rows' => array(
|
| 39 |
+
'test',
|
| 40 |
+
'test',
|
| 41 |
+
),
|
| 42 |
+
'request_uri' => '',
|
| 43 |
+
))))
|
| 44 |
+
);
|
| 45 |
+
|
| 46 |
+
$this->assertEquals($expected, $handler->getHeaders());
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
public function testHeadersOverflow()
|
| 50 |
+
{
|
| 51 |
+
$handler = new TestChromePHPHandler();
|
| 52 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 53 |
+
$handler->handle($this->getRecord(Logger::WARNING, str_repeat('a', 150*1024)));
|
| 54 |
+
|
| 55 |
+
// overflow chrome headers limit
|
| 56 |
+
$handler->handle($this->getRecord(Logger::WARNING, str_repeat('a', 100*1024)));
|
| 57 |
+
|
| 58 |
+
$expected = array(
|
| 59 |
+
'X-ChromePhp-Data' => base64_encode(utf8_encode(json_encode(array(
|
| 60 |
+
'version' => ChromePHPHandler::VERSION,
|
| 61 |
+
'columns' => array('label', 'log', 'backtrace', 'type'),
|
| 62 |
+
'rows' => array(
|
| 63 |
+
array(
|
| 64 |
+
'test',
|
| 65 |
+
'test',
|
| 66 |
+
'unknown',
|
| 67 |
+
'log',
|
| 68 |
+
),
|
| 69 |
+
array(
|
| 70 |
+
'test',
|
| 71 |
+
str_repeat('a', 150*1024),
|
| 72 |
+
'unknown',
|
| 73 |
+
'warn',
|
| 74 |
+
),
|
| 75 |
+
array(
|
| 76 |
+
'monolog',
|
| 77 |
+
'Incomplete logs, chrome header size limit reached',
|
| 78 |
+
'unknown',
|
| 79 |
+
'warn',
|
| 80 |
+
),
|
| 81 |
+
),
|
| 82 |
+
'request_uri' => '',
|
| 83 |
+
))))
|
| 84 |
+
);
|
| 85 |
+
|
| 86 |
+
$this->assertEquals($expected, $handler->getHeaders());
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
public function testConcurrentHandlers()
|
| 90 |
+
{
|
| 91 |
+
$handler = new TestChromePHPHandler();
|
| 92 |
+
$handler->setFormatter($this->getIdentityFormatter());
|
| 93 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 94 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 95 |
+
|
| 96 |
+
$handler2 = new TestChromePHPHandler();
|
| 97 |
+
$handler2->setFormatter($this->getIdentityFormatter());
|
| 98 |
+
$handler2->handle($this->getRecord(Logger::DEBUG));
|
| 99 |
+
$handler2->handle($this->getRecord(Logger::WARNING));
|
| 100 |
+
|
| 101 |
+
$expected = array(
|
| 102 |
+
'X-ChromePhp-Data' => base64_encode(utf8_encode(json_encode(array(
|
| 103 |
+
'version' => ChromePHPHandler::VERSION,
|
| 104 |
+
'columns' => array('label', 'log', 'backtrace', 'type'),
|
| 105 |
+
'rows' => array(
|
| 106 |
+
'test',
|
| 107 |
+
'test',
|
| 108 |
+
'test',
|
| 109 |
+
'test',
|
| 110 |
+
),
|
| 111 |
+
'request_uri' => '',
|
| 112 |
+
))))
|
| 113 |
+
);
|
| 114 |
+
|
| 115 |
+
$this->assertEquals($expected, $handler2->getHeaders());
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
class TestChromePHPHandler extends ChromePHPHandler
|
| 120 |
+
{
|
| 121 |
+
protected $headers = array();
|
| 122 |
+
|
| 123 |
+
public static function reset()
|
| 124 |
+
{
|
| 125 |
+
self::$initialized = false;
|
| 126 |
+
self::$overflowed = false;
|
| 127 |
+
self::$json['rows'] = array();
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
protected function sendHeader($header, $content)
|
| 131 |
+
{
|
| 132 |
+
$this->headers[$header] = $content;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
public function getHeaders()
|
| 136 |
+
{
|
| 137 |
+
return $this->headers;
|
| 138 |
+
}
|
| 139 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/CouchDBHandlerTest.php
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\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 |
+
$expected = array(
|
| 24 |
+
'message' => 'test',
|
| 25 |
+
'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34),
|
| 26 |
+
'level' => Logger::WARNING,
|
| 27 |
+
'level_name' => 'WARNING',
|
| 28 |
+
'channel' => 'test',
|
| 29 |
+
'datetime' => $record['datetime']->format('Y-m-d H:i:s'),
|
| 30 |
+
'extra' => array(),
|
| 31 |
+
);
|
| 32 |
+
|
| 33 |
+
$handler = new CouchDBHandler();
|
| 34 |
+
|
| 35 |
+
try {
|
| 36 |
+
$handler->handle($record);
|
| 37 |
+
} catch (\RuntimeException $e) {
|
| 38 |
+
$this->markTestSkipped('Could not connect to couchdb server on http://localhost:5984');
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\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 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\TestCase;
|
| 15 |
+
use Monolog\Logger;
|
| 16 |
+
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
|
| 17 |
+
|
| 18 |
+
class FingersCrossedHandlerTest extends TestCase
|
| 19 |
+
{
|
| 20 |
+
/**
|
| 21 |
+
* @covers Monolog\Handler\FingersCrossedHandler::__construct
|
| 22 |
+
* @covers Monolog\Handler\FingersCrossedHandler::handle
|
| 23 |
+
*/
|
| 24 |
+
public function testHandleBuffers()
|
| 25 |
+
{
|
| 26 |
+
$test = new TestHandler();
|
| 27 |
+
$handler = new FingersCrossedHandler($test);
|
| 28 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 29 |
+
$handler->handle($this->getRecord(Logger::INFO));
|
| 30 |
+
$this->assertFalse($test->hasDebugRecords());
|
| 31 |
+
$this->assertFalse($test->hasInfoRecords());
|
| 32 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 33 |
+
$this->assertTrue($test->hasInfoRecords());
|
| 34 |
+
$this->assertTrue(count($test->getRecords()) === 3);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* @covers Monolog\Handler\FingersCrossedHandler::handle
|
| 39 |
+
*/
|
| 40 |
+
public function testHandleStopsBufferingAfterTrigger()
|
| 41 |
+
{
|
| 42 |
+
$test = new TestHandler();
|
| 43 |
+
$handler = new FingersCrossedHandler($test);
|
| 44 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 45 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 46 |
+
$this->assertTrue($test->hasWarningRecords());
|
| 47 |
+
$this->assertTrue($test->hasDebugRecords());
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* @covers Monolog\Handler\FingersCrossedHandler::handle
|
| 52 |
+
* @covers Monolog\Handler\FingersCrossedHandler::reset
|
| 53 |
+
*/
|
| 54 |
+
public function testHandleRestartBufferingAfterReset()
|
| 55 |
+
{
|
| 56 |
+
$test = new TestHandler();
|
| 57 |
+
$handler = new FingersCrossedHandler($test);
|
| 58 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 59 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 60 |
+
$handler->reset();
|
| 61 |
+
$handler->handle($this->getRecord(Logger::INFO));
|
| 62 |
+
$this->assertTrue($test->hasWarningRecords());
|
| 63 |
+
$this->assertTrue($test->hasDebugRecords());
|
| 64 |
+
$this->assertFalse($test->hasInfoRecords());
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
* @covers Monolog\Handler\FingersCrossedHandler::handle
|
| 69 |
+
*/
|
| 70 |
+
public function testHandleRestartBufferingAfterBeingTriggeredWhenStopBufferingIsDisabled()
|
| 71 |
+
{
|
| 72 |
+
$test = new TestHandler();
|
| 73 |
+
$handler = new FingersCrossedHandler($test, Logger::WARNING, 0, false, false);
|
| 74 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 75 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 76 |
+
$handler->handle($this->getRecord(Logger::INFO));
|
| 77 |
+
$this->assertTrue($test->hasWarningRecords());
|
| 78 |
+
$this->assertTrue($test->hasDebugRecords());
|
| 79 |
+
$this->assertFalse($test->hasInfoRecords());
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/**
|
| 83 |
+
* @covers Monolog\Handler\FingersCrossedHandler::handle
|
| 84 |
+
*/
|
| 85 |
+
public function testHandleBufferLimit()
|
| 86 |
+
{
|
| 87 |
+
$test = new TestHandler();
|
| 88 |
+
$handler = new FingersCrossedHandler($test, Logger::WARNING, 2);
|
| 89 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 90 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 91 |
+
$handler->handle($this->getRecord(Logger::INFO));
|
| 92 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 93 |
+
$this->assertTrue($test->hasWarningRecords());
|
| 94 |
+
$this->assertTrue($test->hasInfoRecords());
|
| 95 |
+
$this->assertFalse($test->hasDebugRecords());
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* @covers Monolog\Handler\FingersCrossedHandler::handle
|
| 100 |
+
*/
|
| 101 |
+
public function testHandleWithCallback()
|
| 102 |
+
{
|
| 103 |
+
$test = new TestHandler();
|
| 104 |
+
$handler = new FingersCrossedHandler(function($record, $handler) use ($test) {
|
| 105 |
+
return $test;
|
| 106 |
+
});
|
| 107 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 108 |
+
$handler->handle($this->getRecord(Logger::INFO));
|
| 109 |
+
$this->assertFalse($test->hasDebugRecords());
|
| 110 |
+
$this->assertFalse($test->hasInfoRecords());
|
| 111 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 112 |
+
$this->assertTrue($test->hasInfoRecords());
|
| 113 |
+
$this->assertTrue(count($test->getRecords()) === 3);
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
/**
|
| 117 |
+
* @covers Monolog\Handler\FingersCrossedHandler::handle
|
| 118 |
+
* @expectedException RuntimeException
|
| 119 |
+
*/
|
| 120 |
+
public function testHandleWithBadCallbackThrowsException()
|
| 121 |
+
{
|
| 122 |
+
$handler = new FingersCrossedHandler(function($record, $handler) {
|
| 123 |
+
return 'foo';
|
| 124 |
+
});
|
| 125 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
/**
|
| 129 |
+
* @covers Monolog\Handler\FingersCrossedHandler::isHandling
|
| 130 |
+
*/
|
| 131 |
+
public function testIsHandlingAlways()
|
| 132 |
+
{
|
| 133 |
+
$test = new TestHandler();
|
| 134 |
+
$handler = new FingersCrossedHandler($test, Logger::ERROR);
|
| 135 |
+
$this->assertTrue($handler->isHandling($this->getRecord(Logger::DEBUG)));
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
/**
|
| 139 |
+
* @covers Monolog\Handler\FingersCrossedHandler::__construct
|
| 140 |
+
*/
|
| 141 |
+
public function testActivationStrategy()
|
| 142 |
+
{
|
| 143 |
+
$test = new TestHandler();
|
| 144 |
+
$handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::WARNING));
|
| 145 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 146 |
+
$this->assertFalse($test->hasDebugRecords());
|
| 147 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 148 |
+
$this->assertTrue($test->hasDebugRecords());
|
| 149 |
+
$this->assertTrue($test->hasWarningRecords());
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
/**
|
| 153 |
+
* @covers Monolog\Handler\FingersCrossedHandler::handle
|
| 154 |
+
*/
|
| 155 |
+
public function testHandleUsesProcessors()
|
| 156 |
+
{
|
| 157 |
+
$test = new TestHandler();
|
| 158 |
+
$handler = new FingersCrossedHandler($test, Logger::INFO);
|
| 159 |
+
$handler->pushProcessor(function ($record) {
|
| 160 |
+
$record['extra']['foo'] = true;
|
| 161 |
+
|
| 162 |
+
return $record;
|
| 163 |
+
});
|
| 164 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 165 |
+
$this->assertTrue($test->hasWarningRecords());
|
| 166 |
+
$records = $test->getRecords();
|
| 167 |
+
$this->assertTrue($records[0]['extra']['foo']);
|
| 168 |
+
}
|
| 169 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\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 |
+
}
|
| 26 |
+
|
| 27 |
+
public function testHeaders()
|
| 28 |
+
{
|
| 29 |
+
$handler = new TestFirePHPHandler;
|
| 30 |
+
$handler->setFormatter($this->getIdentityFormatter());
|
| 31 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 32 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 33 |
+
|
| 34 |
+
$expected = array(
|
| 35 |
+
'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2',
|
| 36 |
+
'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1',
|
| 37 |
+
'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3',
|
| 38 |
+
'X-Wf-1-1-1-1' => 'test',
|
| 39 |
+
'X-Wf-1-1-1-2' => 'test',
|
| 40 |
+
);
|
| 41 |
+
|
| 42 |
+
$this->assertEquals($expected, $handler->getHeaders());
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
public function testConcurrentHandlers()
|
| 46 |
+
{
|
| 47 |
+
$handler = new TestFirePHPHandler;
|
| 48 |
+
$handler->setFormatter($this->getIdentityFormatter());
|
| 49 |
+
$handler->handle($this->getRecord(Logger::DEBUG));
|
| 50 |
+
$handler->handle($this->getRecord(Logger::WARNING));
|
| 51 |
+
|
| 52 |
+
$handler2 = new TestFirePHPHandler;
|
| 53 |
+
$handler2->setFormatter($this->getIdentityFormatter());
|
| 54 |
+
$handler2->handle($this->getRecord(Logger::DEBUG));
|
| 55 |
+
$handler2->handle($this->getRecord(Logger::WARNING));
|
| 56 |
+
|
| 57 |
+
$expected = array(
|
| 58 |
+
'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2',
|
| 59 |
+
'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1',
|
| 60 |
+
'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3',
|
| 61 |
+
'X-Wf-1-1-1-1' => 'test',
|
| 62 |
+
'X-Wf-1-1-1-2' => 'test',
|
| 63 |
+
);
|
| 64 |
+
|
| 65 |
+
$expected2 = array(
|
| 66 |
+
'X-Wf-1-1-1-3' => 'test',
|
| 67 |
+
'X-Wf-1-1-1-4' => 'test',
|
| 68 |
+
);
|
| 69 |
+
|
| 70 |
+
$this->assertEquals($expected, $handler->getHeaders());
|
| 71 |
+
$this->assertEquals($expected2, $handler2->getHeaders());
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
class TestFirePHPHandler extends FirePHPHandler
|
| 76 |
+
{
|
| 77 |
+
protected $headers = array();
|
| 78 |
+
|
| 79 |
+
public static function reset()
|
| 80 |
+
{
|
| 81 |
+
self::$initialized = false;
|
| 82 |
+
self::$messageIndex = 1;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
protected function sendHeader($header, $content)
|
| 86 |
+
{
|
| 87 |
+
$this->headers[$header] = $content;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
public function getHeaders()
|
| 91 |
+
{
|
| 92 |
+
return $this->headers;
|
| 93 |
+
}
|
| 94 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerTest.php
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\TestCase;
|
| 15 |
+
use Monolog\Logger;
|
| 16 |
+
use Monolog\Formatter\GelfMessageFormatter;
|
| 17 |
+
|
| 18 |
+
class GelfHandlerTest extends TestCase
|
| 19 |
+
{
|
| 20 |
+
public function setUp()
|
| 21 |
+
{
|
| 22 |
+
if (!class_exists("Gelf\MessagePublisher") || !class_exists("Gelf\Message")) {
|
| 23 |
+
$this->markTestSkipped("mlehner/gelf-php not installed");
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
require_once __DIR__ . '/GelfMocks.php';
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* @covers Monolog\Handler\GelfHandler::__construct
|
| 31 |
+
*/
|
| 32 |
+
public function testConstruct()
|
| 33 |
+
{
|
| 34 |
+
$handler = new GelfHandler($this->getMessagePublisher());
|
| 35 |
+
$this->assertInstanceOf('Monolog\Handler\GelfHandler', $handler);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
protected function getHandler($messagePublisher)
|
| 39 |
+
{
|
| 40 |
+
$handler = new GelfHandler($messagePublisher);
|
| 41 |
+
|
| 42 |
+
return $handler;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
protected function getMessagePublisher()
|
| 46 |
+
{
|
| 47 |
+
return new MockMessagePublisher('localhost');
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
public function testDebug()
|
| 51 |
+
{
|
| 52 |
+
$messagePublisher = $this->getMessagePublisher();
|
| 53 |
+
$handler = $this->getHandler($messagePublisher);
|
| 54 |
+
|
| 55 |
+
$record = $this->getRecord(Logger::DEBUG, "A test debug message");
|
| 56 |
+
$handler->handle($record);
|
| 57 |
+
|
| 58 |
+
$this->assertEquals(7, $messagePublisher->lastMessage->getLevel());
|
| 59 |
+
$this->assertEquals('test', $messagePublisher->lastMessage->getFacility());
|
| 60 |
+
$this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage());
|
| 61 |
+
$this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage());
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
public function testWarning()
|
| 65 |
+
{
|
| 66 |
+
$messagePublisher = $this->getMessagePublisher();
|
| 67 |
+
$handler = $this->getHandler($messagePublisher);
|
| 68 |
+
|
| 69 |
+
$record = $this->getRecord(Logger::WARNING, "A test warning message");
|
| 70 |
+
$handler->handle($record);
|
| 71 |
+
|
| 72 |
+
$this->assertEquals(4, $messagePublisher->lastMessage->getLevel());
|
| 73 |
+
$this->assertEquals('test', $messagePublisher->lastMessage->getFacility());
|
| 74 |
+
$this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage());
|
| 75 |
+
$this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage());
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
public function testInjectedGelfMessageFormatter()
|
| 79 |
+
{
|
| 80 |
+
$messagePublisher = $this->getMessagePublisher();
|
| 81 |
+
$handler = $this->getHandler($messagePublisher);
|
| 82 |
+
|
| 83 |
+
$handler->setFormatter(new GelfMessageFormatter('mysystem', 'EXT', 'CTX'));
|
| 84 |
+
|
| 85 |
+
$record = $this->getRecord(Logger::WARNING, "A test warning message");
|
| 86 |
+
$record['extra']['blarg'] = 'yep';
|
| 87 |
+
$record['context']['from'] = 'logger';
|
| 88 |
+
$handler->handle($record);
|
| 89 |
+
|
| 90 |
+
$this->assertEquals('mysystem', $messagePublisher->lastMessage->getHost());
|
| 91 |
+
$this->assertArrayHasKey('_EXTblarg', $messagePublisher->lastMessage->toArray());
|
| 92 |
+
$this->assertArrayHasKey('_CTXfrom', $messagePublisher->lastMessage->toArray());
|
| 93 |
+
}
|
| 94 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/GelfMocks.php
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Gelf\MessagePublisher;
|
| 15 |
+
use Gelf\Message;
|
| 16 |
+
|
| 17 |
+
class MockMessagePublisher extends MessagePublisher
|
| 18 |
+
{
|
| 19 |
+
public function publish(Message $message)
|
| 20 |
+
{
|
| 21 |
+
$this->lastMessage = $message;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
public $lastMessage = null;
|
| 25 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/GroupHandlerTest.php
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\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 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/MailHandlerTest.php
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\Logger;
|
| 15 |
+
use Monolog\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 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/MockRavenClient.php
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Raven_Client;
|
| 15 |
+
|
| 16 |
+
class MockRavenClient extends Raven_Client
|
| 17 |
+
{
|
| 18 |
+
public function capture($data, $stack)
|
| 19 |
+
{
|
| 20 |
+
$this->lastData = $data;
|
| 21 |
+
$this->lastStack = $stack;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
public $lastData;
|
| 25 |
+
public $lastStack;
|
| 26 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\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'));
|
| 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 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/NativeMailerHandlerTest.php
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\TestCase;
|
| 15 |
+
|
| 16 |
+
class NativeMailerHandlerTest extends TestCase
|
| 17 |
+
{
|
| 18 |
+
/**
|
| 19 |
+
* @expectedException InvalidArgumentException
|
| 20 |
+
*/
|
| 21 |
+
public function testConstructorHeaderInjection()
|
| 22 |
+
{
|
| 23 |
+
$mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', "receiver@example.org\r\nFrom: faked@attacker.org");
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* @expectedException InvalidArgumentException
|
| 28 |
+
*/
|
| 29 |
+
public function testSetterHeaderInjection()
|
| 30 |
+
{
|
| 31 |
+
$mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
|
| 32 |
+
$mailer->addHeader("Content-Type: text/html\r\nFrom: faked@attacker.org");
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* @expectedException InvalidArgumentException
|
| 37 |
+
*/
|
| 38 |
+
public function testSetterArrayHeaderInjection()
|
| 39 |
+
{
|
| 40 |
+
$mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
|
| 41 |
+
$mailer->addHeader(array("Content-Type: text/html\r\nFrom: faked@attacker.org"));
|
| 42 |
+
}
|
| 43 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/NullHandlerTest.php
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\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 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/PushoverHandlerTest.php
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\TestCase;
|
| 15 |
+
use Monolog\Logger;
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* Almost all examples (expected header, titles, messages) taken from
|
| 19 |
+
* https://www.pushover.net/api
|
| 20 |
+
* @author Sebastian Göttschkes <sebastian.goettschkes@googlemail.com>
|
| 21 |
+
* @see https://www.pushover.net/api
|
| 22 |
+
*/
|
| 23 |
+
class PushoverHandlerTest extends TestCase
|
| 24 |
+
{
|
| 25 |
+
|
| 26 |
+
private $res;
|
| 27 |
+
private $handler;
|
| 28 |
+
|
| 29 |
+
public function testWriteHeader()
|
| 30 |
+
{
|
| 31 |
+
$this->createHandler();
|
| 32 |
+
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
| 33 |
+
fseek($this->res, 0);
|
| 34 |
+
$content = fread($this->res, 1024);
|
| 35 |
+
|
| 36 |
+
$this->assertRegexp('/POST \/1\/messages.json HTTP\/1.1\\r\\nHost: api.pushover.net\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
|
| 37 |
+
|
| 38 |
+
return $content;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* @depends testWriteHeader
|
| 43 |
+
*/
|
| 44 |
+
public function testWriteContent($content)
|
| 45 |
+
{
|
| 46 |
+
$this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}$/', $content);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
public function testWriteWithComplexTitle()
|
| 50 |
+
{
|
| 51 |
+
$this->createHandler('myToken', 'myUser', 'Backup finished - SQL1');
|
| 52 |
+
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
| 53 |
+
fseek($this->res, 0);
|
| 54 |
+
$content = fread($this->res, 1024);
|
| 55 |
+
|
| 56 |
+
$this->assertRegexp('/title=Backup\+finished\+-\+SQL1/', $content);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
public function testWriteWithComplexMessage()
|
| 60 |
+
{
|
| 61 |
+
$this->createHandler();
|
| 62 |
+
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'Backup of database "example" finished in 16 minutes.'));
|
| 63 |
+
fseek($this->res, 0);
|
| 64 |
+
$content = fread($this->res, 1024);
|
| 65 |
+
|
| 66 |
+
$this->assertRegexp('/message=Backup\+of\+database\+%22example%22\+finished\+in\+16\+minutes\./', $content);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
public function testWriteWithTooLongMessage()
|
| 70 |
+
{
|
| 71 |
+
$message = str_pad('test', 520, 'a');
|
| 72 |
+
$this->createHandler();
|
| 73 |
+
$this->handler->handle($this->getRecord(Logger::CRITICAL, $message));
|
| 74 |
+
fseek($this->res, 0);
|
| 75 |
+
$content = fread($this->res, 1024);
|
| 76 |
+
|
| 77 |
+
$expectedMessage = substr($message, 0, 505);
|
| 78 |
+
|
| 79 |
+
$this->assertRegexp('/message=' . $expectedMessage . '&title/', $content);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
private function createHandler($token = 'myToken', $user = 'myUser', $title = 'Monolog')
|
| 83 |
+
{
|
| 84 |
+
$constructorArgs = array($token, $user, $title);
|
| 85 |
+
$this->res = fopen('php://memory', 'a');
|
| 86 |
+
$this->handler = $this->getMock(
|
| 87 |
+
'\Monolog\Handler\PushoverHandler',
|
| 88 |
+
array('fsockopen', 'streamSetTimeout', 'closeSocket'),
|
| 89 |
+
$constructorArgs
|
| 90 |
+
);
|
| 91 |
+
|
| 92 |
+
$reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
|
| 93 |
+
$reflectionProperty->setAccessible(true);
|
| 94 |
+
$reflectionProperty->setValue($this->handler, 'localhost:1234');
|
| 95 |
+
|
| 96 |
+
$this->handler->expects($this->any())
|
| 97 |
+
->method('fsockopen')
|
| 98 |
+
->will($this->returnValue($this->res));
|
| 99 |
+
$this->handler->expects($this->any())
|
| 100 |
+
->method('streamSetTimeout')
|
| 101 |
+
->will($this->returnValue(true));
|
| 102 |
+
$this->handler->expects($this->any())
|
| 103 |
+
->method('closeSocket')
|
| 104 |
+
->will($this->returnValue(true));
|
| 105 |
+
|
| 106 |
+
$this->handler->setFormatter($this->getIdentityFormatter());
|
| 107 |
+
}
|
| 108 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\TestCase;
|
| 15 |
+
use Monolog\Logger;
|
| 16 |
+
use Monolog\Handler\RavenHandler;
|
| 17 |
+
|
| 18 |
+
class RavenHandlerTest extends TestCase
|
| 19 |
+
{
|
| 20 |
+
public function setUp()
|
| 21 |
+
{
|
| 22 |
+
if (!class_exists("Raven_Client")) {
|
| 23 |
+
$this->markTestSkipped("raven/raven not installed");
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
require_once __DIR__ . '/MockRavenClient.php';
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* @covers Monolog\Handler\RavenHandler::__construct
|
| 31 |
+
*/
|
| 32 |
+
public function testConstruct()
|
| 33 |
+
{
|
| 34 |
+
$handler = new RavenHandler($this->getRavenClient());
|
| 35 |
+
$this->assertInstanceOf('Monolog\Handler\RavenHandler', $handler);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
protected function getHandler($ravenClient)
|
| 39 |
+
{
|
| 40 |
+
$handler = new RavenHandler($ravenClient);
|
| 41 |
+
|
| 42 |
+
return $handler;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
protected function getRavenClient()
|
| 46 |
+
{
|
| 47 |
+
$dsn = 'http://43f6017361224d098402974103bfc53d:a6a0538fc2934ba2bed32e08741b2cd3@marca.python.live.cheggnet.com:9000/1';
|
| 48 |
+
|
| 49 |
+
return new MockRavenClient($dsn);
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
public function testDebug()
|
| 53 |
+
{
|
| 54 |
+
$ravenClient = $this->getRavenClient();
|
| 55 |
+
$handler = $this->getHandler($ravenClient);
|
| 56 |
+
|
| 57 |
+
$record = $this->getRecord(Logger::DEBUG, "A test debug message");
|
| 58 |
+
$handler->handle($record);
|
| 59 |
+
|
| 60 |
+
$this->assertEquals($ravenClient::DEBUG, $ravenClient->lastData['level']);
|
| 61 |
+
$this->assertContains($record['message'], $ravenClient->lastData['message']);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
public function testWarning()
|
| 65 |
+
{
|
| 66 |
+
$ravenClient = $this->getRavenClient();
|
| 67 |
+
$handler = $this->getHandler($ravenClient);
|
| 68 |
+
|
| 69 |
+
$record = $this->getRecord(Logger::WARNING, "A test warning message");
|
| 70 |
+
$handler->handle($record);
|
| 71 |
+
|
| 72 |
+
$this->assertEquals($ravenClient::WARNING, $ravenClient->lastData['level']);
|
| 73 |
+
$this->assertContains($record['message'], $ravenClient->lastData['message']);
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
public function testException()
|
| 77 |
+
{
|
| 78 |
+
$ravenClient = $this->getRavenClient();
|
| 79 |
+
$handler = $this->getHandler($ravenClient);
|
| 80 |
+
|
| 81 |
+
try {
|
| 82 |
+
$this->methodThatThrowsAnException();
|
| 83 |
+
} catch (\Exception $e) {
|
| 84 |
+
$record = $this->getRecord(Logger::ERROR, $e->getMessage(), array('exception' => $e));
|
| 85 |
+
$handler->handle($record);
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
$this->assertEquals($record['message'], $ravenClient->lastData['message']);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
private function methodThatThrowsAnException()
|
| 92 |
+
{
|
| 93 |
+
throw new \Exception('This is an exception');
|
| 94 |
+
}
|
| 95 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/RedisHandlerTest.php
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\TestCase;
|
| 15 |
+
use Monolog\Logger;
|
| 16 |
+
use Monolog\Formatter\LineFormatter;
|
| 17 |
+
|
| 18 |
+
class RedisHandlerTest extends TestCase
|
| 19 |
+
{
|
| 20 |
+
/**
|
| 21 |
+
* @expectedException InvalidArgumentException
|
| 22 |
+
*/
|
| 23 |
+
public function testConstructorShouldThrowExceptionForInvalidRedis()
|
| 24 |
+
{
|
| 25 |
+
new RedisHandler(new \stdClass(), 'key');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
public function testConstructorShouldWorkWithPredis()
|
| 29 |
+
{
|
| 30 |
+
$redis = $this->getMock('Predis\Client');
|
| 31 |
+
$this->assertInstanceof('Monolog\Handler\RedisHandler', new RedisHandler($redis, 'key'));
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
public function testConstructorShouldWorkWithRedis()
|
| 35 |
+
{
|
| 36 |
+
$redis = $this->getMock('Redis');
|
| 37 |
+
$this->assertInstanceof('Monolog\Handler\RedisHandler', new RedisHandler($redis, 'key'));
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
public function testPredisHandle()
|
| 41 |
+
{
|
| 42 |
+
$redis = $this->getMock('Predis\Client', array('rpush'));
|
| 43 |
+
|
| 44 |
+
// Predis\Client uses rpush
|
| 45 |
+
$redis->expects($this->once())
|
| 46 |
+
->method('rpush')
|
| 47 |
+
->with('key', 'test');
|
| 48 |
+
|
| 49 |
+
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
| 50 |
+
|
| 51 |
+
$handler = new RedisHandler($redis, 'key');
|
| 52 |
+
$handler->setFormatter(new LineFormatter("%message%"));
|
| 53 |
+
$handler->handle($record);
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
public function testRedisHandle()
|
| 57 |
+
{
|
| 58 |
+
$redis = $this->getMock('Redis', array('rpush'));
|
| 59 |
+
|
| 60 |
+
// Redis uses rPush
|
| 61 |
+
$redis->expects($this->once())
|
| 62 |
+
->method('rPush')
|
| 63 |
+
->with('key', 'test');
|
| 64 |
+
|
| 65 |
+
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
| 66 |
+
|
| 67 |
+
$handler = new RedisHandler($redis, 'key');
|
| 68 |
+
$handler->setFormatter(new LineFormatter("%message%"));
|
| 69 |
+
$handler->handle($record);
|
| 70 |
+
}
|
| 71 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\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 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\TestCase;
|
| 15 |
+
use Monolog\Logger;
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* @author Pablo de Leon Belloc <pablolb@gmail.com>
|
| 19 |
+
*/
|
| 20 |
+
class SocketHandlerTest extends TestCase
|
| 21 |
+
{
|
| 22 |
+
/**
|
| 23 |
+
* @var Monolog\Handler\SocketHandler
|
| 24 |
+
*/
|
| 25 |
+
private $handler;
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @var resource
|
| 29 |
+
*/
|
| 30 |
+
private $res;
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* @expectedException UnexpectedValueException
|
| 34 |
+
*/
|
| 35 |
+
public function testInvalidHostname()
|
| 36 |
+
{
|
| 37 |
+
$this->createHandler('garbage://here');
|
| 38 |
+
$this->writeRecord('data');
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* @expectedException \InvalidArgumentException
|
| 43 |
+
*/
|
| 44 |
+
public function testBadConnectionTimeout()
|
| 45 |
+
{
|
| 46 |
+
$this->createHandler('localhost:1234');
|
| 47 |
+
$this->handler->setConnectionTimeout(-1);
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
public function testSetConnectionTimeout()
|
| 51 |
+
{
|
| 52 |
+
$this->createHandler('localhost:1234');
|
| 53 |
+
$this->handler->setConnectionTimeout(10.1);
|
| 54 |
+
$this->assertEquals(10.1, $this->handler->getConnectionTimeout());
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* @expectedException \InvalidArgumentException
|
| 59 |
+
*/
|
| 60 |
+
public function testBadTimeout()
|
| 61 |
+
{
|
| 62 |
+
$this->createHandler('localhost:1234');
|
| 63 |
+
$this->handler->setTimeout(-1);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
public function testSetTimeout()
|
| 67 |
+
{
|
| 68 |
+
$this->createHandler('localhost:1234');
|
| 69 |
+
$this->handler->setTimeout(10.25);
|
| 70 |
+
$this->assertEquals(10.25, $this->handler->getTimeout());
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
public function testSetConnectionString()
|
| 74 |
+
{
|
| 75 |
+
$this->createHandler('tcp://localhost:9090');
|
| 76 |
+
$this->assertEquals('tcp://localhost:9090', $this->handler->getConnectionString());
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* @expectedException UnexpectedValueException
|
| 81 |
+
*/
|
| 82 |
+
public function testExceptionIsThrownOnFsockopenError()
|
| 83 |
+
{
|
| 84 |
+
$this->setMockHandler(array('fsockopen'));
|
| 85 |
+
$this->handler->expects($this->once())
|
| 86 |
+
->method('fsockopen')
|
| 87 |
+
->will($this->returnValue(false));
|
| 88 |
+
$this->writeRecord('Hello world');
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
/**
|
| 92 |
+
* @expectedException UnexpectedValueException
|
| 93 |
+
*/
|
| 94 |
+
public function testExceptionIsThrownOnPfsockopenError()
|
| 95 |
+
{
|
| 96 |
+
$this->setMockHandler(array('pfsockopen'));
|
| 97 |
+
$this->handler->expects($this->once())
|
| 98 |
+
->method('pfsockopen')
|
| 99 |
+
->will($this->returnValue(false));
|
| 100 |
+
$this->handler->setPersistent(true);
|
| 101 |
+
$this->writeRecord('Hello world');
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
/**
|
| 105 |
+
* @expectedException UnexpectedValueException
|
| 106 |
+
*/
|
| 107 |
+
public function testExceptionIsThrownIfCannotSetTimeout()
|
| 108 |
+
{
|
| 109 |
+
$this->setMockHandler(array('streamSetTimeout'));
|
| 110 |
+
$this->handler->expects($this->once())
|
| 111 |
+
->method('streamSetTimeout')
|
| 112 |
+
->will($this->returnValue(false));
|
| 113 |
+
$this->writeRecord('Hello world');
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
/**
|
| 117 |
+
* @expectedException RuntimeException
|
| 118 |
+
*/
|
| 119 |
+
public function testWriteFailsOnIfFwriteReturnsFalse()
|
| 120 |
+
{
|
| 121 |
+
$this->setMockHandler(array('fwrite'));
|
| 122 |
+
|
| 123 |
+
$callback = function($arg) {
|
| 124 |
+
$map = array(
|
| 125 |
+
'Hello world' => 6,
|
| 126 |
+
'world' => false,
|
| 127 |
+
);
|
| 128 |
+
|
| 129 |
+
return $map[$arg];
|
| 130 |
+
};
|
| 131 |
+
|
| 132 |
+
$this->handler->expects($this->exactly(2))
|
| 133 |
+
->method('fwrite')
|
| 134 |
+
->will($this->returnCallback($callback));
|
| 135 |
+
|
| 136 |
+
$this->writeRecord('Hello world');
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
/**
|
| 140 |
+
* @expectedException RuntimeException
|
| 141 |
+
*/
|
| 142 |
+
public function testWriteFailsIfStreamTimesOut()
|
| 143 |
+
{
|
| 144 |
+
$this->setMockHandler(array('fwrite', 'streamGetMetadata'));
|
| 145 |
+
|
| 146 |
+
$callback = function($arg) {
|
| 147 |
+
$map = array(
|
| 148 |
+
'Hello world' => 6,
|
| 149 |
+
'world' => 5,
|
| 150 |
+
);
|
| 151 |
+
|
| 152 |
+
return $map[$arg];
|
| 153 |
+
};
|
| 154 |
+
|
| 155 |
+
$this->handler->expects($this->exactly(1))
|
| 156 |
+
->method('fwrite')
|
| 157 |
+
->will($this->returnCallback($callback));
|
| 158 |
+
$this->handler->expects($this->exactly(1))
|
| 159 |
+
->method('streamGetMetadata')
|
| 160 |
+
->will($this->returnValue(array('timed_out' => true)));
|
| 161 |
+
|
| 162 |
+
$this->writeRecord('Hello world');
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
/**
|
| 166 |
+
* @expectedException RuntimeException
|
| 167 |
+
*/
|
| 168 |
+
public function testWriteFailsOnIncompleteWrite()
|
| 169 |
+
{
|
| 170 |
+
$this->setMockHandler(array('fwrite', 'streamGetMetadata'));
|
| 171 |
+
|
| 172 |
+
$res = $this->res;
|
| 173 |
+
$callback = function($string) use ($res) {
|
| 174 |
+
fclose($res);
|
| 175 |
+
|
| 176 |
+
return strlen('Hello');
|
| 177 |
+
};
|
| 178 |
+
|
| 179 |
+
$this->handler->expects($this->exactly(1))
|
| 180 |
+
->method('fwrite')
|
| 181 |
+
->will($this->returnCallback($callback));
|
| 182 |
+
$this->handler->expects($this->exactly(1))
|
| 183 |
+
->method('streamGetMetadata')
|
| 184 |
+
->will($this->returnValue(array('timed_out' => false)));
|
| 185 |
+
|
| 186 |
+
$this->writeRecord('Hello world');
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
public function testWriteWithMemoryFile()
|
| 190 |
+
{
|
| 191 |
+
$this->setMockHandler();
|
| 192 |
+
$this->writeRecord('test1');
|
| 193 |
+
$this->writeRecord('test2');
|
| 194 |
+
$this->writeRecord('test3');
|
| 195 |
+
fseek($this->res, 0);
|
| 196 |
+
$this->assertEquals('test1test2test3', fread($this->res, 1024));
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
public function testWriteWithMock()
|
| 200 |
+
{
|
| 201 |
+
$this->setMockHandler(array('fwrite'));
|
| 202 |
+
|
| 203 |
+
$callback = function($arg) {
|
| 204 |
+
$map = array(
|
| 205 |
+
'Hello world' => 6,
|
| 206 |
+
'world' => 5,
|
| 207 |
+
);
|
| 208 |
+
|
| 209 |
+
return $map[$arg];
|
| 210 |
+
};
|
| 211 |
+
|
| 212 |
+
$this->handler->expects($this->exactly(2))
|
| 213 |
+
->method('fwrite')
|
| 214 |
+
->will($this->returnCallback($callback));
|
| 215 |
+
|
| 216 |
+
$this->writeRecord('Hello world');
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
public function testClose()
|
| 220 |
+
{
|
| 221 |
+
$this->setMockHandler();
|
| 222 |
+
$this->writeRecord('Hello world');
|
| 223 |
+
$this->assertInternalType('resource', $this->res);
|
| 224 |
+
$this->handler->close();
|
| 225 |
+
$this->assertFalse(is_resource($this->res), "Expected resource to be closed after closing handler");
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
public function testCloseDoesNotClosePersistentSocket()
|
| 229 |
+
{
|
| 230 |
+
$this->setMockHandler();
|
| 231 |
+
$this->handler->setPersistent(true);
|
| 232 |
+
$this->writeRecord('Hello world');
|
| 233 |
+
$this->assertTrue(is_resource($this->res));
|
| 234 |
+
$this->handler->close();
|
| 235 |
+
$this->assertTrue(is_resource($this->res));
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
private function createHandler($connectionString)
|
| 239 |
+
{
|
| 240 |
+
$this->handler = new SocketHandler($connectionString);
|
| 241 |
+
$this->handler->setFormatter($this->getIdentityFormatter());
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
private function writeRecord($string)
|
| 245 |
+
{
|
| 246 |
+
$this->handler->handle($this->getRecord(Logger::WARNING, $string));
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
private function setMockHandler(array $methods = array())
|
| 250 |
+
{
|
| 251 |
+
$this->res = fopen('php://memory', 'a');
|
| 252 |
+
|
| 253 |
+
$defaultMethods = array('fsockopen', 'pfsockopen', 'streamSetTimeout');
|
| 254 |
+
$newMethods = array_diff($methods, $defaultMethods);
|
| 255 |
+
|
| 256 |
+
$finalMethods = array_merge($defaultMethods, $newMethods);
|
| 257 |
+
|
| 258 |
+
$this->handler = $this->getMock(
|
| 259 |
+
'\Monolog\Handler\SocketHandler', $finalMethods, array('localhost:1234')
|
| 260 |
+
);
|
| 261 |
+
|
| 262 |
+
if (!in_array('fsockopen', $methods)) {
|
| 263 |
+
$this->handler->expects($this->any())
|
| 264 |
+
->method('fsockopen')
|
| 265 |
+
->will($this->returnValue($this->res));
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
if (!in_array('pfsockopen', $methods)) {
|
| 269 |
+
$this->handler->expects($this->any())
|
| 270 |
+
->method('pfsockopen')
|
| 271 |
+
->will($this->returnValue($this->res));
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
if (!in_array('streamSetTimeout', $methods)) {
|
| 275 |
+
$this->handler->expects($this->any())
|
| 276 |
+
->method('streamSetTimeout')
|
| 277 |
+
->will($this->returnValue(true));
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
$this->handler->setFormatter($this->getIdentityFormatter());
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/Handler/StreamHandlerTest.php
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog\Handler;
|
| 13 |
+
|
| 14 |
+
use Monolog\TestCase;
|
| 15 |
+
use Monolog\Logger;
|
| 16 |
+
|
| 17 |
+
class StreamHandlerTest extends TestCase
|
| 18 |
+
{
|
| 19 |
+
/**
|
| 20 |
+
* @covers Monolog\Handler\StreamHandler::__construct
|
| 21 |
+
* @covers Monolog\Handler\StreamHandler::write
|
| 22 |
+
*/
|
| 23 |
+
public function testWrite()
|
| 24 |
+
{
|
| 25 |
+
$handle = fopen('php://memory', 'a+');
|
| 26 |
+
$handler = new StreamHandler($handle);
|
| 27 |
+
$handler->setFormatter($this->getIdentityFormatter());
|
| 28 |
+
$handler->handle($this->getRecord(Logger::WARNING, 'test'));
|
| 29 |
+
$handler->handle($this->getRecord(Logger::WARNING, 'test2'));
|
| 30 |
+
$handler->handle($this->getRecord(Logger::WARNING, 'test3'));
|
| 31 |
+
fseek($handle, 0);
|
| 32 |
+
$this->assertEquals('testtest2test3', fread($handle, 100));
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* @covers Monolog\Handler\StreamHandler::close
|
| 37 |
+
*/
|
| 38 |
+
public function testClose()
|
| 39 |
+
{
|
| 40 |
+
$handle = fopen('php://memory', 'a+');
|
| 41 |
+
$handler = new StreamHandler($handle);
|
| 42 |
+
$this->assertTrue(is_resource($handle));
|
| 43 |
+
$handler->close();
|
| 44 |
+
$this->assertFalse(is_resource($handle));
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* @covers Monolog\Handler\StreamHandler::write
|
| 49 |
+
*/
|
| 50 |
+
public function testWriteCreatesTheStreamResource()
|
| 51 |
+
{
|
| 52 |
+
$handler = new StreamHandler('php://memory');
|
| 53 |
+
$handler->handle($this->getRecord());
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* @expectedException LogicException
|
| 58 |
+
* @covers Monolog\Handler\StreamHandler::__construct
|
| 59 |
+
* @covers Monolog\Handler\StreamHandler::write
|
| 60 |
+
*/
|
| 61 |
+
public function testWriteMissingResource()
|
| 62 |
+
{
|
| 63 |
+
$handler = new StreamHandler(null);
|
| 64 |
+
$handler->handle($this->getRecord());
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
* @expectedException UnexpectedValueException
|
| 69 |
+
* @covers Monolog\Handler\StreamHandler::__construct
|
| 70 |
+
* @covers Monolog\Handler\StreamHandler::write
|
| 71 |
+
*/
|
| 72 |
+
public function testWriteInvalidResource()
|
| 73 |
+
{
|
| 74 |
+
$handler = new StreamHandler('bogus://url');
|
| 75 |
+
$handler->handle($this->getRecord());
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* @expectedException UnexpectedValueException
|
| 80 |
+
* @covers Monolog\Handler\StreamHandler::__construct
|
| 81 |
+
* @covers Monolog\Handler\StreamHandler::write
|
| 82 |
+
*/
|
| 83 |
+
public function testWriteNonExistingResource()
|
| 84 |
+
{
|
| 85 |
+
$handler = new StreamHandler('/foo/bar/baz/'.rand(0, 10000));
|
| 86 |
+
$handler->handle($this->getRecord());
|
| 87 |
+
}
|
| 88 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/LoggerTest.php
ADDED
|
@@ -0,0 +1,409 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog;
|
| 13 |
+
|
| 14 |
+
use Monolog\Processor\WebProcessor;
|
| 15 |
+
use Monolog\Handler\TestHandler;
|
| 16 |
+
|
| 17 |
+
class LoggerTest extends \PHPUnit_Framework_TestCase
|
| 18 |
+
{
|
| 19 |
+
/**
|
| 20 |
+
* @covers Monolog\Logger::getName
|
| 21 |
+
*/
|
| 22 |
+
public function testGetName()
|
| 23 |
+
{
|
| 24 |
+
$logger = new Logger('foo');
|
| 25 |
+
$this->assertEquals('foo', $logger->getName());
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* @covers Monolog\Logger::getLevelName
|
| 30 |
+
*/
|
| 31 |
+
public function testGetLevelName()
|
| 32 |
+
{
|
| 33 |
+
$this->assertEquals('ERROR', Logger::getLevelName(Logger::ERROR));
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* @covers Monolog\Logger::getLevelName
|
| 38 |
+
* @expectedException InvalidArgumentException
|
| 39 |
+
*/
|
| 40 |
+
public function testGetLevelNameThrows()
|
| 41 |
+
{
|
| 42 |
+
Logger::getLevelName(5);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* @covers Monolog\Logger::__construct
|
| 47 |
+
*/
|
| 48 |
+
public function testChannel()
|
| 49 |
+
{
|
| 50 |
+
$logger = new Logger('foo');
|
| 51 |
+
$handler = new TestHandler;
|
| 52 |
+
$logger->pushHandler($handler);
|
| 53 |
+
$logger->addWarning('test');
|
| 54 |
+
list($record) = $handler->getRecords();
|
| 55 |
+
$this->assertEquals('foo', $record['channel']);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* @covers Monolog\Logger::addRecord
|
| 60 |
+
*/
|
| 61 |
+
public function testLog()
|
| 62 |
+
{
|
| 63 |
+
$logger = new Logger(__METHOD__);
|
| 64 |
+
|
| 65 |
+
$handler = $this->getMock('Monolog\Handler\NullHandler', array('handle'));
|
| 66 |
+
$handler->expects($this->once())
|
| 67 |
+
->method('handle');
|
| 68 |
+
$logger->pushHandler($handler);
|
| 69 |
+
|
| 70 |
+
$this->assertTrue($logger->addWarning('test'));
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* @covers Monolog\Logger::addRecord
|
| 75 |
+
*/
|
| 76 |
+
public function testLogNotHandled()
|
| 77 |
+
{
|
| 78 |
+
$logger = new Logger(__METHOD__);
|
| 79 |
+
|
| 80 |
+
$handler = $this->getMock('Monolog\Handler\NullHandler', array('handle'), array(Logger::ERROR));
|
| 81 |
+
$handler->expects($this->never())
|
| 82 |
+
->method('handle');
|
| 83 |
+
$logger->pushHandler($handler);
|
| 84 |
+
|
| 85 |
+
$this->assertFalse($logger->addWarning('test'));
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
public function testHandlersInCtor()
|
| 89 |
+
{
|
| 90 |
+
$handler1 = new TestHandler;
|
| 91 |
+
$handler2 = new TestHandler;
|
| 92 |
+
$logger = new Logger(__METHOD__, array($handler1, $handler2));
|
| 93 |
+
|
| 94 |
+
$this->assertEquals($handler1, $logger->popHandler());
|
| 95 |
+
$this->assertEquals($handler2, $logger->popHandler());
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
public function testProcessorsInCtor()
|
| 99 |
+
{
|
| 100 |
+
$processor1 = new WebProcessor;
|
| 101 |
+
$processor2 = new WebProcessor;
|
| 102 |
+
$logger = new Logger(__METHOD__, array(), array($processor1, $processor2));
|
| 103 |
+
|
| 104 |
+
$this->assertEquals($processor1, $logger->popProcessor());
|
| 105 |
+
$this->assertEquals($processor2, $logger->popProcessor());
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
/**
|
| 109 |
+
* @covers Monolog\Logger::pushHandler
|
| 110 |
+
* @covers Monolog\Logger::popHandler
|
| 111 |
+
* @expectedException LogicException
|
| 112 |
+
*/
|
| 113 |
+
public function testPushPopHandler()
|
| 114 |
+
{
|
| 115 |
+
$logger = new Logger(__METHOD__);
|
| 116 |
+
$handler1 = new TestHandler;
|
| 117 |
+
$handler2 = new TestHandler;
|
| 118 |
+
|
| 119 |
+
$logger->pushHandler($handler1);
|
| 120 |
+
$logger->pushHandler($handler2);
|
| 121 |
+
|
| 122 |
+
$this->assertEquals($handler2, $logger->popHandler());
|
| 123 |
+
$this->assertEquals($handler1, $logger->popHandler());
|
| 124 |
+
$logger->popHandler();
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
* @covers Monolog\Logger::pushProcessor
|
| 129 |
+
* @covers Monolog\Logger::popProcessor
|
| 130 |
+
* @expectedException LogicException
|
| 131 |
+
*/
|
| 132 |
+
public function testPushPopProcessor()
|
| 133 |
+
{
|
| 134 |
+
$logger = new Logger(__METHOD__);
|
| 135 |
+
$processor1 = new WebProcessor;
|
| 136 |
+
$processor2 = new WebProcessor;
|
| 137 |
+
|
| 138 |
+
$logger->pushProcessor($processor1);
|
| 139 |
+
$logger->pushProcessor($processor2);
|
| 140 |
+
|
| 141 |
+
$this->assertEquals($processor2, $logger->popProcessor());
|
| 142 |
+
$this->assertEquals($processor1, $logger->popProcessor());
|
| 143 |
+
$logger->popProcessor();
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
/**
|
| 147 |
+
* @covers Monolog\Logger::pushProcessor
|
| 148 |
+
* @expectedException InvalidArgumentException
|
| 149 |
+
*/
|
| 150 |
+
public function testPushProcessorWithNonCallable()
|
| 151 |
+
{
|
| 152 |
+
$logger = new Logger(__METHOD__);
|
| 153 |
+
|
| 154 |
+
$logger->pushProcessor(new \stdClass());
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
/**
|
| 158 |
+
* @covers Monolog\Logger::addRecord
|
| 159 |
+
*/
|
| 160 |
+
public function testProcessorsAreExecuted()
|
| 161 |
+
{
|
| 162 |
+
$logger = new Logger(__METHOD__);
|
| 163 |
+
$handler = new TestHandler;
|
| 164 |
+
$logger->pushHandler($handler);
|
| 165 |
+
$logger->pushProcessor(function($record) {
|
| 166 |
+
$record['extra']['win'] = true;
|
| 167 |
+
|
| 168 |
+
return $record;
|
| 169 |
+
});
|
| 170 |
+
$logger->addError('test');
|
| 171 |
+
list($record) = $handler->getRecords();
|
| 172 |
+
$this->assertTrue($record['extra']['win']);
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
/**
|
| 176 |
+
* @covers Monolog\Logger::addRecord
|
| 177 |
+
*/
|
| 178 |
+
public function testProcessorsAreCalledOnlyOnce()
|
| 179 |
+
{
|
| 180 |
+
$logger = new Logger(__METHOD__);
|
| 181 |
+
$handler = $this->getMock('Monolog\Handler\HandlerInterface');
|
| 182 |
+
$handler->expects($this->any())
|
| 183 |
+
->method('isHandling')
|
| 184 |
+
->will($this->returnValue(true))
|
| 185 |
+
;
|
| 186 |
+
$handler->expects($this->any())
|
| 187 |
+
->method('handle')
|
| 188 |
+
->will($this->returnValue(true))
|
| 189 |
+
;
|
| 190 |
+
$logger->pushHandler($handler);
|
| 191 |
+
|
| 192 |
+
$processor = $this->getMockBuilder('Monolog\Processor\WebProcessor')
|
| 193 |
+
->disableOriginalConstructor()
|
| 194 |
+
->setMethods(array('__invoke'))
|
| 195 |
+
->getMock()
|
| 196 |
+
;
|
| 197 |
+
$processor->expects($this->once())
|
| 198 |
+
->method('__invoke')
|
| 199 |
+
->will($this->returnArgument(0))
|
| 200 |
+
;
|
| 201 |
+
$logger->pushProcessor($processor);
|
| 202 |
+
|
| 203 |
+
$logger->addError('test');
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
/**
|
| 207 |
+
* @covers Monolog\Logger::addRecord
|
| 208 |
+
*/
|
| 209 |
+
public function testProcessorsNotCalledWhenNotHandled()
|
| 210 |
+
{
|
| 211 |
+
$logger = new Logger(__METHOD__);
|
| 212 |
+
$handler = $this->getMock('Monolog\Handler\HandlerInterface');
|
| 213 |
+
$handler->expects($this->once())
|
| 214 |
+
->method('isHandling')
|
| 215 |
+
->will($this->returnValue(false))
|
| 216 |
+
;
|
| 217 |
+
$logger->pushHandler($handler);
|
| 218 |
+
$that = $this;
|
| 219 |
+
$logger->pushProcessor(function($record) use ($that) {
|
| 220 |
+
$that->fail('The processor should not be called');
|
| 221 |
+
});
|
| 222 |
+
$logger->addAlert('test');
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
/**
|
| 226 |
+
* @covers Monolog\Logger::addRecord
|
| 227 |
+
*/
|
| 228 |
+
public function testHandlersNotCalledBeforeFirstHandling()
|
| 229 |
+
{
|
| 230 |
+
$logger = new Logger(__METHOD__);
|
| 231 |
+
|
| 232 |
+
$handler1 = $this->getMock('Monolog\Handler\HandlerInterface');
|
| 233 |
+
$handler1->expects($this->never())
|
| 234 |
+
->method('isHandling')
|
| 235 |
+
->will($this->returnValue(false))
|
| 236 |
+
;
|
| 237 |
+
$handler1->expects($this->once())
|
| 238 |
+
->method('handle')
|
| 239 |
+
->will($this->returnValue(false))
|
| 240 |
+
;
|
| 241 |
+
$logger->pushHandler($handler1);
|
| 242 |
+
|
| 243 |
+
$handler2 = $this->getMock('Monolog\Handler\HandlerInterface');
|
| 244 |
+
$handler2->expects($this->once())
|
| 245 |
+
->method('isHandling')
|
| 246 |
+
->will($this->returnValue(true))
|
| 247 |
+
;
|
| 248 |
+
$handler2->expects($this->once())
|
| 249 |
+
->method('handle')
|
| 250 |
+
->will($this->returnValue(false))
|
| 251 |
+
;
|
| 252 |
+
$logger->pushHandler($handler2);
|
| 253 |
+
|
| 254 |
+
$handler3 = $this->getMock('Monolog\Handler\HandlerInterface');
|
| 255 |
+
$handler3->expects($this->once())
|
| 256 |
+
->method('isHandling')
|
| 257 |
+
->will($this->returnValue(false))
|
| 258 |
+
;
|
| 259 |
+
$handler3->expects($this->never())
|
| 260 |
+
->method('handle')
|
| 261 |
+
;
|
| 262 |
+
$logger->pushHandler($handler3);
|
| 263 |
+
|
| 264 |
+
$logger->debug('test');
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
/**
|
| 268 |
+
* @covers Monolog\Logger::addRecord
|
| 269 |
+
*/
|
| 270 |
+
public function testBubblingWhenTheHandlerReturnsFalse()
|
| 271 |
+
{
|
| 272 |
+
$logger = new Logger(__METHOD__);
|
| 273 |
+
|
| 274 |
+
$handler1 = $this->getMock('Monolog\Handler\HandlerInterface');
|
| 275 |
+
$handler1->expects($this->any())
|
| 276 |
+
->method('isHandling')
|
| 277 |
+
->will($this->returnValue(true))
|
| 278 |
+
;
|
| 279 |
+
$handler1->expects($this->once())
|
| 280 |
+
->method('handle')
|
| 281 |
+
->will($this->returnValue(false))
|
| 282 |
+
;
|
| 283 |
+
$logger->pushHandler($handler1);
|
| 284 |
+
|
| 285 |
+
$handler2 = $this->getMock('Monolog\Handler\HandlerInterface');
|
| 286 |
+
$handler2->expects($this->any())
|
| 287 |
+
->method('isHandling')
|
| 288 |
+
->will($this->returnValue(true))
|
| 289 |
+
;
|
| 290 |
+
$handler2->expects($this->once())
|
| 291 |
+
->method('handle')
|
| 292 |
+
->will($this->returnValue(false))
|
| 293 |
+
;
|
| 294 |
+
$logger->pushHandler($handler2);
|
| 295 |
+
|
| 296 |
+
$logger->debug('test');
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
/**
|
| 300 |
+
* @covers Monolog\Logger::addRecord
|
| 301 |
+
*/
|
| 302 |
+
public function testNotBubblingWhenTheHandlerReturnsTrue()
|
| 303 |
+
{
|
| 304 |
+
$logger = new Logger(__METHOD__);
|
| 305 |
+
|
| 306 |
+
$handler1 = $this->getMock('Monolog\Handler\HandlerInterface');
|
| 307 |
+
$handler1->expects($this->any())
|
| 308 |
+
->method('isHandling')
|
| 309 |
+
->will($this->returnValue(true))
|
| 310 |
+
;
|
| 311 |
+
$handler1->expects($this->never())
|
| 312 |
+
->method('handle')
|
| 313 |
+
;
|
| 314 |
+
$logger->pushHandler($handler1);
|
| 315 |
+
|
| 316 |
+
$handler2 = $this->getMock('Monolog\Handler\HandlerInterface');
|
| 317 |
+
$handler2->expects($this->any())
|
| 318 |
+
->method('isHandling')
|
| 319 |
+
->will($this->returnValue(true))
|
| 320 |
+
;
|
| 321 |
+
$handler2->expects($this->once())
|
| 322 |
+
->method('handle')
|
| 323 |
+
->will($this->returnValue(true))
|
| 324 |
+
;
|
| 325 |
+
$logger->pushHandler($handler2);
|
| 326 |
+
|
| 327 |
+
$logger->debug('test');
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
/**
|
| 331 |
+
* @covers Monolog\Logger::isHandling
|
| 332 |
+
*/
|
| 333 |
+
public function testIsHandling()
|
| 334 |
+
{
|
| 335 |
+
$logger = new Logger(__METHOD__);
|
| 336 |
+
|
| 337 |
+
$handler1 = $this->getMock('Monolog\Handler\HandlerInterface');
|
| 338 |
+
$handler1->expects($this->any())
|
| 339 |
+
->method('isHandling')
|
| 340 |
+
->will($this->returnValue(false))
|
| 341 |
+
;
|
| 342 |
+
|
| 343 |
+
$logger->pushHandler($handler1);
|
| 344 |
+
$this->assertFalse($logger->isHandling(Logger::DEBUG));
|
| 345 |
+
|
| 346 |
+
$handler2 = $this->getMock('Monolog\Handler\HandlerInterface');
|
| 347 |
+
$handler2->expects($this->any())
|
| 348 |
+
->method('isHandling')
|
| 349 |
+
->will($this->returnValue(true))
|
| 350 |
+
;
|
| 351 |
+
|
| 352 |
+
$logger->pushHandler($handler2);
|
| 353 |
+
$this->assertTrue($logger->isHandling(Logger::DEBUG));
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
/**
|
| 357 |
+
* @dataProvider logMethodProvider
|
| 358 |
+
* @covers Monolog\Logger::addDebug
|
| 359 |
+
* @covers Monolog\Logger::addInfo
|
| 360 |
+
* @covers Monolog\Logger::addNotice
|
| 361 |
+
* @covers Monolog\Logger::addWarning
|
| 362 |
+
* @covers Monolog\Logger::addError
|
| 363 |
+
* @covers Monolog\Logger::addCritical
|
| 364 |
+
* @covers Monolog\Logger::addAlert
|
| 365 |
+
* @covers Monolog\Logger::addEmergency
|
| 366 |
+
* @covers Monolog\Logger::debug
|
| 367 |
+
* @covers Monolog\Logger::info
|
| 368 |
+
* @covers Monolog\Logger::notice
|
| 369 |
+
* @covers Monolog\Logger::warn
|
| 370 |
+
* @covers Monolog\Logger::err
|
| 371 |
+
* @covers Monolog\Logger::crit
|
| 372 |
+
* @covers Monolog\Logger::alert
|
| 373 |
+
* @covers Monolog\Logger::emerg
|
| 374 |
+
*/
|
| 375 |
+
public function testLogMethods($method, $expectedLevel)
|
| 376 |
+
{
|
| 377 |
+
$logger = new Logger('foo');
|
| 378 |
+
$handler = new TestHandler;
|
| 379 |
+
$logger->pushHandler($handler);
|
| 380 |
+
$logger->{$method}('test');
|
| 381 |
+
list($record) = $handler->getRecords();
|
| 382 |
+
$this->assertEquals($expectedLevel, $record['level']);
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
public function logMethodProvider()
|
| 386 |
+
{
|
| 387 |
+
return array(
|
| 388 |
+
// monolog methods
|
| 389 |
+
array('addDebug', Logger::DEBUG),
|
| 390 |
+
array('addInfo', Logger::INFO),
|
| 391 |
+
array('addNotice', Logger::NOTICE),
|
| 392 |
+
array('addWarning', Logger::WARNING),
|
| 393 |
+
array('addError', Logger::ERROR),
|
| 394 |
+
array('addCritical', Logger::CRITICAL),
|
| 395 |
+
array('addAlert', Logger::ALERT),
|
| 396 |
+
array('addEmergency', Logger::EMERGENCY),
|
| 397 |
+
|
| 398 |
+
// ZF/Sf2 compat methods
|
| 399 |
+
array('debug', Logger::DEBUG),
|
| 400 |
+
array('info', Logger::INFO),
|
| 401 |
+
array('notice', Logger::NOTICE),
|
| 402 |
+
array('warn', Logger::WARNING),
|
| 403 |
+
array('err', Logger::ERROR),
|
| 404 |
+
array('crit', Logger::CRITICAL),
|
| 405 |
+
array('alert', Logger::ALERT),
|
| 406 |
+
array('emerg', Logger::EMERGENCY),
|
| 407 |
+
);
|
| 408 |
+
}
|
| 409 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog;
|
| 13 |
+
|
| 14 |
+
use Monolog\Handler\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 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/Monolog/TestCase.php
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
namespace Monolog;
|
| 13 |
+
|
| 14 |
+
class 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 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/monolog/monolog/tests/bootstrap.php
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of the Monolog package.
|
| 5 |
+
*
|
| 6 |
+
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
| 7 |
+
*
|
| 8 |
+
* For the full copyright and license information, please view the LICENSE
|
| 9 |
+
* file that was distributed with this source code.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
$loader = require_once __DIR__ . "/../vendor/autoload.php";
|
| 13 |
+
$loader->add('Monolog\\', __DIR__);
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
vendor
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/AbstractLogger.php
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace Psr\Log;
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* This is a simple Logger implementation that other Loggers can inherit from.
|
| 7 |
+
*
|
| 8 |
+
* It simply delegates all log-level-specific methods to the `log` method to
|
| 9 |
+
* reduce boilerplate code that a simple Logger that does the same thing with
|
| 10 |
+
* messages regardless of the error level has to implement.
|
| 11 |
+
*/
|
| 12 |
+
abstract class AbstractLogger implements LoggerInterface
|
| 13 |
+
{
|
| 14 |
+
/**
|
| 15 |
+
* System is unusable.
|
| 16 |
+
*
|
| 17 |
+
* @param string $message
|
| 18 |
+
* @param array $context
|
| 19 |
+
* @return null
|
| 20 |
+
*/
|
| 21 |
+
public function emergency($message, array $context = array())
|
| 22 |
+
{
|
| 23 |
+
$this->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 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/InvalidArgumentException.php
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace Psr\Log;
|
| 4 |
+
|
| 5 |
+
class InvalidArgumentException extends \InvalidArgumentException
|
| 6 |
+
{
|
| 7 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/LogLevel.php
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace Psr\Log;
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* Describes log levels
|
| 7 |
+
*/
|
| 8 |
+
class LogLevel
|
| 9 |
+
{
|
| 10 |
+
const EMERGENCY = 'emergency';
|
| 11 |
+
const ALERT = 'alert';
|
| 12 |
+
const CRITICAL = 'critical';
|
| 13 |
+
const ERROR = 'error';
|
| 14 |
+
const WARNING = 'warning';
|
| 15 |
+
const NOTICE = 'notice';
|
| 16 |
+
const INFO = 'info';
|
| 17 |
+
const DEBUG = 'debug';
|
| 18 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/LoggerAwareInterface.php
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace Psr\Log;
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* Describes a logger-aware instance
|
| 7 |
+
*/
|
| 8 |
+
interface LoggerAwareInterface
|
| 9 |
+
{
|
| 10 |
+
/**
|
| 11 |
+
* Sets a logger instance on the object
|
| 12 |
+
*
|
| 13 |
+
* @param LoggerInterface $logger
|
| 14 |
+
* @return null
|
| 15 |
+
*/
|
| 16 |
+
public function setLogger(LoggerInterface $logger);
|
| 17 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/LoggerAwareTrait.php
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace Psr\Log;
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* Basic Implementation of LoggerAwareInterface.
|
| 7 |
+
*/
|
| 8 |
+
trait LoggerAwareTrait
|
| 9 |
+
{
|
| 10 |
+
/** @var LoggerInterface */
|
| 11 |
+
protected $logger;
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Sets a logger.
|
| 15 |
+
*
|
| 16 |
+
* @param LoggerInterface $logger
|
| 17 |
+
*/
|
| 18 |
+
public function setLogger(LoggerInterface $logger)
|
| 19 |
+
{
|
| 20 |
+
$this->logger = $logger;
|
| 21 |
+
}
|
| 22 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/LoggerInterface.php
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace Psr\Log;
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* Describes a logger instance
|
| 7 |
+
*
|
| 8 |
+
* The message MUST be a string or object implementing __toString().
|
| 9 |
+
*
|
| 10 |
+
* The message MAY contain placeholders in the form: {foo} where foo
|
| 11 |
+
* will be replaced by the context data in key "foo".
|
| 12 |
+
*
|
| 13 |
+
* The context array can contain arbitrary data, the only assumption that
|
| 14 |
+
* can be made by implementors is that if an Exception instance is given
|
| 15 |
+
* to produce a stack trace, it MUST be in a key named "exception".
|
| 16 |
+
*
|
| 17 |
+
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
|
| 18 |
+
* for the full interface specification.
|
| 19 |
+
*/
|
| 20 |
+
interface LoggerInterface
|
| 21 |
+
{
|
| 22 |
+
/**
|
| 23 |
+
* System is unusable.
|
| 24 |
+
*
|
| 25 |
+
* @param string $message
|
| 26 |
+
* @param array $context
|
| 27 |
+
* @return null
|
| 28 |
+
*/
|
| 29 |
+
public function emergency($message, array $context = array());
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* Action must be taken immediately.
|
| 33 |
+
*
|
| 34 |
+
* Example: Entire website down, database unavailable, etc. This should
|
| 35 |
+
* trigger the SMS alerts and wake you up.
|
| 36 |
+
*
|
| 37 |
+
* @param string $message
|
| 38 |
+
* @param array $context
|
| 39 |
+
* @return null
|
| 40 |
+
*/
|
| 41 |
+
public function alert($message, array $context = array());
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* Critical conditions.
|
| 45 |
+
*
|
| 46 |
+
* Example: Application component unavailable, unexpected exception.
|
| 47 |
+
*
|
| 48 |
+
* @param string $message
|
| 49 |
+
* @param array $context
|
| 50 |
+
* @return null
|
| 51 |
+
*/
|
| 52 |
+
public function critical($message, array $context = array());
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* Runtime errors that do not require immediate action but should typically
|
| 56 |
+
* be logged and monitored.
|
| 57 |
+
*
|
| 58 |
+
* @param string $message
|
| 59 |
+
* @param array $context
|
| 60 |
+
* @return null
|
| 61 |
+
*/
|
| 62 |
+
public function error($message, array $context = array());
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* Exceptional occurrences that are not errors.
|
| 66 |
+
*
|
| 67 |
+
* Example: Use of deprecated APIs, poor use of an API, undesirable things
|
| 68 |
+
* that are not necessarily wrong.
|
| 69 |
+
*
|
| 70 |
+
* @param string $message
|
| 71 |
+
* @param array $context
|
| 72 |
+
* @return null
|
| 73 |
+
*/
|
| 74 |
+
public function warning($message, array $context = array());
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* Normal but significant events.
|
| 78 |
+
*
|
| 79 |
+
* @param string $message
|
| 80 |
+
* @param array $context
|
| 81 |
+
* @return null
|
| 82 |
+
*/
|
| 83 |
+
public function notice($message, array $context = array());
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* Interesting events.
|
| 87 |
+
*
|
| 88 |
+
* Example: User logs in, SQL logs.
|
| 89 |
+
*
|
| 90 |
+
* @param string $message
|
| 91 |
+
* @param array $context
|
| 92 |
+
* @return null
|
| 93 |
+
*/
|
| 94 |
+
public function info($message, array $context = array());
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* Detailed debug information.
|
| 98 |
+
*
|
| 99 |
+
* @param string $message
|
| 100 |
+
* @param array $context
|
| 101 |
+
* @return null
|
| 102 |
+
*/
|
| 103 |
+
public function debug($message, array $context = array());
|
| 104 |
+
|
| 105 |
+
/**
|
| 106 |
+
* Logs with an arbitrary level.
|
| 107 |
+
*
|
| 108 |
+
* @param mixed $level
|
| 109 |
+
* @param string $message
|
| 110 |
+
* @param array $context
|
| 111 |
+
* @return null
|
| 112 |
+
*/
|
| 113 |
+
public function log($level, $message, array $context = array());
|
| 114 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/LoggerTrait.php
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace Psr\Log;
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* This is a simple Logger trait that classes unable to extend AbstractLogger
|
| 7 |
+
* (because they extend another class, etc) can include.
|
| 8 |
+
*
|
| 9 |
+
* It simply delegates all log-level-specific methods to the `log` method to
|
| 10 |
+
* reduce boilerplate code that a simple Logger that does the same thing with
|
| 11 |
+
* messages regardless of the error level has to implement.
|
| 12 |
+
*/
|
| 13 |
+
trait LoggerTrait
|
| 14 |
+
{
|
| 15 |
+
/**
|
| 16 |
+
* System is unusable.
|
| 17 |
+
*
|
| 18 |
+
* @param string $message
|
| 19 |
+
* @param array $context
|
| 20 |
+
* @return null
|
| 21 |
+
*/
|
| 22 |
+
public function emergency($message, array $context = array())
|
| 23 |
+
{
|
| 24 |
+
$this->log(LogLevel::EMERGENCY, $message, $context);
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Action must be taken immediately.
|
| 29 |
+
*
|
| 30 |
+
* Example: Entire website down, database unavailable, etc. This should
|
| 31 |
+
* trigger the SMS alerts and wake you up.
|
| 32 |
+
*
|
| 33 |
+
* @param string $message
|
| 34 |
+
* @param array $context
|
| 35 |
+
* @return null
|
| 36 |
+
*/
|
| 37 |
+
public function alert($message, array $context = array())
|
| 38 |
+
{
|
| 39 |
+
$this->log(LogLevel::ALERT, $message, $context);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* Critical conditions.
|
| 44 |
+
*
|
| 45 |
+
* Example: Application component unavailable, unexpected exception.
|
| 46 |
+
*
|
| 47 |
+
* @param string $message
|
| 48 |
+
* @param array $context
|
| 49 |
+
* @return null
|
| 50 |
+
*/
|
| 51 |
+
public function critical($message, array $context = array())
|
| 52 |
+
{
|
| 53 |
+
$this->log(LogLevel::CRITICAL, $message, $context);
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* Runtime errors that do not require immediate action but should typically
|
| 58 |
+
* be logged and monitored.
|
| 59 |
+
*
|
| 60 |
+
* @param string $message
|
| 61 |
+
* @param array $context
|
| 62 |
+
* @return null
|
| 63 |
+
*/
|
| 64 |
+
public function error($message, array $context = array())
|
| 65 |
+
{
|
| 66 |
+
$this->log(LogLevel::ERROR, $message, $context);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* Exceptional occurrences that are not errors.
|
| 71 |
+
*
|
| 72 |
+
* Example: Use of deprecated APIs, poor use of an API, undesirable things
|
| 73 |
+
* that are not necessarily wrong.
|
| 74 |
+
*
|
| 75 |
+
* @param string $message
|
| 76 |
+
* @param array $context
|
| 77 |
+
* @return null
|
| 78 |
+
*/
|
| 79 |
+
public function warning($message, array $context = array())
|
| 80 |
+
{
|
| 81 |
+
$this->log(LogLevel::WARNING, $message, $context);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* Normal but significant events.
|
| 86 |
+
*
|
| 87 |
+
* @param string $message
|
| 88 |
+
* @param array $context
|
| 89 |
+
* @return null
|
| 90 |
+
*/
|
| 91 |
+
public function notice($message, array $context = array())
|
| 92 |
+
{
|
| 93 |
+
$this->log(LogLevel::NOTICE, $message, $context);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* Interesting events.
|
| 98 |
+
*
|
| 99 |
+
* Example: User logs in, SQL logs.
|
| 100 |
+
*
|
| 101 |
+
* @param string $message
|
| 102 |
+
* @param array $context
|
| 103 |
+
* @return null
|
| 104 |
+
*/
|
| 105 |
+
public function info($message, array $context = array())
|
| 106 |
+
{
|
| 107 |
+
$this->log(LogLevel::INFO, $message, $context);
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
/**
|
| 111 |
+
* Detailed debug information.
|
| 112 |
+
*
|
| 113 |
+
* @param string $message
|
| 114 |
+
* @param array $context
|
| 115 |
+
* @return null
|
| 116 |
+
*/
|
| 117 |
+
public function debug($message, array $context = array())
|
| 118 |
+
{
|
| 119 |
+
$this->log(LogLevel::DEBUG, $message, $context);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
/**
|
| 123 |
+
* Logs with an arbitrary level.
|
| 124 |
+
*
|
| 125 |
+
* @param mixed $level
|
| 126 |
+
* @param string $message
|
| 127 |
+
* @param array $context
|
| 128 |
+
* @return null
|
| 129 |
+
*/
|
| 130 |
+
abstract public function log($level, $message, array $context = array());
|
| 131 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/NullLogger.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace Psr\Log;
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* This Logger can be used to avoid conditional log calls
|
| 7 |
+
*
|
| 8 |
+
* Logging should always be optional, and if no logger is provided to your
|
| 9 |
+
* library creating a NullLogger instance to have something to throw logs at
|
| 10 |
+
* is a good way to avoid littering your code with `if ($this->logger) { }`
|
| 11 |
+
* blocks.
|
| 12 |
+
*/
|
| 13 |
+
class NullLogger extends AbstractLogger
|
| 14 |
+
{
|
| 15 |
+
/**
|
| 16 |
+
* Logs with an arbitrary level.
|
| 17 |
+
*
|
| 18 |
+
* @param mixed $level
|
| 19 |
+
* @param string $message
|
| 20 |
+
* @param array $context
|
| 21 |
+
* @return null
|
| 22 |
+
*/
|
| 23 |
+
public function log($level, $message, array $context = array())
|
| 24 |
+
{
|
| 25 |
+
// noop
|
| 26 |
+
}
|
| 27 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace Psr\Log\Test;
|
| 4 |
+
|
| 5 |
+
use Psr\Log\LogLevel;
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Provides a base test class for ensuring compliance with the LoggerInterface
|
| 9 |
+
*
|
| 10 |
+
* Implementors can extend the class and implement abstract methods to run this as part of their test suite
|
| 11 |
+
*/
|
| 12 |
+
abstract class LoggerInterfaceTest extends \PHPUnit_Framework_TestCase
|
| 13 |
+
{
|
| 14 |
+
/**
|
| 15 |
+
* @return LoggerInterface
|
| 16 |
+
*/
|
| 17 |
+
abstract function getLogger();
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* This must return the log messages in order with a simple formatting: "<LOG LEVEL> <MESSAGE>"
|
| 21 |
+
*
|
| 22 |
+
* Example ->error('Foo') would yield "error Foo"
|
| 23 |
+
*
|
| 24 |
+
* @return string[]
|
| 25 |
+
*/
|
| 26 |
+
abstract function getLogs();
|
| 27 |
+
|
| 28 |
+
public function testImplements()
|
| 29 |
+
{
|
| 30 |
+
$this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* @dataProvider provideLevelsAndMessages
|
| 35 |
+
*/
|
| 36 |
+
public function testLogsAtAllLevels($level, $message)
|
| 37 |
+
{
|
| 38 |
+
$logger = $this->getLogger();
|
| 39 |
+
$logger->{$level}($message, array('user' => 'Bob'));
|
| 40 |
+
$logger->log($level, $message, array('user' => 'Bob'));
|
| 41 |
+
|
| 42 |
+
$expected = array(
|
| 43 |
+
$level.' message of level '.$level.' with context: Bob',
|
| 44 |
+
$level.' message of level '.$level.' with context: Bob',
|
| 45 |
+
);
|
| 46 |
+
$this->assertEquals($expected, $this->getLogs());
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
public function provideLevelsAndMessages()
|
| 50 |
+
{
|
| 51 |
+
return array(
|
| 52 |
+
LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'),
|
| 53 |
+
LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'),
|
| 54 |
+
LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'),
|
| 55 |
+
LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'),
|
| 56 |
+
LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'),
|
| 57 |
+
LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'),
|
| 58 |
+
LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'),
|
| 59 |
+
LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'),
|
| 60 |
+
);
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
/**
|
| 64 |
+
* @expectedException Psr\Log\InvalidArgumentException
|
| 65 |
+
*/
|
| 66 |
+
public function testThrowsOnInvalidLevel()
|
| 67 |
+
{
|
| 68 |
+
$logger = $this->getLogger();
|
| 69 |
+
$logger->log('invalid level', 'Foo');
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
public function testContextReplacement()
|
| 73 |
+
{
|
| 74 |
+
$logger = $this->getLogger();
|
| 75 |
+
$logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
|
| 76 |
+
|
| 77 |
+
$expected = array('info {Message {nothing} Bob Bar a}');
|
| 78 |
+
$this->assertEquals($expected, $this->getLogs());
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
public function testObjectCastToString()
|
| 82 |
+
{
|
| 83 |
+
$dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString'));
|
| 84 |
+
$dummy->expects($this->once())
|
| 85 |
+
->method('__toString')
|
| 86 |
+
->will($this->returnValue('DUMMY'));
|
| 87 |
+
|
| 88 |
+
$this->getLogger()->warning($dummy);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
public function testContextCanContainAnything()
|
| 92 |
+
{
|
| 93 |
+
$context = array(
|
| 94 |
+
'bool' => true,
|
| 95 |
+
'null' => null,
|
| 96 |
+
'string' => 'Foo',
|
| 97 |
+
'int' => 0,
|
| 98 |
+
'float' => 0.5,
|
| 99 |
+
'nested' => array('with object' => new DummyTest),
|
| 100 |
+
'object' => new \DateTime,
|
| 101 |
+
'resource' => fopen('php://memory', 'r'),
|
| 102 |
+
);
|
| 103 |
+
|
| 104 |
+
$this->getLogger()->warning('Crazy context data', $context);
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
public function testContextExceptionKeyCanBeExceptionOrOtherValues()
|
| 108 |
+
{
|
| 109 |
+
$this->getLogger()->warning('Random message', array('exception' => 'oops'));
|
| 110 |
+
$this->getLogger()->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
class DummyTest
|
| 115 |
+
{
|
| 116 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
<?php
|
| 17 |
+
|
| 18 |
+
use Psr\Log\LoggerInterface;
|
| 19 |
+
|
| 20 |
+
class Foo
|
| 21 |
+
{
|
| 22 |
+
private $logger;
|
| 23 |
+
|
| 24 |
+
public function __construct(LoggerInterface $logger = null)
|
| 25 |
+
{
|
| 26 |
+
$this->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.
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/vendor/psr/log/composer.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
}
|