xref: /plugin/upgrade/myvendor/splitbrain/php-cli/src/CLI.php (revision ab8e5256dbaece2751c4414d6cf7b761cb71998a)
1*ab8e5256SAndreas Gohr<?php
2*ab8e5256SAndreas Gohr
3*ab8e5256SAndreas Gohrnamespace splitbrain\phpcli;
4*ab8e5256SAndreas Gohr
5*ab8e5256SAndreas Gohr/**
6*ab8e5256SAndreas Gohr * Class CLI
7*ab8e5256SAndreas Gohr *
8*ab8e5256SAndreas Gohr * Your commandline script should inherit from this class and implement the abstract methods.
9*ab8e5256SAndreas Gohr *
10*ab8e5256SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
11*ab8e5256SAndreas Gohr * @license MIT
12*ab8e5256SAndreas Gohr */
13*ab8e5256SAndreas Gohrabstract class CLI extends Base
14*ab8e5256SAndreas Gohr{
15*ab8e5256SAndreas Gohr    /**
16*ab8e5256SAndreas Gohr     * System is unusable.
17*ab8e5256SAndreas Gohr     *
18*ab8e5256SAndreas Gohr     * @param string $message
19*ab8e5256SAndreas Gohr     * @param array $context
20*ab8e5256SAndreas Gohr     *
21*ab8e5256SAndreas Gohr     * @return void
22*ab8e5256SAndreas Gohr     */
23*ab8e5256SAndreas Gohr    public function emergency($message, array $context = array())
24*ab8e5256SAndreas Gohr    {
25*ab8e5256SAndreas Gohr        $this->log('emergency', $message, $context);
26*ab8e5256SAndreas Gohr    }
27*ab8e5256SAndreas Gohr
28*ab8e5256SAndreas Gohr    /**
29*ab8e5256SAndreas Gohr     * Action must be taken immediately.
30*ab8e5256SAndreas Gohr     *
31*ab8e5256SAndreas Gohr     * Example: Entire website down, database unavailable, etc. This should
32*ab8e5256SAndreas Gohr     * trigger the SMS alerts and wake you up.
33*ab8e5256SAndreas Gohr     *
34*ab8e5256SAndreas Gohr     * @param string $message
35*ab8e5256SAndreas Gohr     * @param array $context
36*ab8e5256SAndreas Gohr     */
37*ab8e5256SAndreas Gohr    public function alert($message, array $context = array())
38*ab8e5256SAndreas Gohr    {
39*ab8e5256SAndreas Gohr        $this->log('alert', $message, $context);
40*ab8e5256SAndreas Gohr    }
41*ab8e5256SAndreas Gohr
42*ab8e5256SAndreas Gohr    /**
43*ab8e5256SAndreas Gohr     * Critical conditions.
44*ab8e5256SAndreas Gohr     *
45*ab8e5256SAndreas Gohr     * Example: Application component unavailable, unexpected exception.
46*ab8e5256SAndreas Gohr     *
47*ab8e5256SAndreas Gohr     * @param string $message
48*ab8e5256SAndreas Gohr     * @param array $context
49*ab8e5256SAndreas Gohr     */
50*ab8e5256SAndreas Gohr    public function critical($message, array $context = array())
51*ab8e5256SAndreas Gohr    {
52*ab8e5256SAndreas Gohr        $this->log('critical', $message, $context);
53*ab8e5256SAndreas Gohr    }
54*ab8e5256SAndreas Gohr
55*ab8e5256SAndreas Gohr    /**
56*ab8e5256SAndreas Gohr     * Runtime errors that do not require immediate action but should typically
57*ab8e5256SAndreas Gohr     * be logged and monitored.
58*ab8e5256SAndreas Gohr     *
59*ab8e5256SAndreas Gohr     * @param string $message
60*ab8e5256SAndreas Gohr     * @param array $context
61*ab8e5256SAndreas Gohr     */
62*ab8e5256SAndreas Gohr    public function error($message, array $context = array())
63*ab8e5256SAndreas Gohr    {
64*ab8e5256SAndreas Gohr        $this->log('error', $message, $context);
65*ab8e5256SAndreas Gohr    }
66*ab8e5256SAndreas Gohr
67*ab8e5256SAndreas Gohr    /**
68*ab8e5256SAndreas Gohr     * Exceptional occurrences that are not errors.
69*ab8e5256SAndreas Gohr     *
70*ab8e5256SAndreas Gohr     * Example: Use of deprecated APIs, poor use of an API, undesirable things
71*ab8e5256SAndreas Gohr     * that are not necessarily wrong.
72*ab8e5256SAndreas Gohr     *
73*ab8e5256SAndreas Gohr     * @param string $message
74*ab8e5256SAndreas Gohr     * @param array $context
75*ab8e5256SAndreas Gohr     */
76*ab8e5256SAndreas Gohr    public function warning($message, array $context = array())
77*ab8e5256SAndreas Gohr    {
78*ab8e5256SAndreas Gohr        $this->log('warning', $message, $context);
79*ab8e5256SAndreas Gohr    }
80*ab8e5256SAndreas Gohr
81*ab8e5256SAndreas Gohr
82*ab8e5256SAndreas Gohr
83*ab8e5256SAndreas Gohr    /**
84*ab8e5256SAndreas Gohr     * Normal but significant events.
85*ab8e5256SAndreas Gohr     *
86*ab8e5256SAndreas Gohr     * @param string $message
87*ab8e5256SAndreas Gohr     * @param array $context
88*ab8e5256SAndreas Gohr     */
89*ab8e5256SAndreas Gohr    public function notice($message, array $context = array())
90*ab8e5256SAndreas Gohr    {
91*ab8e5256SAndreas Gohr        $this->log('notice', $message, $context);
92*ab8e5256SAndreas Gohr    }
93*ab8e5256SAndreas Gohr
94*ab8e5256SAndreas Gohr    /**
95*ab8e5256SAndreas Gohr     * Interesting events.
96*ab8e5256SAndreas Gohr     *
97*ab8e5256SAndreas Gohr     * Example: User logs in, SQL logs.
98*ab8e5256SAndreas Gohr     *
99*ab8e5256SAndreas Gohr     * @param string $message
100*ab8e5256SAndreas Gohr     * @param array $context
101*ab8e5256SAndreas Gohr     */
102*ab8e5256SAndreas Gohr    public function info($message, array $context = array())
103*ab8e5256SAndreas Gohr    {
104*ab8e5256SAndreas Gohr        $this->log('info', $message, $context);
105*ab8e5256SAndreas Gohr    }
106*ab8e5256SAndreas Gohr
107*ab8e5256SAndreas Gohr    /**
108*ab8e5256SAndreas Gohr     * Detailed debug information.
109*ab8e5256SAndreas Gohr     *
110*ab8e5256SAndreas Gohr     * @param string $message
111*ab8e5256SAndreas Gohr     * @param array $context
112*ab8e5256SAndreas Gohr     */
113*ab8e5256SAndreas Gohr    public function debug($message, array $context = array())
114*ab8e5256SAndreas Gohr    {
115*ab8e5256SAndreas Gohr        $this->log('debug', $message, $context);
116*ab8e5256SAndreas Gohr    }
117*ab8e5256SAndreas Gohr
118*ab8e5256SAndreas Gohr    /**
119*ab8e5256SAndreas Gohr     * @param string $level
120*ab8e5256SAndreas Gohr     * @param string $message
121*ab8e5256SAndreas Gohr     * @param array $context
122*ab8e5256SAndreas Gohr     */
123*ab8e5256SAndreas Gohr    public function log($level, $message, array $context = array())
124*ab8e5256SAndreas Gohr    {
125*ab8e5256SAndreas Gohr        $this->logMessage($level, $message, $context);
126*ab8e5256SAndreas Gohr    }
127*ab8e5256SAndreas Gohr}
128