ci4
1<?php
2
3declare(strict_types=1);
4
5/**
6* This file is part of CodeIgniter 4 framework.
7*
8* (c) CodeIgniter Foundation <admin@codeigniter.com>
9*
10* For the full copyright and license information, please view
11* the LICENSE file that was distributed with this source code.
12*/
13
14namespace CodeIgniter\Log\Handlers;
15
16/**
17* Base class for logging
18*/
19abstract class BaseHandler implements HandlerInterface
20{
21/**
22* Handles
23*
24* @var array
25*/
26protected $handles;
27
28/**
29* Date format for logging
30*
31* @var string
32*/
33protected $dateFormat = 'Y-m-d H:i:s';
34
35/**
36* Constructor
37*/
38public function __construct(array $config)
39{
40$this->handles = $config['handles'] ?? [];
41}
42
43/**
44* Checks whether the Handler will handle logging items of this
45* log Level.
46*/
47public function canHandle(string $level): bool
48{
49return in_array($level, $this->handles, true);
50}
51
52/**
53* Stores the date format to use while logging messages.
54*/
55public function setDateFormat(string $format): HandlerInterface
56{
57$this->dateFormat = $format;
58
59return $this;
60}
61}
62