Exemplo n.º 1
0
 public function testComplexLayout()
 {
     $config = LoggerTestHelper::getEchoPatternConfig($this->pattern);
     Logger::configure($config);
     ob_start();
     $log = Logger::getLogger('LoggerTest');
     $log->error("my message");
     $line = __LINE__;
     $actual = ob_get_contents();
     ob_end_clean();
     $file = __FILE__;
     $class = __CLASS__;
     $method = __FUNCTION__;
     $expected = "ERROR  LoggerTest: my message from {$class}::{$method}() in {$file} at {$line}" . PHP_EOL;
     self::assertSame($expected, $actual);
     Logger::resetConfiguration();
 }
 public function testLocation2()
 {
     $config = LoggerTestHelper::getEchoPatternConfig("%location");
     Logger::configure($config);
     // Test by capturing output. Logging methods of a Logger object must
     // be used for the location info to be formed correctly.
     ob_start();
     $log = Logger::getLogger('foo');
     $log->info('foo');
     $line = __LINE__;
     // Do NOT move this to next line.
     $actual = ob_get_contents();
     ob_end_clean();
     $class = __CLASS__;
     $func = __FUNCTION__;
     $file = __FILE__;
     $expected = "{$class}.{$func}({$file}:{$line})";
     self::assertSame($expected, $actual);
     Logger::resetConfiguration();
 }