File indexing completed on 2024-12-29 05:28:03
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Service_WindowsAzure 0017 * @subpackage Storage 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** 0024 * @see Zend_Log_Formatter_Interface 0025 */ 0026 // require_once 'Zend/Log/Formatter/Interface.php'; 0027 0028 /** 0029 * @see Zend_Service_WindowsAzure_Storage_DynamicTableEntity 0030 */ 0031 // require_once 'Zend/Service/WindowsAzure/Storage/DynamicTableEntity.php'; 0032 0033 /** 0034 * @category Zend 0035 * @package Zend_Service_WindowsAzure 0036 * @subpackage Log 0037 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0038 * @license http://framework.zend.com/license/new-bsd New BSD License 0039 */ 0040 class Zend_Service_WindowsAzure_Log_Formatter_WindowsAzure 0041 implements Zend_Log_Formatter_Interface 0042 { 0043 /** 0044 * Write a message to the table storage 0045 * 0046 * @param array $event 0047 * 0048 * @return Zend_Service_WindowsAzure_Storage_DynamicTableEntity 0049 */ 0050 public function format($event) 0051 { 0052 // partition key is the current date, represented as YYYYMMDD 0053 // row key will always be the current timestamp. These values MUST be hardcoded. 0054 $logEntity = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity( 0055 date('Ymd'), microtime(true) 0056 ); 0057 // Windows Azure automatically adds the timestamp, but the timezone is most of the time 0058 // different compared to the origin server's timezone, so add this timestamp aswell. 0059 $event['server_timestamp'] = $event['timestamp']; 0060 unset($event['timestamp']); 0061 0062 foreach ($event as $key => $value) { 0063 if ((is_object($value) && !method_exists($value, '__toString')) 0064 || is_array($value) 0065 ) { 0066 $value = gettype($value); 0067 } 0068 $logEntity->{$key} = $value; 0069 } 0070 0071 return $logEntity; 0072 } 0073 }