/**
  * setup, create mocks
  *
  * @return Mock object
  */
 public function setUp()
 {
     parent::setUp();
     $this->stderr = $this->getMock('Cake\\Console\\ConsoleOutput', [], [], '', false);
     $this->Error = $this->getMock('Cake\\Console\\ConsoleErrorHandler', ['_stop'], [['stderr' => $this->stderr]]);
     Log::drop('stderr');
 }
Пример #2
0
 /**
  * setup, create mocks
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->stderr = $this->getMockBuilder('Cake\\Console\\ConsoleOutput')->disableOriginalConstructor()->getMock();
     $this->Error = $this->getMockBuilder('Cake\\Console\\ConsoleErrorHandler')->setMethods(['_stop'])->setConstructorArgs([['stderr' => $this->stderr]])->getMock();
     Log::drop('stderr');
 }
Пример #3
0
 /**
  * Start the shell and interactive console.
  *
  * @return int|void
  */
 public function main()
 {
     if (!class_exists('Psy\\Shell')) {
         $this->err('<error>Unable to load Psy\\Shell.</error>');
         $this->err('');
         $this->err('Make sure you have installed psysh as a dependency,');
         $this->err('and that Psy\\Shell is registered in your autoloader.');
         $this->err('');
         $this->err('If you are using composer run');
         $this->err('');
         $this->err('<info>$ php composer.phar require --dev psy/psysh</info>');
         $this->err('');
         return 1;
     }
     $this->out("You can exit with <info>`CTRL-C`</info> or <info>`exit`</info>");
     $this->out('');
     Log::drop('debug');
     Log::drop('error');
     $this->_io->setLoggers(false);
     restore_error_handler();
     restore_exception_handler();
     $psy = new PsyShell();
     $psy->run();
     return 0;
 }
Пример #4
0
 /**
  * Start the shell and interactive console.
  *
  * @return void
  */
 public function main()
 {
     if (!class_exists('Boris\\Boris')) {
         $this->err('<error>Unable to load Boris\\Boris.</error>');
         $this->err('');
         $this->err('Make sure you have installed boris as a dependency,');
         $this->err('and that Boris\\Boris is registered in your autoloader.');
         $this->err('');
         $this->err('If you are using composer run');
         $this->err('');
         $this->err('<info>$ php composer.phar require d11wtq/boris</info>');
         $this->err('');
         return 1;
     }
     if (!function_exists('pcntl_signal')) {
         $this->err('<error>No process control functions.</error>');
         $this->err('');
         $this->err('You are missing the pcntl extension, the interactive console requires this extension.');
         return 2;
     }
     $this->out('You can exit with <info>CTRL-D</info>');
     Log::drop('debug');
     Log::drop('error');
     $this->_io->setLoggers(false);
     restore_error_handler();
     restore_exception_handler();
     $boris = new Boris('app > ');
     $boris->start();
 }
Пример #5
0
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Log::drop('email');
     Email::drop('test');
     Email::dropTransport('debug');
     Email::dropTransport('test_smtp');
 }
Пример #6
0
 /**
  * Start the shell and interactive console.
  *
  * @return void
  */
 public function main()
 {
     if (!class_exists('Boris\\Boris')) {
         $this->err('<error>Unable to load Boris\\Boris.</error>');
         $this->err('');
         $this->err('Make sure you have installed boris as a dependency,');
         $this->err('and that Boris\\Boris is registered in your autoloader.');
         $this->err('');
         $this->err('If you are using composer run');
         $this->err('');
         $this->err('<info>$ php composer.phar require d11wtq/boris</info>');
         $this->err('');
         return 1;
     }
     $this->out('You can exit with <info>CTRL-D</info>');
     Log::drop('debug');
     Log::drop('error');
     restore_error_handler();
     restore_exception_handler();
     $boris = new Boris('app > ');
     $boris->start();
 }
Пример #7
0
 /**
  * Test that write() returns false on an unhandled message.
  *
  * @return void
  */
 public function testWriteUnhandled()
 {
     Log::drop('error');
     Log::drop('debug');
     $result = Log::write('error', 'Bad stuff', 'unpossible');
     $this->assertFalse($result);
 }
Пример #8
0
 /**
  * Connects or disconnects the loggers to the console output.
  *
  * Used to enable or disable logging stream output to stdout and stderr
  * If you don't wish all log output in stdout or stderr
  * through Cake's Log class, call this function with `$enable=false`.
  *
  * @param int|bool $enable Use a boolean to enable/toggle all logging. Use
  *   one of the verbosity constants (self::VERBOSE, self::QUIET, self::NORMAL)
  *   to control logging levels. VERBOSE enables debug logs, NORMAL does not include debug logs,
  *   QUIET disables notice, info and debug logs.
  * @return void
  */
 public function setLoggers($enable)
 {
     Log::drop('stdout');
     Log::drop('stderr');
     if ($enable === false) {
         return;
     }
     $outLevels = ['notice', 'info'];
     if ($enable === static::VERBOSE || $enable === true) {
         $outLevels[] = 'debug';
     }
     if ($enable !== static::QUIET) {
         $stdout = new ConsoleLog(['types' => $outLevels, 'stream' => $this->_out]);
         Log::config('stdout', ['engine' => $stdout]);
     }
     $stderr = new ConsoleLog(['types' => ['emergency', 'alert', 'critical', 'error', 'warning'], 'stream' => $this->_err]);
     Log::config('stderr', ['engine' => $stderr]);
 }
Пример #9
0
 /**
  * Tests that setLoggers works properly with verbose
  *
  * @return void
  */
 public function testSetLoggersVerbose()
 {
     Log::drop('stdout');
     Log::drop('stderr');
     $this->io->setLoggers(ConsoleIo::VERBOSE);
     $this->assertNotEmpty(Log::engine('stderr'));
     $engine = Log::engine('stdout');
     $this->assertEquals(['notice', 'info', 'debug'], $engine->config('levels'));
 }
 /**
  * Tests that setLoggers works properly
  *
  * @return void
  */
 public function testSetLoggers()
 {
     Log::drop('stdout');
     Log::drop('stderr');
     $this->io->setLoggers(true);
     $this->assertNotEmpty(Log::engine('stdout'));
     $this->assertNotEmpty(Log::engine('stderr'));
     $this->io->setLoggers(false);
     $this->assertFalse(Log::engine('stdout'));
     $this->assertFalse(Log::engine('stderr'));
 }
Пример #11
0
 /**
  * Connects or disconnects the loggers to the console output.
  *
  * Used to enable or disable logging stream output to stdout and stderr
  * If you don't wish all log output in stdout or stderr
  * through Cake's Log class, call this function with `$enable=false`.
  *
  * @param bool $enable Whether you want loggers on or off.
  * @return void
  */
 public function setLoggers($enable)
 {
     Log::drop('stdout');
     Log::drop('stderr');
     if (!$enable) {
         return;
     }
     $stdout = new ConsoleLog(['types' => ['notice', 'info', 'debug'], 'stream' => $this->_out]);
     Log::config('stdout', ['engine' => $stdout]);
     $stderr = new ConsoleLog(['types' => ['emergency', 'alert', 'critical', 'error', 'warning'], 'stream' => $this->_err]);
     Log::config('stderr', ['engine' => $stderr]);
 }
Пример #12
0
 public function tearDown()
 {
     parent::tearDown();
     Log::drop('trait_test');
 }
 /**
  * Teardown method.
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Log::drop('debug_kit_log_panel');
 }
 /**
  * testLog method
  *
  * @return void
  */
 public function testLog()
 {
     $mock = $this->getMock('Cake\\Log\\Engine\\BaseLog', ['log']);
     Log::config('test', ['engine' => $mock]);
     $mock->expects($this->at(0))->method('log')->with('debug', $this->logicalAnd($this->stringContains('DebuggerTest::testLog'), $this->stringContains('cool')));
     $mock->expects($this->at(1))->method('log')->with('debug', $this->logicalAnd($this->stringContains('DebuggerTest::testLog'), $this->stringContains('[main]'), $this->stringContains("'whatever',"), $this->stringContains("'here'")));
     Debugger::log('cool');
     Debugger::log(['whatever', 'here']);
     Log::drop('test');
 }
Пример #15
0
 * Connect middleware/dispatcher filters.
 */
DispatcherFactory::add('Asset');
DispatcherFactory::add('Routing');
DispatcherFactory::add('ControllerFactory');
/**
 * Cakebox: use Monolog to create a combined log (with all log levels) to enable
 * Logstash > Elasticsearch forwarding, unless we are in CLI mode which defines
 * it's own Monlog logger (with 'cli' prefix tag instead of 'app').
 *
 * Notes:
 * - will log to /var/logs/cakephp if available so it can be parsed by Logstash
 * - LogStashFormatter argument is used as Logstash/Elasticsearch "type"
 * - Logger second argument is used as Monolog "channel"
 */
if (!$isCli) {
    Log::config('default', function () {
        if (is_writable('/var/log/cakephp')) {
            $handler = new StreamHandler('/var/log/cakephp/cakebox.log');
        } else {
            $handler = new StreamHandler(LOGS . DS . 'cakebox.log');
        }
        $formatter = new LogstashFormatter('cakephp');
        $handler->setFormatter($formatter);
        $log = new Logger('app.cakebox', array($handler));
        return $log;
    });
    // Stop using the now redundant default CakePHP file loggers
    Log::drop('debug');
    Log::drop('error');
}