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
* implemented logger Component
* changed target for logger to "sqlpage::logger" and made the log::Level case insensitive
* changed error message on missing message key, to be more precise
* changed custom method for String to log::Level conversion to builtin method log::Level::from_str()
* switched to utility method get_object_str and inlined constants
* dynamically target based on file and statement
* disabled ci error (large difference in enum variants) for ResponseWithWriter<S>
* added functionality to work in Header context
* Refactor log component to use compact error handling
* Rename comp_str variable to component_name
* Documented log component
* fixxed missing values statement
* fixxed pipeline errors
* very simple test case for logger
---------
Co-authored-by: Lenardt Gerhardts <lenardt.ger+git@gmail.com>
Co-authored-by: lovasoa <contact@ophir.dev>
('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 case sensitive. If this value is missing or not matching any possible values, the default priority will be ''info''.', 'TEXT', TRUE, 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
bail!("There cannot be more than a single shell per page. You are trying to open the {} component, but a shell component is already opened for the current page. You can fix this by removing the extra shell component, or by moving this component to the top of the SQL file, before any other component that displays data.", component_name);
let new_component = get_object_str(data,"component");
726
764
let current_component = self
727
765
.current_component
728
766
.as_ref()
729
767
.map(SplitTemplateRenderer::name);
730
-
ifletSome(comp_str) = new_component {
731
-
ifSelf::is_shell_component(comp_str){
732
-
bail!("There cannot be more than a single shell per page. You are trying to open the {} component, but a shell component is already opened for the current page. You can fix this by removing the extra shell component, or by moving this component to the top of the SQL file, before any other component that displays data.", comp_str);
0 commit comments