1 | <?php |
||
16 | class SlackLogEngine extends BaseLog |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * Instance of SlackClient class |
||
21 | * |
||
22 | * @var \Maknz\Slack\Client |
||
23 | */ |
||
24 | protected $_SlackClient = null; |
||
25 | |||
26 | /** |
||
27 | * The default config used unless overridden by runtime configuration |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $_defaultConfig = [ |
||
32 | 'types' => null, |
||
33 | 'levels' => [], |
||
34 | 'scopes' => [], |
||
35 | 'clientClass' => '\Maknz\Slack\Client' |
||
36 | ]; |
||
37 | |||
38 | /** |
||
39 | * Configuration is valid or not |
||
40 | * |
||
41 | * @var boolean |
||
42 | */ |
||
43 | protected $_valid = true; |
||
44 | |||
45 | /** |
||
46 | * Sets protected properties based on config provided |
||
47 | * Either `client` or `hookUrl` is required |
||
48 | * |
||
49 | * - `hookUrl` [string] Slack hook url. |
||
50 | * - `client` [\Maknz\Slack\Client] Slack client instance for custom. |
||
51 | * - `clientClass` [string(optional)] slack client class. This option is used only with `hookUrl` option. |
||
52 | * |
||
53 | * Other available settings can be seen at https://github.com/maknz/slack#settings |
||
54 | * |
||
55 | * @param array $config Configuration array |
||
56 | */ |
||
57 | public function __construct(array $config = []) |
||
74 | |||
75 | /** |
||
76 | * Get slack client |
||
77 | * |
||
78 | * @return \Maknz\Slack\Client slack client |
||
79 | */ |
||
80 | public function getClient() |
||
84 | |||
85 | /** |
||
86 | * Set slack client |
||
87 | * |
||
88 | * @param \Maknz\Slack\Client $client slack client |
||
89 | * @return \Maknz\Slack\Client slack client |
||
90 | */ |
||
91 | public function setClient(SlackClient $client) |
||
98 | |||
99 | /** |
||
100 | * Implements post a log to slack. |
||
101 | * |
||
102 | * @param string $level The severity level of the message being written. |
||
103 | * See Cake\Log\Log::$_levels for list of possible levels. |
||
104 | * @param string $message The message you want to log. |
||
105 | * @param array $context Additional information about the logged message |
||
106 | * @return bool success |
||
107 | */ |
||
108 | public function log($level, $message, array $context = []) |
||
130 | } |
||
131 |