ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Monolog\Handler\TestHandler Class Reference

Used for testing purposes. More...

+ Inheritance diagram for Monolog\Handler\TestHandler:
+ Collaboration diagram for Monolog\Handler\TestHandler:

Public Member Functions

 getRecords ()
 
 hasRecordThatContains ($message, $level)
 
 hasRecordThatMatches ($regex, $level)
 
 hasRecordThatPasses ($predicate, $level)
 
 __call ($method, $args)
 
- Public Member Functions inherited from Monolog\Handler\AbstractProcessingHandler
 handle (array $record)
 {Handles a record.All records may be passed to this method, and the handler should discard those that it does not want to handle.The return value of this function controls the bubbling process of the handler stack. Unless the bubbling is interrupted (by returning true), the Logger class will keep on calling further handlers in the stack with a given log record.
Parameters
array$recordThe record to handle
Returns
Boolean true means that this handler handled the record, and that bubbling is not permitted. false means the record was either not processed or that this handler allows bubbling.
} More...
 
- Public Member Functions inherited from Monolog\Handler\AbstractHandler
 __construct ($level=Logger::DEBUG, $bubble=true)
 
 isHandling (array $record)
 {Checks whether the given record will be handled by this handler.This is mostly done for performance reasons, to avoid calling processors for nothing.Handlers should still check the record levels within handle(), returning false in isHandling() is no guarantee that handle() will not be called, and isHandling() might not be called for a given record.
Parameters
array$recordPartial log record containing only a level key
Returns
Boolean
} More...
 
 handleBatch (array $records)
 {Handles a set of records at once.
Parameters
array$recordsThe records to handle (an array of record arrays)
} More...
 
 close ()
 Closes the handler. More...
 
 pushProcessor ($callback)
 {Adds a processor in the stack.
Parameters
callable$callback
Returns
self
} More...
 
 popProcessor ()
 {Removes the processor on top of the stack and returns it.
Returns
callable
} More...
 
 setFormatter (FormatterInterface $formatter)
 {Sets the formatter.
Parameters
FormatterInterface$formatter
Returns
self
} More...
 
 getFormatter ()
 {Gets the formatter.
Returns
FormatterInterface
} More...
 
 setLevel ($level)
 Sets minimum logging level at which this handler will be triggered. More...
 
 getLevel ()
 Gets minimum logging level at which this handler will be triggered. More...
 
 setBubble ($bubble)
 Sets the bubbling behavior. More...
 
 getBubble ()
 Gets the bubbling behavior. More...
 
 __destruct ()
 

Protected Member Functions

 hasRecordRecords ($level)
 
 hasRecord ($record, $level)
 
 write (array $record)
 {} More...
 
- Protected Member Functions inherited from Monolog\Handler\AbstractProcessingHandler
 write (array $record)
 Writes the record down to the log of the implementing handler. More...
 
 processRecord (array $record)
 Processes a record. More...
 
- Protected Member Functions inherited from Monolog\Handler\AbstractHandler
 getDefaultFormatter ()
 Gets the default formatter. More...
 

Protected Attributes

 $records = array()
 
 $recordsByLevel = array()
 
- Protected Attributes inherited from Monolog\Handler\AbstractHandler
 $level = Logger::DEBUG
 
 $bubble = true
 
 $formatter
 
 $processors = array()
 

Detailed Description

Used for testing purposes.

It records all records and gives you access to them for verification.

Author
Jordi Boggiano j.bog.nosp@m.gian.nosp@m.o@sel.nosp@m.d.be

boolean hasEmergency($record) boolean hasAlert($record) boolean hasCritical($record) boolean hasError($record) boolean hasWarning($record) boolean hasNotice($record) boolean hasInfo($record) boolean hasDebug($record)

boolean hasEmergencyRecords() boolean hasAlertRecords() boolean hasCriticalRecords() boolean hasErrorRecords() boolean hasWarningRecords() boolean hasNoticeRecords() boolean hasInfoRecords() boolean hasDebugRecords()

boolean hasEmergencyThatContains($message) boolean hasAlertThatContains($message) boolean hasCriticalThatContains($message) boolean hasErrorThatContains($message) boolean hasWarningThatContains($message) boolean hasNoticeThatContains($message) boolean hasInfoThatContains($message) boolean hasDebugThatContains($message)

boolean hasEmergencyThatMatches($message) boolean hasAlertThatMatches($message) boolean hasCriticalThatMatches($message) boolean hasErrorThatMatches($message) boolean hasWarningThatMatches($message) boolean hasNoticeThatMatches($message) boolean hasInfoThatMatches($message) boolean hasDebugThatMatches($message)

boolean hasEmergencyThatPasses($message) boolean hasAlertThatPasses($message) boolean hasCriticalThatPasses($message) boolean hasErrorThatPasses($message) boolean hasWarningThatPasses($message) boolean hasNoticeThatPasses($message) boolean hasInfoThatPasses($message) boolean hasDebugThatPasses($message)

Definition at line 68 of file TestHandler.php.

Member Function Documentation

◆ __call()

Monolog\Handler\TestHandler::__call (   $method,
  $args 
)

Definition at line 137 of file TestHandler.php.

References Monolog\Handler\AbstractHandler\$level.

138  {
139  if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
140  $genericMethod = $matches[1] . 'Record' . $matches[3];
141  $level = constant('Monolog\Logger::' . strtoupper($matches[2]));
142  if (method_exists($this, $genericMethod)) {
143  $args[] = $level;
144  return call_user_func_array(array($this, $genericMethod), $args);
145  }
146  }
147 
148  throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()');
149  }

◆ getRecords()

Monolog\Handler\TestHandler::getRecords ( )

Definition at line 73 of file TestHandler.php.

References Monolog\Handler\TestHandler\$records.

Referenced by Monolog\LoggerTest\testChannel(), Monolog\LoggerTest\testLogMethods(), and Monolog\LoggerTest\testSetTimezone().

74  {
75  return $this->records;
76  }
+ Here is the caller graph for this function:

◆ hasRecord()

Monolog\Handler\TestHandler::hasRecord (   $record,
  $level 
)
protected

Definition at line 83 of file TestHandler.php.

References Monolog\Handler\AbstractHandler\$level, and Monolog\Handler\TestHandler\hasRecordThatPasses().

84  {
85  if (is_array($record)) {
86  $record = $record['message'];
87  }
88 
89  return $this->hasRecordThatPasses(function($rec) use ($record) {
90  return $rec['message'] === $record;
91  }, $level);
92  }
hasRecordThatPasses($predicate, $level)
+ Here is the call graph for this function:

◆ hasRecordRecords()

Monolog\Handler\TestHandler::hasRecordRecords (   $level)
protected

Definition at line 78 of file TestHandler.php.

References Monolog\Handler\AbstractHandler\$level.

79  {
80  return isset($this->recordsByLevel[$level]);
81  }

◆ hasRecordThatContains()

Monolog\Handler\TestHandler::hasRecordThatContains (   $message,
  $level 
)

Definition at line 94 of file TestHandler.php.

References Monolog\Handler\AbstractHandler\$level, and Monolog\Handler\TestHandler\hasRecordThatPasses().

95  {
96  return $this->hasRecordThatPasses(function($rec) use ($message) {
97  return strpos($rec['message'], $message) !== false;
98  }, $level);
99  }
hasRecordThatPasses($predicate, $level)
+ Here is the call graph for this function:

◆ hasRecordThatMatches()

Monolog\Handler\TestHandler::hasRecordThatMatches (   $regex,
  $level 
)

Definition at line 101 of file TestHandler.php.

References Monolog\Handler\AbstractHandler\$level, and Monolog\Handler\TestHandler\hasRecordThatPasses().

102  {
103  return $this->hasRecordThatPasses(function($rec) use ($regex) {
104  return preg_match($regex, $rec['message']) > 0;
105  }, $level);
106  }
hasRecordThatPasses($predicate, $level)
+ Here is the call graph for this function:

◆ hasRecordThatPasses()

Monolog\Handler\TestHandler::hasRecordThatPasses (   $predicate,
  $level 
)

Definition at line 108 of file TestHandler.php.

References Monolog\Handler\AbstractHandler\$level.

Referenced by Monolog\Handler\TestHandler\hasRecord(), Monolog\Handler\TestHandler\hasRecordThatContains(), and Monolog\Handler\TestHandler\hasRecordThatMatches().

109  {
110  if (!is_callable($predicate)) {
111  throw new \InvalidArgumentException("Expected a callable for hasRecordThatSucceeds");
112  }
113 
114  if (!isset($this->recordsByLevel[$level])) {
115  return false;
116  }
117 
118  foreach ($this->recordsByLevel[$level] as $i => $rec) {
119  if (call_user_func($predicate, $rec, $i)) {
120  return true;
121  }
122  }
123 
124  return false;
125  }
+ Here is the caller graph for this function:

◆ write()

Monolog\Handler\TestHandler::write ( array  $record)
protected

{}

Definition at line 130 of file TestHandler.php.

131  {
132  $this->recordsByLevel[$record['level']][] = $record;
133  $this->records[] = $record;
134  }

Field Documentation

◆ $records

Monolog\Handler\TestHandler::$records = array()
protected

Definition at line 70 of file TestHandler.php.

Referenced by Monolog\Handler\TestHandler\getRecords().

◆ $recordsByLevel

Monolog\Handler\TestHandler::$recordsByLevel = array()
protected

Definition at line 71 of file TestHandler.php.


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