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: 
21: App::uses('CakeLogInterface', 'Log');
22: 
23: /**
24:  * Base log engine class.
25:  *
26:  * @package       Cake.Log.Engine
27:  */
28: abstract class BaseLog implements CakeLogInterface {
29: 
30: /**
31:  * Engine config
32:  *
33:  * @var string
34:  */
35:     protected $_config = array();
36: 
37: /**
38:  * __construct method
39:  *
40:  * @param array $config Configuration array
41:  * @return void
42:  */
43:     public function __construct($config = array()) {
44:         $this->config($config);
45:     }
46: 
47: /**
48:  * Sets instance config. When $config is null, returns config array
49:  *
50:  * Config
51:  *
52:  * - `types` string or array, levels the engine is interested in
53:  * - `scopes` string or array, scopes the engine is interested in
54:  *
55:  * @param array $config engine configuration
56:  * @return array
57:  */
58:     public function config($config = array()) {
59:         if (!empty($config)) {
60:             foreach (array('types', 'scopes') as $option) {
61:                 if (isset($config[$option]) && is_string($config[$option])) {
62:                     $config[$option] = array($config[$option]);
63:                 }
64:             }
65:             $this->_config = $config;
66:         }
67:         return $this->_config;
68:     }
69: 
70: }
71: