1 | <?php |
||
24 | class SentryLogger |
||
25 | { |
||
26 | |||
27 | /** |
||
28 | * Stipulates what gets shown in the Sentry UI, should some metric not be |
||
29 | * available for any reason. |
||
30 | * |
||
31 | * @const string |
||
32 | */ |
||
33 | const SLW_NOOP = 'Unavailable'; |
||
34 | |||
35 | /** |
||
36 | * A static constructor as per {@link Zend_Log_FactoryInterface}. |
||
37 | * |
||
38 | * @param array $config An array of optional additional configuration for |
||
39 | * passing custom information to Sentry. See the README |
||
40 | * for more detail. |
||
41 | * @return SentryLogger |
||
42 | */ |
||
43 | public static function factory($config = []) |
||
67 | |||
68 | /** |
||
69 | * Used in unit tests. |
||
70 | * |
||
71 | * @return SentryClientAdaptor |
||
72 | */ |
||
73 | public function getClient() |
||
77 | |||
78 | /** |
||
79 | * Returns a default environment when one isn't passed to the factory() |
||
80 | * method. |
||
81 | * |
||
82 | * @return string |
||
83 | */ |
||
84 | public function defaultEnv() |
||
88 | |||
89 | /** |
||
90 | * Returns a default set of additional "tags" we wish to send to Sentry. |
||
91 | * By default, Sentry reports on several mertrics, and we're already sending |
||
92 | * {@link Member} data. But there are additional data that would be useful |
||
93 | * for debugging via the Sentry UI. |
||
94 | * |
||
95 | * These data can augment that which is sent to Sentry at setup |
||
96 | * time in _config.php. See the README for more detail. |
||
97 | * |
||
98 | * N.b. Tags can be used to group messages within the Sentry UI itself, so there |
||
99 | * should only be "static" data being sent, not something that can drastically |
||
100 | * or minutely change, such as memory usage for example. |
||
101 | * |
||
102 | * @return array |
||
103 | */ |
||
104 | public function defaultTags() |
||
113 | |||
114 | /** |
||
115 | * Returns a default set of extra data to show upon selecting a message for |
||
116 | * analysis in the Sentry UI. This can augment the data sent to Sentry at setup |
||
117 | * time in _config.php as well as at runtime when calling SS_Log itself. |
||
118 | * See the README for more detail. |
||
119 | * |
||
120 | * @return array |
||
121 | */ |
||
122 | public function defaultExtra() |
||
128 | |||
129 | /** |
||
130 | * Return the version of $pkg taken from composer.lock. |
||
131 | * |
||
132 | * @param string $pkg e.g. "silverstripe/framework" |
||
133 | * @return string |
||
134 | */ |
||
135 | public function getPackageInfo($pkg) |
||
153 | |||
154 | /** |
||
155 | * What sort of request is this? (A harder question to answer than you might |
||
156 | * think: http://stackoverflow.com/questions/6275363/what-is-the-correct-terminology-for-a-non-ajax-request) |
||
157 | * |
||
158 | * @return string |
||
159 | */ |
||
160 | public function getRequestType() |
||
167 | |||
168 | /** |
||
169 | * Return peak memory usage. |
||
170 | * |
||
171 | * @return float |
||
172 | */ |
||
173 | public function getPeakMemory() |
||
179 | |||
180 | /** |
||
181 | * Basic User-Agent check and return. |
||
182 | * |
||
183 | * @return string |
||
184 | */ |
||
185 | public function getUserAgent() |
||
195 | |||
196 | /** |
||
197 | * Basic request method check and return. |
||
198 | * |
||
199 | * @return string |
||
200 | */ |
||
201 | public function getReqMethod() |
||
211 | |||
212 | /** |
||
213 | * @return string |
||
214 | */ |
||
215 | public function getSAPI() |
||
219 | |||
220 | /** |
||
221 | * Returns the client IP address which originated this request. |
||
222 | * Lifted and modified from SilverStripe 3's SS_HTTPRequest. |
||
223 | * |
||
224 | * @return string |
||
225 | */ |
||
226 | public function getIP() |
||
261 | |||
262 | } |
||
263 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: