BaseLog.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 http://www.opensource.org/licenses/mit-license.php MIT License
  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. */
  38. public function __construct($config = array()) {
  39. $this->config($config);
  40. }
  41. /**
  42. * Sets instance config. When $config is null, returns config array
  43. *
  44. * Config
  45. *
  46. * - `types` string or array, levels the engine is interested in
  47. * - `scopes` string or array, scopes the engine is interested in
  48. *
  49. * @param array $config engine configuration
  50. * @return array
  51. */
  52. public function config($config = array()) {
  53. if (!empty($config)) {
  54. foreach (array('types', 'scopes') as $option) {
  55. if (isset($config[$option]) && is_string($config[$option])) {
  56. $config[$option] = array($config[$option]);
  57. }
  58. }
  59. $this->_config = $config;
  60. }
  61. return $this->_config;
  62. }
  63. }