|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Service_WindowsAzure |
|
17 * @subpackage Storage |
|
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 * @version $Id$ |
|
21 */ |
|
22 |
|
23 /** |
|
24 * @see Zend_Log_Formatter_Interface |
|
25 */ |
|
26 require_once 'Zend/Log/Formatter/Interface.php'; |
|
27 |
|
28 /** |
|
29 * @see Zend_Service_WindowsAzure_Storage_DynamicTableEntity |
|
30 */ |
|
31 require_once 'Zend/Service/WindowsAzure/Storage/DynamicTableEntity.php'; |
|
32 |
|
33 /** |
|
34 * @category Zend |
|
35 * @package Zend_Service_WindowsAzure |
|
36 * @subpackage Log |
|
37 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
|
38 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
39 */ |
|
40 class Zend_Service_WindowsAzure_Log_Formatter_WindowsAzure |
|
41 implements Zend_Log_Formatter_Interface |
|
42 { |
|
43 /** |
|
44 * Write a message to the table storage |
|
45 * |
|
46 * @param array $event |
|
47 * |
|
48 * @return Zend_Service_WindowsAzure_Storage_DynamicTableEntity |
|
49 */ |
|
50 public function format($event) |
|
51 { |
|
52 // partition key is the current date, represented as YYYYMMDD |
|
53 // row key will always be the current timestamp. These values MUST be hardcoded. |
|
54 $logEntity = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity( |
|
55 date('Ymd'), microtime(true) |
|
56 ); |
|
57 // Windows Azure automatically adds the timestamp, but the timezone is most of the time |
|
58 // different compared to the origin server's timezone, so add this timestamp aswell. |
|
59 $event['server_timestamp'] = $event['timestamp']; |
|
60 unset($event['timestamp']); |
|
61 |
|
62 foreach ($event as $key => $value) { |
|
63 if ((is_object($value) && !method_exists($value, '__toString')) |
|
64 || is_array($value) |
|
65 ) { |
|
66 $value = gettype($value); |
|
67 } |
|
68 $logEntity->{$key} = $value; |
|
69 } |
|
70 |
|
71 return $logEntity; |
|
72 } |
|
73 } |