ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Monolog\Processor\GitProcessor Class Reference

Injects Git branch and Git commit SHA in all records. More...

+ Collaboration diagram for Monolog\Processor\GitProcessor:

Public Member Functions

 __construct ($level=Logger::DEBUG)
 
 __invoke (array $record)
 

Static Private Member Functions

static getGitInfo ()
 

Private Attributes

 $level
 

Static Private Attributes

static $cache
 

Detailed Description

Injects Git branch and Git commit SHA in all records.

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

Definition at line 22 of file GitProcessor.php.

Constructor & Destructor Documentation

◆ __construct()

Monolog\Processor\GitProcessor::__construct (   $level = Logger::DEBUG)

Definition at line 27 of file GitProcessor.php.

References Monolog\Processor\GitProcessor\$level, and Monolog\Logger\toMonologLevel().

28  {
29  $this->level = Logger::toMonologLevel($level);
30  }
static toMonologLevel($level)
Converts PSR-3 levels to Monolog ones if necessary.
Definition: Logger.php:473
+ Here is the call graph for this function:

Member Function Documentation

◆ __invoke()

Monolog\Processor\GitProcessor::__invoke ( array  $record)
Parameters
array$record
Returns
array

Definition at line 36 of file GitProcessor.php.

37  {
38  // return if the level is not high enough
39  if ($record['level'] < $this->level) {
40  return $record;
41  }
42 
43  $record['extra']['git'] = self::getGitInfo();
44 
45  return $record;
46  }

◆ getGitInfo()

static Monolog\Processor\GitProcessor::getGitInfo ( )
staticprivate

Definition at line 48 of file GitProcessor.php.

References array.

49  {
50  if (self::$cache) {
51  return self::$cache;
52  }
53 
54  $branches = `git branch -v --no-abbrev`;
55  if (preg_match('{^\* (.+?)\s+([a-f0-9]{40})(?:\s|$)}m', $branches, $matches)) {
56  return self::$cache = array(
57  'branch' => $matches[1],
58  'commit' => $matches[2],
59  );
60  }
61 
62  return self::$cache = array();
63  }
Create styles array
The data for the language used.

Field Documentation

◆ $cache

Monolog\Processor\GitProcessor::$cache
staticprivate

Definition at line 25 of file GitProcessor.php.

◆ $level

Monolog\Processor\GitProcessor::$level
private

Definition at line 24 of file GitProcessor.php.

Referenced by Monolog\Processor\GitProcessor\__construct().


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