ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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.

28 {
29 $this->level = Logger::toMonologLevel($level);
30 }
static toMonologLevel($level)
Converts PSR-3 levels to Monolog ones if necessary.
Definition: Logger.php:403

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

+ 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 }

References Monolog\Processor\GitProcessor\getGitInfo().

+ Here is the call graph for this function:

◆ getGitInfo()

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

Definition at line 48 of file GitProcessor.php.

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 }
v($data, $pos)

References Monolog\Processor\GitProcessor\$cache, and v().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $cache

Monolog\Processor\GitProcessor::$cache
staticprivate

Definition at line 25 of file GitProcessor.php.

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

◆ $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: