You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
('message', 'The message that needs to be logged', 'TEXT', TRUE, FALSE),
7
-
('priority', 'The priority which the message should be logged with. Possible values are [''trace'', ''debug'', ''info'', ''warn'', ''error''] and are not casesensitive. If this value is missing or not matching any possible values, the default priority will be ''info''.', 'TEXT', TRUE, TRUE)
16
+
('message', 'The text to write to the server logs. It is printed when the page runs.', 'TEXT', TRUE, FALSE),
17
+
('level', 'How important the message is. One of ''trace'', ''debug'', ''info'' (default), ''warn'', ''error''. Not case-sensitive. Controls the level shown in the logs.', 'TEXT', TRUE, TRUE)
8
18
) x;
9
19
10
20
INSERT INTO example(component, description) VALUES
11
21
('log', '
12
-
### Hello World
22
+
### Record a simple message
13
23
14
-
Log a simple ''Hello, World!'' message on page load.
24
+
This writes "Hello, World!" to the server logs.
15
25
16
26
```sql
17
-
SELECT ''log'' as component,
18
-
''Hello, World!'' as message
27
+
SELECT ''log'' as component, ''Hello, World!'' as message;
19
28
```
20
29
21
-
Output example:
30
+
Example output:
22
31
23
-
```
24
-
[2025-09-12T08:33:48.228Z INFO sqlpage::log from file "index.sql" in statement 3] Hello, World!
32
+
```text
33
+
[2025-09-13T22:30:14.722Z INFO sqlpage::log from "x.sql" statement 1] Hello, World!
25
34
```
26
35
27
-
### Priority
36
+
### Set the importance (level)
28
37
29
-
Change the priority to error.
38
+
Choose how important the message is.
30
39
31
40
```sql
32
-
SELECT ''log'' as component,
33
-
''This is a error message'' as message,
34
-
''error'' as priority
41
+
SELECT ''log'' as component, ''error'' as level, ''This is an error message'' as message;
35
42
```
36
43
37
-
Output example:
44
+
Example output:
38
45
39
-
```
40
-
[2025-09-12T08:33:48.228Z ERROR sqlpage::log from file "index.sql" in header] This is a error message
46
+
```text
47
+
[2025-09-13T22:30:14.722Z ERROR sqlpage::log from "x.sql" statement 2] This is an error message
41
48
```
42
49
43
-
### Retrieve user data
50
+
### Log dynamic information
44
51
45
-
```sql
46
-
set username = ''user'' -- (retrieve username from somewhere)
52
+
Include variables like a username.
47
53
48
-
select ''log'' as component,
49
-
''403 - failed for '' || coalesce($username, ''None'') as output,
50
-
''error'' as priority;
51
-
```
52
-
53
-
Output example:
54
+
```sql
55
+
set username = ''user''
54
56
55
-
```
56
-
[2025-09-12T08:33:48.228Z ERROR sqlpage::log from file "403.sql" in statement 7] 403 - failed for user
57
+
select ''log'' as component,
58
+
''403 - failed for '' || coalesce($username, ''None'') as message,
0 commit comments