Completed
Branch master (a3fffb)
by Hong
33:51 queued 28:35
created

MemoryInfo   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A classProcessors() 0 6 1
1
<?php
2
3
/**
4
 * Phoole (PHP7.2+)
5
 *
6
 * @category  Library
7
 * @package   Phoole\Logger
8
 * @copyright Copyright (c) 2019 Hong Zhang
9
 */
10
declare(strict_types=1);
11
12
namespace Phoole\Logger\Entry;
13
14
use Phoole\Logger\Processor\MemoryProcessor;
15
16
/**
17
 * A log entry with predefined message template to log memory usage
18
 *
19
 * ```php
20
 * // initiate log with app id
21
 * $log = new Logger('MyApp');
22
 *
23
 * // add handler to this MemoryInfo
24
 * $log->addHandler(
25
 *     LogLevel::INFO,
26
 *     new LogfileHandler('system.log'),
27
 *     MemoryInfo::class
28
 * );
29
 *
30
 * // use it
31
 * $log->info(new MemoryInfo());
32
 * ```
33
 *
34
 * @package Phoole\Logger
35
 */
36
class MemoryInfo extends LogEntry
37
{
38
    /**
39
     * default message template
40
     *
41
     * @var string
42
     */
43
    protected $message = '{memory_used}M memory used, peak usage is {memory_peak}M';
44
45
    /**
46
     * {@inheritDoc}
47
     */
48
    protected static function classProcessors(): array
49
    {
50
        return [
51
            new MemoryProcessor()
52
        ];
53
    }
54
}