MediaWiki  1.33.0
TestLogger Class Reference

A logger that may be configured to either buffer logs or to print them to the output where PHPUnit will complain about them. More...

Inheritance diagram for TestLogger:
Collaboration diagram for TestLogger:

Public Member Functions

 __construct ( $collect=false, $filter=null, $collectContext=false)
 
 clearBuffer ()
 Clear the collected log buffer. More...
 
 getBuffer ()
 Return the collected logs. More...
 
 log ( $level, $message, array $context=[])
 
 setCollect ( $collect)
 Set the "collect" flag. More...
 
 setCollectContext ( $collectContext)
 Set the collectContext flag. More...
 

Private Attributes

 $buffer = []
 
 $collect = false
 
 $collectContext = false
 
 $filter = null
 

Detailed Description

A logger that may be configured to either buffer logs or to print them to the output where PHPUnit will complain about them.

Since
1.27

Definition at line 33 of file TestLogger.php.

Constructor & Destructor Documentation

◆ __construct()

TestLogger::__construct (   $collect = false,
  $filter = null,
  $collectContext = false 
)
Parameters
bool$collectWhether to collect logs.
See also
setCollect()
Parameters
callable | null$filterFilter logs before collecting/printing. Signature is string|null function ( string $message, string $level, array $context );
bool$collectContextWhether to keep the context passed to log (since 1.29,
See also
setCollectContext()).

Definition at line 46 of file TestLogger.php.

References $collect, $collectContext, and $filter.

Member Function Documentation

◆ clearBuffer()

TestLogger::clearBuffer ( )

Clear the collected log buffer.

Definition at line 86 of file TestLogger.php.

Referenced by MediaWiki\Session\SessionManagerTest\testLoadSessionInfoFromStore().

◆ getBuffer()

TestLogger::getBuffer ( )

Return the collected logs.

Returns
array Array of array( string $level, string $message ), or array( string $level, string $message, array $context ) if $collectContext was true.

Definition at line 79 of file TestLogger.php.

References $buffer.

Referenced by MediaWiki\Session\SessionManagerTest\testLoadSessionInfoFromStore().

◆ log()

TestLogger::log (   $level,
  $message,
array  $context = [] 
)

Definition at line 90 of file TestLogger.php.

References $context.

◆ setCollect()

TestLogger::setCollect (   $collect)

Set the "collect" flag.

Parameters
bool$collect
Returns
TestLogger $this

Definition at line 57 of file TestLogger.php.

References $collect.

◆ setCollectContext()

TestLogger::setCollectContext (   $collectContext)

Set the collectContext flag.

Parameters
bool$collectContext
Since
1.29
Returns
TestLogger $this

Definition at line 69 of file TestLogger.php.

References $collectContext.

Member Data Documentation

◆ $buffer

TestLogger::$buffer = []
private

Definition at line 36 of file TestLogger.php.

Referenced by getBuffer().

◆ $collect

TestLogger::$collect = false
private

Definition at line 34 of file TestLogger.php.

Referenced by __construct(), and setCollect().

◆ $collectContext

TestLogger::$collectContext = false
private

Definition at line 35 of file TestLogger.php.

Referenced by __construct(), and setCollectContext().

◆ $filter

TestLogger::$filter = null
private

Definition at line 37 of file TestLogger.php.

Referenced by __construct().


The documentation for this class was generated from the following file: