public function testLogsError()
 {
     $logger = new TestWorkableLogger();
     SS_Log::add_writer($logger);
     $result = Workable::create()->getJobs(['state' => 'fail']);
     $this->assertNotNull($logger->event);
     SS_Log::remove_writer($logger);
 }
 function testRemoveWriter()
 {
     SS_Log::remove_writer($this->testEmailWriter);
     $writers = SS_Log::get_writers();
     $this->assertType('array', $writers);
     $this->assertEquals(1, count($writers));
     SS_Log::remove_writer($this->testFileWriter);
     $writers = SS_Log::get_writers();
     $this->assertType('array', $writers);
     $this->assertEquals(0, count($writers));
 }
示例#3
0
 public function testRemoveWriter()
 {
     $testEmailWriter = new SS_LogEmailWriter('*****@*****.**');
     $testFileWriter = new SS_LogFileWriter('../test.log');
     SS_Log::add_writer($testEmailWriter, SS_Log::ERR);
     SS_Log::add_writer($testFileWriter, SS_Log::WARN);
     SS_Log::remove_writer($testEmailWriter);
     $writers = SS_Log::get_writers();
     $this->assertEquals(1, count($writers));
     SS_Log::remove_writer($testFileWriter);
     $writers = SS_Log::get_writers();
     $this->assertEquals(0, count($writers));
 }
示例#4
0
文件: Debug.php 项目: nomidi/sapphire
 /**
  * Log the given error, if self::$log_errors is set.
  * Uses the native error_log() funtion in PHP.
  * 
  * Format: [d-M-Y h:i:s] <type> at <file> line <line>: <errormessage> <url>
  * 
  * @todo Detect script path for CLI errors
  * @todo Log detailed errors to full file
  * @deprecated 2.5 See SS_Log on setting up error file logging
  */
 protected static function log_error_if_necessary($errno, $errstr, $errfile, $errline, $errcontext, $errtype)
 {
     Deprecation::notice('2.5', 'Use SS_Log instead. See the class documentation in SS_Log.php for more information.');
     $priority = $errtype == 'Error' ? SS_Log::ERR : SS_Log::WARN;
     $writer = new SS_LogFileWriter('../' . self::$log_errors_to);
     SS_Log::add_writer($writer, $priority);
     SS_Log::log(array('errno' => $errno, 'errstr' => $errstr, 'errfile' => $errfile, 'errline' => $errline, 'errcontext' => $errcontext), $priority);
     SS_Log::remove_writer($writer);
 }
示例#5
0
    /**
     * Log the given error, if self::$log_errors is set.
     * Uses the native error_log() funtion in PHP.
     * 
     * Format: [d-M-Y h:i:s] <type> at <file> line <line>: <errormessage> <url>
     * 
     * @todo Detect script path for CLI errors
     * @todo Log detailed errors to full file
     * @deprecated 2.5 See SS_Log on setting up error file logging
     */
    protected static function log_error_if_necessary($errno, $errstr, $errfile, $errline, $errcontext, $errtype)
    {
        user_error('Debug::log_error_if_necessary() and Debug::log_errors_to() are deprecated. Please use SS_Log instead.
			See the class documentation in SS_Log.php for more information.', E_USER_NOTICE);
        $priority = $errtype == 'Error' ? SS_Log::ERR : SS_Log::WARN;
        $writer = new SS_LogFileWriter('../' . self::$log_errors_to);
        SS_Log::add_writer($writer, $priority);
        SS_Log::log(array('errno' => $errno, 'errstr' => $errstr, 'errfile' => $errfile, 'errline' => $errline, 'errcontext' => $errcontext), $priority);
        SS_Log::remove_writer($writer);
    }