diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-05-19 12:00:19 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-05-19 12:00:19 +0200 |
commit | a52afb040a9bb64d782df7aabcfd0075fbfd4064 (patch) | |
tree | 7916594bbeb914a4e6f685f884af1c4c466e88d6 /tests | |
parent | d90b83725f87825a68b51a32228270d9e9a82ac6 (diff) | |
parent | e79c255cabecb768061bb58ea508a38011ef6284 (diff) | |
download | nextcloud-server-a52afb040a9bb64d782df7aabcfd0075fbfd4064.tar.gz nextcloud-server-a52afb040a9bb64d782df7aabcfd0075fbfd4064.zip |
Merge pull request #15965 from owncloud/conditional-logging
Conditional logging
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/logger.php | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/tests/lib/logger.php b/tests/lib/logger.php index 700a847917b..9a9f5be12fc 100644 --- a/tests/lib/logger.php +++ b/tests/lib/logger.php @@ -21,14 +21,38 @@ class Logger extends TestCase { parent::setUp(); self::$logs = array(); - $this->logger = new Log('Test\Logger'); + $this->config = $this->getMockBuilder( + '\OC\SystemConfig') + ->disableOriginalConstructor() + ->getMock(); + $this->logger = new Log('Test\Logger', $this->config); } public function testInterpolation() { $logger = $this->logger; - $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar')); + $logger->warning('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar')); - $expected = array('1 {Message {nothing} Bob Bar a}'); + $expected = array('2 {Message {nothing} Bob Bar a}'); + $this->assertEquals($expected, $this->getLogs()); + } + + public function testAppCondition() { + $this->config->expects($this->any()) + ->method('getValue') + ->will(($this->returnValueMap([ + ['loglevel', \OC_Log::WARN, \OC_Log::WARN], + ['log.condition', [], ['apps' => ['files']]] + ]))); + $logger = $this->logger; + + $logger->info('Don\'t display info messages'); + $logger->info('Show info messages of files app', ['app' => 'files']); + $logger->warning('Show warning messages of other apps'); + + $expected = [ + '1 Show info messages of files app', + '2 Show warning messages of other apps', + ]; $this->assertEquals($expected, $this->getLogs()); } |