add the ability to configure logger
This commit is contained in:
parent
866b78f1f4
commit
23e0add29d
2 changed files with 14 additions and 1 deletions
12
src/app.ml
12
src/app.ml
|
|
@ -57,3 +57,15 @@ let port =
|
||||||
failwith "invalid `port` value in configuration file" ) )
|
failwith "invalid `port` value in configuration file" ) )
|
||||||
|
|
||||||
let () = Dream.log "port: %d" port
|
let () = Dream.log "port: %d" port
|
||||||
|
|
||||||
|
let log =
|
||||||
|
match Scfg.Query.get_dir "log" config with
|
||||||
|
| None -> true
|
||||||
|
| Some open_registration -> (
|
||||||
|
match Scfg.Query.get_param 0 open_registration with
|
||||||
|
| Error e -> failwith e
|
||||||
|
| Ok "true" -> true
|
||||||
|
| Ok "false" -> false
|
||||||
|
| Ok _unknown -> failwith "invalid `log` value in configuration file" )
|
||||||
|
|
||||||
|
let () = Dream.log "log: %b" log
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,8 @@ let routes =
|
||||||
[ get_ "/:thread_id" thread_get; post "/:thread_id" reply_post ]
|
[ get_ "/:thread_id" thread_get; post "/:thread_id" reply_post ]
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
Dream.run ~port:App.port @@ Dream.logger @@ Dream.cookie_sessions
|
let logger = if App.log then Dream.logger else Fun.id in
|
||||||
|
Dream.run ~port:App.port @@ logger @@ Dream.cookie_sessions
|
||||||
(* this should replace memory/cookie sessions but it doesn't work :-(
|
(* this should replace memory/cookie sessions but it doesn't work :-(
|
||||||
@@ Dream.sql_pool Db.db_uri
|
@@ Dream.sql_pool Db.db_uri
|
||||||
@@ Dream.sql_sessions
|
@@ Dream.sql_sessions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue