Go to the documentation of this file.
28 use Psr\Log\AbstractLogger;
63 LogLevel::DEBUG => 100,
64 LogLevel::INFO => 200,
65 LogLevel::NOTICE => 250,
66 LogLevel::WARNING => 300,
67 LogLevel::ERROR => 400,
68 LogLevel::CRITICAL => 500,
69 LogLevel::ALERT => 550,
70 LogLevel::EMERGENCY => 600,
78 'DBConnection' =>
true
99 if ( is_string( $level ) ) {
100 $level = self::$levelMapping[$level];
102 if ( $this->channel ===
'DBQuery'
126 if ( isset( self::$dbChannels[$this->channel] )
127 && $level >= self::$levelMapping[LogLevel::ERROR]
131 $effectiveChannel =
'wfLogDBError';
136 if ( self::shouldEmit( $effectiveChannel, $message, $level,
$context ) ) {
160 if ( is_string( $level ) ) {
161 $level = self::$levelMapping[$level];
164 if (
$channel ===
'wfLogDBError' ) {
169 } elseif (
$channel ===
'wfDebug' ) {
179 if ( is_array( $logConfig ) ) {
181 if ( isset( $logConfig[
'sample'] ) ) {
183 $shouldEmit = mt_rand( 1, $logConfig[
'sample'] ) === 1;
186 if ( isset( $logConfig[
'level'] ) ) {
187 $shouldEmit = $level >= self::$levelMapping[$logConfig[
'level']];
191 $shouldEmit = $logConfig !==
false;
227 } elseif (
$channel ===
'wfLogDBError' ) {
230 } elseif (
$channel ===
'profileoutput' ) {
233 if ( isset(
$context[
'forwarded_for'] ) ) {
234 $forward =
" forwarded for {$context['forwarded_for']}";
236 if ( isset(
$context[
'client_ip'] ) ) {
237 $forward .=
" client IP {$context['client_ip']}";
240 $forward .=
" from {$context['from']}";
243 $forward =
"\t(proxied via {$context['proxy']}{$forward})";
252 $log = sprintf(
"%s\t%04.3f\t%s%s\n",
272 if (
$e instanceof Exception ) {
275 } elseif ( is_array(
$e ) && isset(
$e[
'trace'] ) ) {
277 $backtrace =
$e[
'trace'];
298 $text = preg_replace(
'![\x00-\x08\x0b\x0c\x0e-\x1f]!',
' ', $message );
299 if ( isset(
$context[
'seconds_elapsed'] ) ) {
302 $text =
"{$context['seconds_elapsed']} {$context['memory_used']} {$text}";
304 if ( isset(
$context[
'prefix'] ) ) {
305 $text =
"{$context['prefix']}{$text}";
320 static $cachedTimezone =
null;
322 if ( !$cachedTimezone ) {
326 $d = date_create(
'now', $cachedTimezone );
327 $date = $d->format(
'D M j G:i:s T Y' );
332 $text =
"{$date}\t{$host}\t{$wiki}\t{$message}\n";
348 $text =
"{$time} {$host} {$wiki}: {$message}\n";
360 if ( strpos( $message,
'{' ) !==
false ) {
365 $message = strtr( $message, $replace );
378 if ( $item ===
null ) {
382 if ( is_bool( $item ) ) {
383 return $item ?
'true' :
'false';
386 if ( is_float( $item ) ) {
387 if ( is_infinite( $item ) ) {
388 return ( $item > 0 ?
'' :
'-' ) .
'INF';
390 if ( is_nan( $item ) ) {
393 return (
string)$item;
396 if ( is_scalar( $item ) ) {
397 return (
string)$item;
400 if ( is_array( $item ) ) {
401 return '[Array(' .
count( $item ) .
')]';
404 if ( $item instanceof \DateTime ) {
405 return $item->format(
'c' );
408 if ( $item instanceof Exception ) {
409 return '[Exception ' . get_class( $item ) .
'( ' .
410 $item->getFile() .
':' . $item->getLine() .
') ' .
411 $item->getMessage() .
']';
414 if ( is_object( $item ) ) {
415 if ( method_exists( $item,
'__toString' ) ) {
416 return (
string)$item;
419 return '[Object ' . get_class( $item ) .
']';
422 if ( is_resource( $item ) ) {
423 return '[Resource ' . get_resource_type( $item ) .
']';
426 return '[Unknown ' . gettype( $item ) .
']';
446 if ( isset(
$context[
'destination'] ) ) {
448 $destination =
$context[
'destination'];
450 } elseif (
$channel ===
'wfDebug' ) {
453 } elseif (
$channel ===
'wfLogDBError' ) {
459 if ( is_array( $logConfig ) ) {
460 $destination = $logConfig[
'destination'];
462 $destination = strval( $logConfig );
479 if ( substr(
$file, 0, 4 ) ==
'udp:' ) {
481 $transport->emit( $text );
483 \Wikimedia\suppressWarnings();
484 $exists = file_exists(
$file );
485 $size = $exists ? filesize(
$file ) :
false;
487 ( $size !==
false && $size + strlen( $text ) < 0x7fffffff )
489 file_put_contents(
$file, $text, FILE_APPEND );
491 \Wikimedia\restoreWarnings();
static newFromString( $info)
static getRedactedTrace( $e)
Return a copy of an exception's backtrace as an array.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
static getCurrentWikiDbDomain()
New debugger system that outputs a toolbar on page view.
Handler class for MWExceptions.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfHostname()
Fetch server name for use in error reporting etc.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
$wgDBerrorLog
File to log database errors to.
static prettyPrintTrace(array $trace, $pad='')
Generate a string representation of a stacktrace.
static getWikiIdFromDbDomain( $domain)
Get the wiki ID of a database domain.
static debugMsg( $str, $context=[])
This is a method to pass messages from wfDebug to the pretty debugger.
$wgDebugLogGroups
Map of string log group names to log destinations.
$wgLogExceptionBacktrace
If true, send the exception backtrace to the error log.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
$wgDebugLogFile
Filename for debug logging.
A generic class to send a message over UDP.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
static query( $sql, $function, $isMaster, $runTime)
Begins profiling on a database query.
Helper tools for dealing with other locally-hosted wikis.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
$wgDBerrorLogTZ
Timezone to use in the error log.
see documentation in includes Linker php for Linker::makeImageLink & $time