@@ -25,16 +25,19 @@ let warning_file = "warnings.log"
2525let error_file = " errors.log"
2626
2727
28- let access_sect = Lwt_log.Section. make " access"
28+ let access_sect = Lwt_log.Section. make " ocsigen: access"
2929
3030let full_path f = Filename. concat (Ocsigen_config. get_logdir () ) f
3131
3232let error_log_path () = full_path error_file
3333
3434let stderr = Lwt_log. channel `Keep Lwt_io. stderr ()
35+ let stdout = Lwt_log. channel `Keep Lwt_io. stdout ()
3536
3637let loggers = ref []
3738
39+ let access_logger = ref Lwt_log_core. null
40+
3841let open_files ?(user = Ocsigen_config. get_user () ) ?(group = Ocsigen_config. get_group () ) () =
3942
4043 (* CHECK: we are closing asynchronously! That should be ok, though. *)
@@ -66,6 +69,7 @@ let open_files ?(user = Ocsigen_config.get_user ()) ?(group = Ocsigen_config.get
6669 in
6770
6871 open_log access_file >> = fun acc ->
72+ access_logger := acc;
6973 open_log warning_file >> = fun war ->
7074 open_log error_file >> = fun err ->
7175 loggers := [acc; war; err];
@@ -74,14 +78,16 @@ let open_files ?(user = Ocsigen_config.get_user ()) ?(group = Ocsigen_config.get
7478 Lwt_log. broadcast
7579 [Lwt_log. dispatch
7680 (fun sect lev ->
77- if sect = access_sect then acc else
78- match lev with
79- | Lwt_log. Error | Lwt_log. Fatal -> err
80- | Lwt_log. Warning -> war
81- | _ -> Lwt_log. null);
81+ match lev with
82+ | Lwt_log. Error | Lwt_log. Fatal -> err
83+ | Lwt_log. Warning -> war
84+ | _ -> Lwt_log. null);
8285 Lwt_log. dispatch
8386 (fun sect lev ->
84- if Ocsigen_config. get_silent () then Lwt_log. null else stderr)];
87+ if Ocsigen_config. get_silent () then Lwt_log. null else
88+ match lev with
89+ | Lwt_log. Warning | Lwt_log. Error | Lwt_log. Fatal -> stderr
90+ | _ -> stdout)];
8591
8692 let gid = match group with
8793 | None -> Unix. getgid ()
@@ -109,7 +115,10 @@ let open_files ?(user = Ocsigen_config.get_user ()) ?(group = Ocsigen_config.get
109115
110116(* ***)
111117
112- let accesslog s = Lwt_log. ign_notice ~section: access_sect s
118+ let accesslog s =
119+ (* not really fatal, but log in all cases; does not affect console *)
120+ Lwt_log. ign_fatal ~section: access_sect ~logger: ! access_logger s;
121+ Lwt_log. ign_notice ~section: access_sect s
113122
114123let errlog ?section s = Lwt_log. ign_error ?section s
115124
0 commit comments