Skip to content

Commit 30ccf2c

Browse files
author
Lenardt Gerhardts
committed
Documented log component
1 parent b4ad8db commit 30ccf2c

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
INSERT INTO components(name, icon, description) VALUES
2+
('log', 'logs', 'A Component to log a message to the Servers STDOUT or Log file on page load')
3+
4+
INSERT INTO parameter(component, name, description, type, top_level, optional) SELECT 'log', * FROM (
5+
-- item level
6+
('message', 'The message that needs to be logged', 'ANY', FALSE, FALSE),
7+
('priority', 'The priority which the message should be logged with. Possible values are [''trace'', ''debug'', ''info'', ''warn'', ''error''] and are not case sensitive. If this value is missing or not matching any possible values, the default priority will be ''info''.', 'TEXT', FALSE, TRUE)
8+
) x;
9+
10+
INSERT INTO example(component, description) VALUES
11+
('log', '
12+
### Hello World
13+
14+
Log a simple ''Hello, World!'' message on page load.
15+
16+
```sql
17+
SELECT ''log'' as component,
18+
''Hello, World!'' as message
19+
```
20+
21+
Output example:
22+
23+
```
24+
[2025-09-12T08:33:48.228Z INFO sqlpage::log from file "index.sql" in statement 3] Hello, World!
25+
```
26+
27+
### Priority
28+
29+
Change the priority to error.
30+
31+
```sql
32+
SELECT ''log'' as component,
33+
''This is a error message'' as message,
34+
''error'' as priority
35+
```
36+
37+
Output example:
38+
39+
```
40+
[2025-09-12T08:33:48.228Z ERROR sqlpage::log from file "index.sql" in header] This is a error message
41+
```
42+
43+
### Retrieve user data
44+
45+
```sql
46+
set username = ''user'' -- (retrieve username from somewhere)
47+
48+
select ''log'' as component,
49+
''403 - failed for '' || coalesce($username, ''None'') as output,
50+
''error'' as priority;
51+
```
52+
53+
Output example:
54+
55+
```
56+
[2025-09-12T08:33:48.228Z ERROR sqlpage::log from file "403.sql" in statement 7] 403 - failed for user
57+
```
58+
')

0 commit comments

Comments
 (0)