ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Monolog\Processor\MemoryProcessor Class Reference

Some methods that are common for all memory processors. More...

+ Inheritance diagram for Monolog\Processor\MemoryProcessor:
+ Collaboration diagram for Monolog\Processor\MemoryProcessor:

Public Member Functions

 __construct ($realUsage=true, $useFormatting=true)
 

Protected Member Functions

 formatBytes ($bytes)
 Formats bytes into a human readable string if $this->useFormatting is true, otherwise return $bytes as is. More...
 

Protected Attributes

 $realUsage
 
 $useFormatting
 

Detailed Description

Some methods that are common for all memory processors.

Author
Rob Jensen

Definition at line 19 of file MemoryProcessor.php.

Constructor & Destructor Documentation

◆ __construct()

Monolog\Processor\MemoryProcessor::__construct (   $realUsage = true,
  $useFormatting = true 
)
Parameters
bool$realUsageSet this to true to get the real size of memory allocated from system.
bool$useFormattingIf true, then format memory size to human readable string (MB, KB, B depending on size)

Definition at line 35 of file MemoryProcessor.php.

References Monolog\Processor\MemoryProcessor\$realUsage, and Monolog\Processor\MemoryProcessor\$useFormatting.

36  {
37  $this->realUsage = (boolean) $realUsage;
38  $this->useFormatting = (boolean) $useFormatting;
39  }

Member Function Documentation

◆ formatBytes()

Monolog\Processor\MemoryProcessor::formatBytes (   $bytes)
protected

Formats bytes into a human readable string if $this->useFormatting is true, otherwise return $bytes as is.

Parameters
int$bytes
Returns
string|int Formatted string if $this->useFormatting is true, otherwise return $bytes as is

Definition at line 47 of file MemoryProcessor.php.

Referenced by Monolog\Processor\MemoryPeakUsageProcessor\__invoke(), and Monolog\Processor\MemoryUsageProcessor\__invoke().

48  {
49  $bytes = (int) $bytes;
50 
51  if (!$this->useFormatting) {
52  return $bytes;
53  }
54 
55  if ($bytes > 1024 * 1024) {
56  return round($bytes / 1024 / 1024, 2).' MB';
57  } elseif ($bytes > 1024) {
58  return round($bytes / 1024, 2).' KB';
59  }
60 
61  return $bytes . ' B';
62  }
+ Here is the caller graph for this function:

Field Documentation

◆ $realUsage

Monolog\Processor\MemoryProcessor::$realUsage
protected

Definition at line 24 of file MemoryProcessor.php.

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

◆ $useFormatting

Monolog\Processor\MemoryProcessor::$useFormatting
protected

Definition at line 29 of file MemoryProcessor.php.

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


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