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

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

class EbatNs_LoggerWire extends EbatNs_Logger
{
	protected $Request = '';
	protected $Response = '';
	function __construct()
	{
		parent::__construct(false, '', false, false);
	}
	
	function log($msg, $subject = null)
	{
		if ($subject == 'Request')
		{
			$this->Request = $msg;
		}
		else
		{
			if ($subject == 'Response' || $subject == 'ResponseRaw')
			{
			    $this->Response = $msg;
			}
		}
	}
	
	function getFullWireLog($beautifyRequest = true)
	{
		if ($beautifyRequest === true)
		{
			require_once 'XML/Beautifier.php';
			$xmlb = new XML_Beautifier();
			$this->Request = $xmlb->formatString($this->Request);
		}
		
		return $this->_RequestUrl .
			($this->debugHtml ? "<br>" : "\n") .
			($this->debugHtml ? htmlentities($this->Request) :  $this->Request) .
			($this->debugHtml ? "<br>" : "\n") .
			($this->debugHtml ? htmlentities($this->Response) : $this->Response);
	}
}
?>
Back to Top