diff --git a/lib/Cake/Log/Log.php b/lib/Cake/Log/Log.php index 858ff839f56..e5d75869785 100644 --- a/lib/Cake/Log/Log.php +++ b/lib/Cake/Log/Log.php @@ -192,18 +192,6 @@ public static function reset() { static::$_registry = null; } -/** - * @deprecated Use Configure::write() to configure logging. - * @see App/Config/logging.php - * @return void - */ - public static function config($key, $config) { - trigger_error( - __d('cake_dev', 'You must use Configure::write() to define logging configuration. Or use engine() to inject new adapter.'), - E_USER_WARNING - ); - } - /** * Returns the keynames of the currently active streams * @@ -226,6 +214,18 @@ public static function levels() { return static::$_levels; } +/** + * @deprecated Use Configure::write() to configure logging. + * @see App/Config/logging.php + * @return void + */ + public static function config($key, $config) { + trigger_error( + __d('cake_dev', 'You must use Configure::write() to define logging configuration. Or use engine() to inject new adapter.'), + E_USER_WARNING + ); + } + /** * Removes a stream from the active streams. Once a stream has been removed * it will no longer have messages sent to it. @@ -239,51 +239,39 @@ public static function drop($streamName) { } /** - * Checks wether $streamName is enabled + * Checks whether $streamName is enabled * * @param string $streamName to check * @return bool * @throws Cake\Error\Exception + * @deprecated This method will be removed in 3.0 stable. */ public static function enabled($streamName) { - static::_init(); - if (!isset(static::$_registry->{$streamName})) { - throw new Error\Exception(__d('cake_dev', 'Stream %s not found', $streamName)); - } - return static::$_registry->enabled($streamName); + throw new Error\Exception(__d('cake_dev', 'Log::enabled() is deprecated. Use Log::configured() instead.')); } /** - * Enable stream. Streams that were previously disabled - * can be re-enabled with this method. + * Enable stream. * * @param string $streamName to enable * @return void * @throws Cake\Error\Exception + * @deprecated This method will be removed in 3.0 stable. */ public static function enable($streamName) { - static::_init(); - if (!isset(static::$_registry->{$streamName})) { - throw new Error\Exception(__d('cake_dev', 'Stream %s not found', $streamName)); - } - static::$_registry->enable($streamName); + throw new Error\Exception(__d('cake_dev', 'Log::enable() is deprecated. Use Log::engine() instead.')); } /** - * Disable stream. Disabling a stream will - * prevent that log stream from receiving any messages until - * its re-enabled. + * Disable stream. * * @param string $streamName to disable * @return void * @throws Cake\Error\Exception + * @deprecated This method will be removed in 3.0 stable. */ public static function disable($streamName) { - static::_init(); - if (!isset(static::$_registry->{$streamName})) { - throw new Error\Exception(__d('cake_dev', 'Stream %s not found', $streamName)); - } - static::$_registry->disable($streamName); + throw new Error\Exception(__d('cake_dev', 'Log::disable() is deprecated. Use Log::drop() instead.')); } /** diff --git a/lib/Cake/Test/TestCase/Log/LogTest.php b/lib/Cake/Test/TestCase/Log/LogTest.php index 698d1ab7ad1..486520332de 100644 --- a/lib/Cake/Test/TestCase/Log/LogTest.php +++ b/lib/Cake/Test/TestCase/Log/LogTest.php @@ -217,53 +217,30 @@ public function testSelectiveLoggingByLevel() { } /** - * test enable + * test enable() throws exceptions * * @expectedException Cake\Error\Exception */ public function testStreamEnable() { - Configure::write('Log.spam', array( - 'engine' => 'File', - 'file' => 'spam', - )); - $this->assertTrue(Log::enabled('spam')); - Log::drop('spam'); - Log::enable('bogus_stream'); - } - -/** - * test disable - * - * @expectedException Cake\Error\Exception - */ - public function testStreamDisable() { - Configure::write('Log.spam', array( - 'engine' => 'File', - 'file' => 'spam', - )); - $this->assertTrue(Log::enabled('spam')); - Log::disable('spam'); - $this->assertFalse(Log::enabled('spam')); - Log::drop('spam'); - Log::enable('bogus_stream'); + Log::enable('debug'); } /** - * test enabled() invalid stream + * test enabled() throws exceptions * * @expectedException Cake\Error\Exception */ - public function testStreamEnabledInvalid() { - Log::enabled('bogus_stream'); + public function testStreamEnabled() { + Log::enabled('debug'); } /** - * test disable invalid stream + * test disable() throws exceptions * * @expectedException Cake\Error\Exception */ - public function testStreamDisableInvalid() { - Log::disable('bogus_stream'); + public function testStreamDisable() { + Log::disable('debug'); } protected function _resetLogConfig() {