blob: b3a24b5f7e9d6d9b09680cee1491ceff9ee973b6 [file] [log] [blame]
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +02001<?php
2
3namespace Psr\Log;
4
5/**
6 * Describes a logger instance.
7 *
8 * The message MUST be a string or object implementing __toString().
9 *
10 * The message MAY contain placeholders in the form: {foo} where foo
11 * will be replaced by the context data in key "foo".
12 *
13 * The context array can contain arbitrary data. The only assumption that
14 * can be made by implementors is that if an Exception instance is given
15 * to produce a stack trace, it MUST be in a key named "exception".
16 *
17 * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
18 * for the full interface specification.
19 */
20interface LoggerInterface
21{
22 /**
23 * System is unusable.
24 *
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010025 * @param string|\Stringable $message
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020026 * @param mixed[] $context
27 *
28 * @return void
29 */
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010030 public function emergency(string|\Stringable $message, array $context = []): void;
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020031
32 /**
33 * Action must be taken immediately.
34 *
35 * Example: Entire website down, database unavailable, etc. This should
36 * trigger the SMS alerts and wake you up.
37 *
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010038 * @param string|\Stringable $message
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020039 * @param mixed[] $context
40 *
41 * @return void
42 */
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010043 public function alert(string|\Stringable $message, array $context = []): void;
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020044
45 /**
46 * Critical conditions.
47 *
48 * Example: Application component unavailable, unexpected exception.
49 *
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010050 * @param string|\Stringable $message
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020051 * @param mixed[] $context
52 *
53 * @return void
54 */
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010055 public function critical(string|\Stringable $message, array $context = []): void;
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020056
57 /**
58 * Runtime errors that do not require immediate action but should typically
59 * be logged and monitored.
60 *
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010061 * @param string|\Stringable $message
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020062 * @param mixed[] $context
63 *
64 * @return void
65 */
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010066 public function error(string|\Stringable $message, array $context = []): void;
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020067
68 /**
69 * Exceptional occurrences that are not errors.
70 *
71 * Example: Use of deprecated APIs, poor use of an API, undesirable things
72 * that are not necessarily wrong.
73 *
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010074 * @param string|\Stringable $message
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020075 * @param mixed[] $context
76 *
77 * @return void
78 */
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010079 public function warning(string|\Stringable $message, array $context = []): void;
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020080
81 /**
82 * Normal but significant events.
83 *
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010084 * @param string|\Stringable $message
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020085 * @param mixed[] $context
86 *
87 * @return void
88 */
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010089 public function notice(string|\Stringable $message, array $context = []): void;
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020090
91 /**
92 * Interesting events.
93 *
94 * Example: User logs in, SQL logs.
95 *
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010096 * @param string|\Stringable $message
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020097 * @param mixed[] $context
98 *
99 * @return void
100 */
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +0100101 public function info(string|\Stringable $message, array $context = []): void;
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200102
103 /**
104 * Detailed debug information.
105 *
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +0100106 * @param string|\Stringable $message
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200107 * @param mixed[] $context
108 *
109 * @return void
110 */
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +0100111 public function debug(string|\Stringable $message, array $context = []): void;
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200112
113 /**
114 * Logs with an arbitrary level.
115 *
116 * @param mixed $level
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +0100117 * @param string|\Stringable $message
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200118 * @param mixed[] $context
119 *
120 * @return void
121 *
122 * @throws \Psr\Log\InvalidArgumentException
123 */
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +0100124 public function log($level, string|\Stringable $message, array $context = []): void;
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200125}