1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-23 09:36:11 +02:00
This commit is contained in:
Rob Jensen
2011-07-19 15:04:23 +01:00
parent c0cfb39d75
commit 6a2e2142d6
4 changed files with 11 additions and 38 deletions

View File

@@ -15,21 +15,17 @@ namespace Monolog\Processor;
* Some methods that are common for all memory processors
* @author Rob Jensen
*/
abstract class MemoryProcessor extends AbstractProcessor
class MemoryProcessor
{
protected $realUsage;
/**
* @param array $options
* @param boolean $realUsage
*/
public function __construct( $options = array() )
public function __construct($realUsage = true)
{
if(array_key_exists('realUsage', $options )){
$this->realUsage = (boolean) $options['realUsage'];
} else {
$this->realUsage = true;
}
$this->realUsage = (boolean) $realUsage;
}
/**
@@ -38,12 +34,12 @@ abstract class MemoryProcessor extends AbstractProcessor
* @param int $bytes
* @return string
*/
public static function formatBytes( $bytes )
public static function formatBytes($bytes)
{
$bytes = (int) $bytes;
if ($bytes > 1024*1024) {
$bytes = round($bytes/1024/1024, 2).' MB';
} else if ($bytes > 1024) {
} elseif ($bytes > 1024) {
$bytes = round($bytes/1024, 2).' KB';
} else {
$bytes .= ' B';