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