PageRenderTime 39ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/Service/WindowsAzure/Log/Formatter/WindowsAzure.php

https://bitbucket.org/bigstylee/zend-framework
PHP | 72 lines | 21 code | 8 blank | 43 comment | 3 complexity | 4ce773fe00ced086c91e1ebcd6661ec6 MD5 | raw file
  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. * @see Zend_Service_Log_Formatter_Interface
  24. */
  25. require_once 'Zend/Service/Log/Formatter/Interface.php';
  26. /**
  27. * @see Zend_Service_WindowsAzure_Storage_DynamicTableEntity
  28. */
  29. require_once 'Zend/Service/WindowsAzure/Storage/DynamicTableEntity.php';
  30. /**
  31. * @category Zend
  32. * @package Zend_Service_WindowsAzure
  33. * @subpackage Log
  34. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. */
  37. class Zend_Service_WindowsAzure_Log_Formatter_WindowsAzure implements Zend_Service_Log_Formatter_Interface
  38. {
  39. /**
  40. * Write a message to the table storage
  41. *
  42. * @param array $event
  43. * @return Zend_Service_WindowsAzure_Storage_DynamicTableEntity
  44. */
  45. public function format($event)
  46. {
  47. // partition key is the current date, represented as YYYYMMDD
  48. // row key will always be the current timestamp. These values MUST be hardcoded.
  49. $logEntity = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity(
  50. date('Ymd'), microtime(true));
  51. // Windows Azure automatically adds the timestamp, but the timezone is most of the time
  52. // different compared to the origin server's timezone, so add this timestamp aswell.
  53. $event['server_timestamp'] = $event['timestamp'];
  54. unset($event['timestamp']);
  55. foreach ($event as $key => $value) {
  56. if ((is_object($value) && !method_exists($value,'__toString'))
  57. || is_array($value)) {
  58. $value = gettype($value);
  59. }
  60. $logEntity->{$key} = $value;
  61. }
  62. return $logEntity;
  63. }
  64. }