| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | // |
|---|
| 4 | // Open Web Analytics - An Open Source Web Analytics Framework |
|---|
| 5 | // |
|---|
| 6 | // Copyright 2006 Peter Adams. All rights reserved. |
|---|
| 7 | // |
|---|
| 8 | // Licensed under GPL v2.0 http://www.gnu.org/copyleft/gpl.html |
|---|
| 9 | // |
|---|
| 10 | // Unless required by applicable law or agreed to in writing, software |
|---|
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
|---|
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|---|
| 13 | // See the License for the specific language governing permissions and |
|---|
| 14 | // limitations under the License. |
|---|
| 15 | // |
|---|
| 16 | // $Id$ |
|---|
| 17 | // |
|---|
| 18 | |
|---|
| 19 | require_once(OWA_PEARLOG_DIR . DIRECTORY_SEPARATOR . 'Log.php'); |
|---|
| 20 | require_once(OWA_PLUGIN_DIR . 'log/queue.php'); |
|---|
| 21 | require_once(OWA_PLUGIN_DIR . 'log/async_queue.php'); |
|---|
| 22 | require_once(OWA_BASE_CLASSES_DIR. 'owa_observer.php'); |
|---|
| 23 | |
|---|
| 24 | /** |
|---|
| 25 | * Event Queue |
|---|
| 26 | * |
|---|
| 27 | * @author Peter Adams <peter@openwebanalytics.com> |
|---|
| 28 | * @copyright Copyright © 2006 Peter Adams <peter@openwebanalytics.com> |
|---|
| 29 | * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 |
|---|
| 30 | * @category owa |
|---|
| 31 | * @package owa |
|---|
| 32 | * @version $Revision$ |
|---|
| 33 | * @since owa 1.0.0 |
|---|
| 34 | */ |
|---|
| 35 | class eventQueue { |
|---|
| 36 | |
|---|
| 37 | /** |
|---|
| 38 | * Configuration |
|---|
| 39 | * |
|---|
| 40 | * @var array |
|---|
| 41 | */ |
|---|
| 42 | var $config; |
|---|
| 43 | |
|---|
| 44 | /** |
|---|
| 45 | * Constructor |
|---|
| 46 | * |
|---|
| 47 | * @return eventQueue |
|---|
| 48 | */ |
|---|
| 49 | function eventQueue() { |
|---|
| 50 | |
|---|
| 51 | return; |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | /** |
|---|
| 55 | * Event Queue factory |
|---|
| 56 | * @static |
|---|
| 57 | * @return object |
|---|
| 58 | * @access public |
|---|
| 59 | */ |
|---|
| 60 | function &get_instance() { |
|---|
| 61 | |
|---|
| 62 | static $eq; |
|---|
| 63 | |
|---|
| 64 | $c = &owa_coreAPI::configSingleton(); |
|---|
| 65 | $this->config = $c->fetch('base'); |
|---|
| 66 | |
|---|
| 67 | if (!isset($eq)): |
|---|
| 68 | // Create an async event queue |
|---|
| 69 | if ($this->config['async_db'] == true): |
|---|
| 70 | $conf = array('mode' => 0600, 'timeFormat' => '%X %x'); |
|---|
| 71 | $eq = &Log::singleton('async_queue', $this->config['async_log_dir'].$this->config['async_log_file'], 'async_event_queue', $conf); |
|---|
| 72 | $eq->_lineFormat = '%1$s|*|%2$s|*|[%3$s]|*|%4$s|*|%5$s'; |
|---|
| 73 | // not sure why this is needed but it is. |
|---|
| 74 | $eq->_filename = $this->config['async_log_dir'].$this->config['async_log_file']; |
|---|
| 75 | else: |
|---|
| 76 | //Create a normal event queue using 'queue' which is an extension to PEAR LOG. |
|---|
| 77 | $eq = Log::singleton('queue', '', 'event_queue'); |
|---|
| 78 | endif; |
|---|
| 79 | endif; |
|---|
| 80 | |
|---|
| 81 | return $eq; |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | ?> |
|---|