Given the folllowing code:
let my_log = Dream.sub_log ~level:`Error "my.log"
let () =
Dream.run
@@ Dream.logger
@@ Dream.router
[ Dream.get "/" (fun _ -> Dream.html "Welcome to my website")
; Dream.get "/echo/:word" (fun req ->
my_log.warning (fun log -> log ~request:req "echo path");
Dream.html (Printf.sprintf "Hello, %s" @@ Dream.param req "word"))
]
;;
I expect that echo path will not be logged, as it is a warning, and this sub_log is only configured with errors.
However, it is still being logged:
15.09.23 10:00:58.532 dream.log INFO REQ 1 GET /echo/dream 127.0.0.1:45198 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/51
15.09.23 10:00:58.532 my.log WARN REQ 1 echo path
15.09.23 10:00:58.532 dream.log INFO REQ 1 200 in 87 μs
"Manually" setting the log level with the following line:
let () = Dream.set_log_level "my.log" `Error
Makes it behave as expected:
15.09.23 10:03:37.447 dream.log INFO REQ 1 GET /echo/dream 127.0.0.1:33510 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/51
15.09.23 10:03:37.447 dream.log INFO REQ 1 200 in 56 μs
I am running OCaml 4.14.1 under WSL2
Given the folllowing code:
I expect that
echo pathwill not be logged, as it is a warning, and this sub_log is only configured with errors.However, it is still being logged:
"Manually" setting the log level with the following line:
Makes it behave as expected:
I am running OCaml 4.14.1 under WSL2