-
Notifications
You must be signed in to change notification settings - Fork 5
/
CreateLogsTask.php
44 lines (40 loc) · 1.46 KB
/
CreateLogsTask.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace SilverLeague\LogViewer\Task;
use Psr\Log\LoggerInterface;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\BuildTask;
/**
* This is purely for demo purposes, and will log a message at every level for local testing or demo purposes.
*
* @package silverstripe-logviewer
* @author Robbie Averill <[email protected]>
*/
class CreateLogsTask extends BuildTask
{
/**
* {@inheritDoc}
*/
private static $segment = 'CreateLogsTask';
/**
* {@inheritDoc}
*/
public function run($request)
{
$logger = Injector::inst()->get(LoggerInterface::class);
$logger->addDebug('Detailed debug information');
$logger->addInfo('Interesting events. Examples: User logs in, SQL logs.');
$logger->addNotice('Uncommon events');
$logger->addWarning(
'Exceptional occurrences that are not errors. Examples: Use of deprecated APIs, poor use of an API, '
. 'undesirable things that are not necessarily wrong.'
);
$logger->addError('Runtime errors');
$logger->addCritical('Critical conditions. Example: Application component unavailable, unexpected exception.');
$logger->addAlert(
'Action must be taken immediately. Example: Entire website down, database unavailable, etc. '
. 'This should trigger the SMS alerts and wake you up.'
);
$logger->addEmergency('Urgent alert.');
echo 'Finito.', PHP_EOL;
}
}