mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-26 11:37:33 +00:00
- add real-time in-line logging capabilities to Net/SFTP.php (useful if you're dumping the output to a file or if you're trying to figure out why a script is timing out or something)
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@173 21d32557-59b3-4da0-833f-c5933fad653e
This commit is contained in:
parent
a5d702346a
commit
68a5d7d4db
@ -71,6 +71,10 @@ define('NET_SFTP_LOG_SIMPLE', NET_SSH2_LOG_SIMPLE);
|
||||
* Returns the message content
|
||||
*/
|
||||
define('NET_SFTP_LOG_COMPLEX', NET_SSH2_LOG_COMPLEX);
|
||||
/**
|
||||
* Outputs the message content in real-time.
|
||||
*/
|
||||
define('NET_SFTP_LOG_REALTIME', 3);
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
@ -1520,10 +1524,17 @@ class Net_SFTP extends Net_SSH2 {
|
||||
$stop = strtok(microtime(), ' ') + strtok('');
|
||||
|
||||
if (defined('NET_SFTP_LOGGING')) {
|
||||
$this->packet_type_log[] = '-> ' . $this->packet_types[$type] .
|
||||
' (' . round($stop - $start, 4) . 's)';
|
||||
if (NET_SFTP_LOGGING == NET_SFTP_LOG_COMPLEX) {
|
||||
$this->packet_log[] = $data;
|
||||
$packet_type = '-> ' . $this->packet_types[$type] .
|
||||
' (' . round($stop - $start, 4) . 's)';
|
||||
if (NET_SFTP_LOGGING == NET_SFTP_LOG_REALTIME) {
|
||||
echo $this->_format_log(array($data), array($packet_type));
|
||||
flush();
|
||||
ob_flush();
|
||||
} else {
|
||||
$this->packet_type_log[] = $packet_type;
|
||||
if (NET_SFTP_LOGGING == NET_SFTP_LOG_COMPLEX) {
|
||||
$this->packet_log[] = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1587,10 +1598,17 @@ class Net_SFTP extends Net_SSH2 {
|
||||
$packet = $this->_string_shift($this->packet_buffer, $length);
|
||||
|
||||
if (defined('NET_SFTP_LOGGING')) {
|
||||
$this->packet_type_log[] = '<- ' . $this->packet_types[$this->packet_type] .
|
||||
' (' . round($stop - $start, 4) . 's)';
|
||||
if (NET_SFTP_LOGGING == NET_SFTP_LOG_COMPLEX) {
|
||||
$this->packet_log[] = $packet;
|
||||
$packet_type = '<- ' . $this->packet_types[$this->packet_type] .
|
||||
' (' . round($stop - $start, 4) . 's)';
|
||||
if (NET_SFTP_LOGGING == NET_SFTP_LOG_REALTIME) {
|
||||
echo $this->_format_log(array($packet), array($packet_type));
|
||||
flush();
|
||||
ob_flush();
|
||||
} else {
|
||||
$this->packet_type_log[] = $packet_type;
|
||||
if (NET_SFTP_LOGGING == NET_SFTP_LOG_COMPLEX) {
|
||||
$this->packet_log[] = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user