Skip to content

Commit f5dd35d

Browse files
authored
document parameter logging (#155)
1 parent 9edd1d4 commit f5dd35d

File tree

1 file changed

+34
-17
lines changed

1 file changed

+34
-17
lines changed

src/pages/4-combining-actions.md

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -553,40 +553,57 @@ Slick uses a logging interface called [SLF4J][link-slf4j]. We can configure this
553553
<logger name="slick.jdbc.JdbcBackend.statement" level="DEBUG"/>
554554
```
555555

556-
This causes Slick to log every query, even modifications to the schema:
556+
This causes Slick to log every query, including modifications to the schema:
557557

558558
```
559559
DEBUG slick.jdbc.JdbcBackend.statement - Preparing statement:
560560
delete from "message" where "message"."sender" = 'HAL'
561561
```
562562

563-
We can change the level of various loggers, as shown in the table below:
563+
We can change the level of various loggers, as shown in the table below.
564564

565-
------------------------------------------------------------------------------------------------------------------------
566-
Logger Effect
567-
------------------------------------------------------------ ----------------------------------------------------------
568-
`slick.jdbc.JdbcBackend.statement` Logs SQL sent to the database as described above.
565+
-----------------------------------------------------------------------------------------------------------------------------
566+
Logger Will log...
567+
----------------------------------------------------------------- ----------------------------------------------------------
568+
`slick.jdbc.JdbcBackend.statement` SQL sent to the database.
569569

570-
`slick.jdbc.StatementInvoker.result` Logs the first few results of each query.
570+
`slick.jdbc.JdbcBackend.parameter` Parameters passed to a query.
571571

572-
`slick.session` Logs session events such as opening/closing connections.
572+
`slick.jdbc.StatementInvoker.result` The first few results of each query.
573573

574-
`slick` Logs everything! Equivalent to changing all of the above.
575-
------------------------------------------------------------ ----------------------------------------------------------
574+
`slick.session` Session events such as opening/closing connections.
575+
576+
`slick` Everything!
577+
----------------------------------------------------------------- ----------------------------------------------------------
576578

577579
: Slick loggers and their effects.
578580

579-
The `StatementInvoker.result` logger, in particular, is pretty cute:
581+
The `StatementInvoker.result` logger, in particular, is pretty cute.
582+
Here's an example from running a select query:
580583

581584
```
582-
SI.result - /--------+----------------------+----\
583-
SI.result - | sender | content | id |
584-
SI.result - +--------+----------------------+----+
585-
SI.result - | HAL | Affirmative, Dave... | 2 |
586-
SI.result - | HAL | I'm sorry, Dave. ... | 4 |
587-
SI.result - \--------+----------------------+----/
585+
result - /--------+----------------------+----\
586+
result - | sender | content | id |
587+
result - +--------+----------------------+----+
588+
result - | HAL | Affirmative, Dave... | 2 |
589+
result - | HAL | I'm sorry, Dave. ... | 4 |
590+
result - \--------+----------------------+----/
588591
```
589592

593+
The combination of `parameter` and `statement` can show you the values bound to `?` placeholders.
594+
For example, when adding rows we can see the values being inserted:
595+
596+
```
597+
statement - Preparing statement: insert into "message"
598+
("sender","content") values (?,?)
599+
parameter - /--------+---------------------------\
600+
parameter - | 1 | 2 |
601+
parameter - | String | String |
602+
parameter - |--------+---------------------------|
603+
parameter - | Dave | Hello, HAL. Do you rea... |
604+
parameter - | HAL | I'm sorry, Dave. I'm a... |
605+
parameter - \--------+---------------------------/
606+
```
590607

591608

592609

0 commit comments

Comments
 (0)