| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Mediawiki
Revision: 40468
Author: tstarling
Date: 04 Sep 2008 23:46:07
Changes:In wfDebugLog(): log the hostname if $wgShowHostnames is true. Cache the hostname.
Files:| ... | ...@@ -255,12 +255,17 @@ | |
| 255 | 255 | * log file is specified, (default true) |
| 256 | 256 | */ |
| 257 | 257 | function wfDebugLog( $logGroup, $text, $public = true ) { |
| 258 | global $wgDebugLogGroups; | |
| 258 | global $wgDebugLogGroups, $wgShowHostnames; | |
| 259 | 259 | if( $text{strlen( $text ) - 1} != "\n" ) $text .= "\n"; |
| 260 | 260 | if( isset( $wgDebugLogGroups[$logGroup] ) ) { |
| 261 | 261 | $time = wfTimestamp( TS_DB ); |
| 262 | 262 | $wiki = wfWikiID(); |
| 263 | wfErrorLog( "$time $wiki: $text", $wgDebugLogGroups[$logGroup] ); | |
| 263 | if ( $wgShowHostnames ) { | |
| 264 | $host = wfHostname(); | |
| 265 | } else { | |
| 266 | $host = ''; | |
| 267 | } | |
| 268 | wfErrorLog( "$time $host $wiki: $text", $wgDebugLogGroups[$logGroup] ); | |
| 264 | 269 | } else if ( $public === true ) { |
| 265 | 270 | wfDebug( $text, true ); |
| 266 | 271 | } |
| ... | ...@@ -767,18 +772,22 @@ | |
| 767 | 772 | * @return string |
| 768 | 773 | */ |
| 769 | 774 | function wfHostname() { |
| 770 | if ( function_exists( 'posix_uname' ) ) { | |
| 771 | // This function not present on Windows | |
| 772 | $uname = @posix_uname(); | |
| 773 | } else { | |
| 774 | $uname = false; | |
| 775 | } | |
| 776 | if( is_array( $uname ) && isset( $uname['nodename'] ) ) { | |
| 777 | return $uname['nodename']; | |
| 778 | } else { | |
| 779 | # This may be a virtual server. | |
| 780 | return $_SERVER['SERVER_NAME']; | |
| 775 | static $host; | |
| 776 | if ( is_null( $host ) ) { | |
| 777 | if ( function_exists( 'posix_uname' ) ) { | |
| 778 | // This function not present on Windows | |
| 779 | $uname = @posix_uname(); | |
| 780 | } else { | |
| 781 | $uname = false; | |
| 782 | } | |
| 783 | if( is_array( $uname ) && isset( $uname['nodename'] ) ) { | |
| 784 | $host = $uname['nodename']; | |
| 785 | } else { | |
| 786 | # This may be a virtual server. | |
| 787 | $host = $_SERVER['SERVER_NAME']; | |
| 788 | } | |
| 781 | 789 | } |
| 790 | return $host; | |
| 782 | 791 | } |
| 783 | 792 | |
| 784 | 793 | /** |