PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/wp-lister-for-ebay/includes/EbatNs/EbatNs_Logger.php

https://bitbucket.org/sanders_nick/my-maxi-skirt
PHP | 122 lines | 105 code | 10 blank | 7 comment | 16 complexity | 16904598bf8b802f191d2807ef7a8a39 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, AGPL-1.0, GPL-3.0, LGPL-2.1
  1. <?php
  2. // $Id: EbatNs_Logger.php,v 1.2 2008-05-02 15:04:05 carsten Exp $
  3. // $Log: EbatNs_Logger.php,v $
  4. // Revision 1.2 2008-05-02 15:04:05 carsten
  5. // Initial, PHP5
  6. //
  7. //
  8. class EbatNs_Logger
  9. {
  10. // debugging options
  11. protected $debugXmlBeautify = true;
  12. protected $debugLogDestination = 'stdout';
  13. protected $debugSecureLogging = true;
  14. protected $debugHtml = true;
  15. function __construct($beautfyXml = false, $destination = 'stdout', $asHtml = true, $SecureLogging = true)
  16. {
  17. $this->debugLogDestination = $destination;
  18. $this->debugXmlBeautify = $beautfyXml;
  19. $this->debugHtml = $asHtml;
  20. $this->debugSecureLogging = $SecureLogging;
  21. }
  22. function log($msg, $subject = null)
  23. {
  24. if ($this->debugLogDestination)
  25. {
  26. if ($this->debugLogDestination == 'stdout')
  27. {
  28. if ($this->debugHtml)
  29. {
  30. print_r("<pre>");
  31. if ($subject)
  32. print_r("$subject :<br>");
  33. print_r(htmlentities($msg) . "\r\n");
  34. print_r("</pre>");
  35. }
  36. else
  37. {
  38. if ($subject)
  39. print_r($subject . ' : ' . "\r\n");
  40. print_r($msg . "\r\n");
  41. }
  42. }
  43. else
  44. {
  45. ob_start();
  46. echo date('r') . "\t" . $subject . "\t";
  47. print_r($msg);
  48. echo "\r\n";
  49. error_log(ob_get_clean(), 3, $this->debugLogDestination);
  50. }
  51. }
  52. }
  53. function logXml($xmlMsg, $subject = null)
  54. {
  55. if ($this->debugSecureLogging)
  56. {
  57. $xmlMsg = preg_replace("/<eBayAuthToken>.*<\/eBayAuthToken>/", "<eBayAuthToken>...</eBayAuthToken>", $xmlMsg);
  58. $xmlMsg = preg_replace("/<AuthCert>.*<\/AuthCert>/", "<AuthCert>...</AuthCert>", $xmlMsg);
  59. }
  60. if ($this->debugXmlBeautify)
  61. {
  62. if (is_object($xmlMsg))
  63. $this->log($xmlMsg);
  64. else
  65. {
  66. require_once 'XML/Beautifier.php';
  67. $xmlb = new XML_Beautifier();
  68. $this->log($xmlb->formatString($xmlMsg), $subject);
  69. }
  70. return;
  71. }
  72. $this->log($xmlMsg, $subject);
  73. }
  74. }
  75. class EbatNs_LoggerWire extends EbatNs_Logger
  76. {
  77. protected $Request = '';
  78. protected $Response = '';
  79. function __construct()
  80. {
  81. parent::__construct(false, '', false, false);
  82. }
  83. function log($msg, $subject = null)
  84. {
  85. if ($subject == 'Request')
  86. {
  87. $this->Request = $msg;
  88. }
  89. else
  90. {
  91. if ($subject == 'Response' || $subject == 'ResponseRaw')
  92. {
  93. $this->Response = $msg;
  94. }
  95. }
  96. }
  97. function getFullWireLog($beautifyRequest = true)
  98. {
  99. if ($beautifyRequest === true)
  100. {
  101. require_once 'XML/Beautifier.php';
  102. $xmlb = new XML_Beautifier();
  103. $this->Request = $xmlb->formatString($this->Request);
  104. }
  105. return $this->_RequestUrl .
  106. ($this->debugHtml ? "<br>" : "\n") .
  107. ($this->debugHtml ? htmlentities($this->Request) : $this->Request) .
  108. ($this->debugHtml ? "<br>" : "\n") .
  109. ($this->debugHtml ? htmlentities($this->Response) : $this->Response);
  110. }
  111. }
  112. ?>