!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache/2.2.22 (Debian). PHP/5.6.36 

uname -a: Linux h05.hvosting.ua 4.9.110-amd64 #3 SMP Sun Nov 4 16:27:09 UTC 2018 x86_64 

uid=1389(h33678) gid=1099(h33678) groups=1099(h33678),502(mgrsecure) 

Safe-mode: OFF (not secure)

/home/h33678/data/www/it-man.ztu.edu.ua/src/vendor/monolog/monolog/tests/Monolog/Formatter/   drwxr-xr-x
Free 116.58 GB of 200.55 GB (58.13%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     GelfMessageFormatterTest.php (7.32 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

/*
 * This file is part of the Monolog package.
 *
 * (c) Jordi Boggiano <j.boggiano@seld.be>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Monolog\Formatter;

use 
Monolog\Logger;

class 
GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
{
    public function 
setUp()
    {
        if (!
class_exists('\Gelf\Message')) {
            
$this->markTestSkipped("graylog2/gelf-php or mlehner/gelf-php is not installed");
        }
    }

    
/**
     * @covers Monolog\Formatter\GelfMessageFormatter::format
     */
    
public function testDefaultFormatter()
    {
        
$formatter = new GelfMessageFormatter();
        
$record = array(
            
'level' => Logger::ERROR,
            
'level_name' => 'ERROR',
            
'channel' => 'meh',
            
'context' => array(),
            
'datetime' => new \DateTime("@0"),
            
'extra' => array(),
            
'message' => 'log',
        );

        
$message $formatter->format($record);

        
$this->assertInstanceOf('Gelf\Message'$message);
        
$this->assertEquals(0$message->getTimestamp());
        
$this->assertEquals('log'$message->getShortMessage());
        
$this->assertEquals('meh'$message->getFacility());
        
$this->assertEquals(null$message->getLine());
        
$this->assertEquals(null$message->getFile());
        
$this->assertEquals($this->isLegacy() ? 'error'$message->getLevel());
        
$this->assertNotEmpty($message->getHost());

        
$formatter = new GelfMessageFormatter('mysystem');

        
$message $formatter->format($record);

        
$this->assertInstanceOf('Gelf\Message'$message);
        
$this->assertEquals('mysystem'$message->getHost());
    }

    
/**
     * @covers Monolog\Formatter\GelfMessageFormatter::format
     */
    
public function testFormatWithFileAndLine()
    {
        
$formatter = new GelfMessageFormatter();
        
$record = array(
            
'level' => Logger::ERROR,
            
'level_name' => 'ERROR',
            
'channel' => 'meh',
            
'context' => array('from' => 'logger'),
            
'datetime' => new \DateTime("@0"),
            
'extra' => array('file' => 'test''line' => 14),
            
'message' => 'log',
        );

        
$message $formatter->format($record);

        
$this->assertInstanceOf('Gelf\Message'$message);
        
$this->assertEquals('test'$message->getFile());
        
$this->assertEquals(14$message->getLine());
    }

    
/**
     * @covers Monolog\Formatter\GelfMessageFormatter::format
     * @expectedException InvalidArgumentException
     */
    
public function testFormatInvalidFails()
    {
        
$formatter = new GelfMessageFormatter();
        
$record = array(
            
'level' => Logger::ERROR,
            
'level_name' => 'ERROR',
        );

        
$formatter->format($record);
    }

    
/**
     * @covers Monolog\Formatter\GelfMessageFormatter::format
     */
    
public function testFormatWithContext()
    {
        
$formatter = new GelfMessageFormatter();
        
$record = array(
            
'level' => Logger::ERROR,
            
'level_name' => 'ERROR',
            
'channel' => 'meh',
            
'context' => array('from' => 'logger'),
            
'datetime' => new \DateTime("@0"),
            
'extra' => array('key' => 'pair'),
            
'message' => 'log',
        );

        
$message $formatter->format($record);

        
$this->assertInstanceOf('Gelf\Message'$message);

        
$message_array $message->toArray();

        
$this->assertArrayHasKey('_ctxt_from'$message_array);
        
$this->assertEquals('logger'$message_array['_ctxt_from']);

        
// Test with extraPrefix
        
$formatter = new GelfMessageFormatter(nullnull'CTX');
        
$message $formatter->format($record);

        
$this->assertInstanceOf('Gelf\Message'$message);

        
$message_array $message->toArray();

        
$this->assertArrayHasKey('_CTXfrom'$message_array);
        
$this->assertEquals('logger'$message_array['_CTXfrom']);
    }

    
/**
     * @covers Monolog\Formatter\GelfMessageFormatter::format
     */
    
public function testFormatWithContextContainingException()
    {
        
$formatter = new GelfMessageFormatter();
        
$record = array(
            
'level' => Logger::ERROR,
            
'level_name' => 'ERROR',
            
'channel' => 'meh',
            
'context' => array('from' => 'logger''exception' => array(
                
'class' => '\Exception',
                
'file'  => '/some/file/in/dir.php:56',
                
'trace' => array('/some/file/1.php:23''/some/file/2.php:3'),
            )),
            
'datetime' => new \DateTime("@0"),
            
'extra' => array(),
            
'message' => 'log',
        );

        
$message $formatter->format($record);

        
$this->assertInstanceOf('Gelf\Message'$message);

        
$this->assertEquals("/some/file/in/dir.php"$message->getFile());
        
$this->assertEquals("56"$message->getLine());
    }

    
/**
     * @covers Monolog\Formatter\GelfMessageFormatter::format
     */
    
public function testFormatWithExtra()
    {
        
$formatter = new GelfMessageFormatter();
        
$record = array(
            
'level' => Logger::ERROR,
            
'level_name' => 'ERROR',
            
'channel' => 'meh',
            
'context' => array('from' => 'logger'),
            
'datetime' => new \DateTime("@0"),
            
'extra' => array('key' => 'pair'),
            
'message' => 'log',
        );

        
$message $formatter->format($record);

        
$this->assertInstanceOf('Gelf\Message'$message);

        
$message_array $message->toArray();

        
$this->assertArrayHasKey('_key'$message_array);
        
$this->assertEquals('pair'$message_array['_key']);

        
// Test with extraPrefix
        
$formatter = new GelfMessageFormatter(null'EXT');
        
$message $formatter->format($record);

        
$this->assertInstanceOf('Gelf\Message'$message);

        
$message_array $message->toArray();

        
$this->assertArrayHasKey('_EXTkey'$message_array);
        
$this->assertEquals('pair'$message_array['_EXTkey']);
    }

    public function 
testFormatWithLargeData()
    {
        
$formatter = new GelfMessageFormatter();
        
$record = array(
            
'level' => Logger::ERROR,
            
'level_name' => 'ERROR',
            
'channel' => 'meh',
            
'context' => array('exception' => str_repeat(' '32767)),
            
'datetime' => new \DateTime("@0"),
            
'extra' => array('key' => str_repeat(' '32767)),
            
'message' => 'log'
        
);
        
$message $formatter->format($record);
        
$messageArray $message->toArray();

        
// 200 for padding + metadata
        
$length 200;

        foreach (
$messageArray as $key => $value) {
            if (!
in_array($key, array('level''timestamp'))) {
                
$length += strlen($value);
            }
        }

        
// in graylog2/gelf-php before 1.4.1 empty strings are filtered and won't be included in the message
        // though it should be sufficient to ensure that the entire message length does not exceed the maximum
        // length being allowed
        
$this->assertLessThanOrEqual(32766$length'The message length is no longer than the maximum allowed length');
    }

    private function 
isLegacy()
    {
        return 
interface_exists('\Gelf\IMessagePublisher');
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by PinoyWH1Z | C99Shell Github | Generation time: 0.0454 ]--