BaseLog.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * Base Log Engine class
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * For full copyright and license information, please see the LICENSE.txt
  12. * Redistributions of files must retain the above copyright notice.
  13. *
  14. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  15. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
  16. * @package Cake.Log.Engine
  17. * @since CakePHP(tm) v 2.2
  18. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  19. */
  20. App::uses('CakeLogInterface', 'Log');
  21. /**
  22. * Base log engine class.
  23. *
  24. * @package Cake.Log.Engine
  25. */
  26. abstract class BaseLog implements CakeLogInterface {
  27. /**
  28. * Engine config
  29. *
  30. * @var string
  31. */
  32. protected $_config = array();
  33. /**
  34. * __construct method
  35. *
  36. * @param array $config Configuration array
  37. * @return void
  38. */
  39. public function __construct($config = array()) {
  40. $this->config($config);
  41. }
  42. /**
  43. * Sets instance config. When $config is null, returns config array
  44. *
  45. * Config
  46. *
  47. * - `types` string or array, levels the engine is interested in
  48. * - `scopes` string or array, scopes the engine is interested in
  49. *
  50. * @param array $config engine configuration
  51. * @return array
  52. */
  53. public function config($config = array()) {
  54. if (!empty($config)) {
  55. foreach (array('types', 'scopes') as $option) {
  56. if (isset($config[$option]) && is_string($config[$option])) {
  57. $config[$option] = array($config[$option]);
  58. }
  59. }
  60. $this->_config = $config;
  61. }
  62. return $this->_config;
  63. }
  64. }