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