diff --git a/resto/src/server.ml b/resto/src/server.ml index d228f24cd88b32d11ed014e9b98a5ea16e6fab16..632ba3961d604362a1a177c11c851aaf99f338fa 100644 --- a/resto/src/server.ml +++ b/resto/src/server.ml @@ -62,23 +62,23 @@ let wseq ic oc seq = Lwt.finalize (fun () -> wseq ic oc seq) (fun () -> Lwt_io.close ic) module type LOGGING = sig - val debug : ('a, Format.formatter, unit, unit) format4 -> 'a + val log_debug : ('a, Format.formatter, unit, unit) format4 -> 'a val log_info : ('a, Format.formatter, unit, unit) format4 -> 'a val log_notice : ('a, Format.formatter, unit, unit) format4 -> 'a - val warn : ('a, Format.formatter, unit, unit) format4 -> 'a + val log_warn : ('a, Format.formatter, unit, unit) format4 -> 'a val log_error : ('a, Format.formatter, unit, unit) format4 -> 'a - val lwt_debug : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a + val lwt_log_debug : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a val lwt_log_info : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a val lwt_log_notice : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a - val lwt_warn : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a + val lwt_log_warn : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a val lwt_log_error : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a end @@ -214,13 +214,13 @@ module Make_selfserver (Encoding : Resto.ENCODING) (Log : LOGGING) = struct match answer with | `Ok o -> let body = output o in - Log.debug "server (%s) response code:200" con_string ; - Log.debug "server (%s) response body: %s" con_string body ; + Log.log_debug "server (%s) response code:200" con_string ; + Log.log_debug "server (%s) response body: %s" con_string body ; let encoding = Transfer.Fixed (Int64.of_int (String.length body)) in ( Response.make ~status:`OK ~encoding ?headers (), Cohttp_lwt.Body.of_string body ) | `No_content -> - Log.debug "server (%s) response code:204 (no content)" con_string ; + Log.log_debug "server (%s) response code:204 (no content)" con_string ; (Response.make ~status:`No_content (), Cohttp_lwt.Body.empty) | `Created s -> let headers = Header.init () in @@ -229,7 +229,7 @@ module Make_selfserver (Encoding : Resto.ENCODING) (Log : LOGGING) = struct | None -> headers | Some s -> Header.add headers "location" s in - Log.debug "server (%s) response code:201 (created)" con_string ; + Log.log_debug "server (%s) response code:201 (created)" con_string ; (Response.make ~status:`Created ~headers (), Cohttp_lwt.Body.empty) let handle_rpc_answer_error con_string ?headers error answer = @@ -375,13 +375,14 @@ module Make (Encoding : Resto.ENCODING) (Log : LOGGING) = struct path_and_query >>= fun () -> let req_headers = Request.headers req in - Log.lwt_debug + Log.lwt_log_debug "server (%s) request headers: %s" con_string (Header.to_string req_headers) >>= fun () -> Cohttp_lwt.Body.to_string body >>= fun body -> - Log.lwt_debug "server (%s) request body: %s" con_string body >>= fun () -> + Log.lwt_log_debug "server (%s) request body: %s" con_string body + >>= fun () -> let path = Uri.path uri in let path = Resto.Utils.decode_split_path path in (match Request.meth req with @@ -392,7 +393,7 @@ module Make (Encoding : Resto.ENCODING) (Log : LOGGING) = struct >>=? fun (Directory.Service s) -> Media.input_media_type ~headers:req_headers server.medias >>? fun input_media_type -> - Log.lwt_debug + Log.lwt_log_debug "server (%s) input media type %s" con_string (Media_type.name input_media_type) @@ -408,7 +409,7 @@ module Make (Encoding : Resto.ENCODING) (Log : LOGGING) = struct Lwt.return_error (`Cannot_parse_query s) | query -> Lwt.return_ok query) >>=? fun query -> - Log.lwt_debug + Log.lwt_log_debug "server (%s) ouput media type %s" con_string (Media_type.name output_media_type) @@ -440,7 +441,7 @@ module Make (Encoding : Resto.ENCODING) (Log : LOGGING) = struct lwt_return_ok_response response | `OkChunk _ as a -> let output_seq = output_media_type.construct_seq s.types.output in - Log.lwt_debug + Log.lwt_log_debug "server (%s) response code:200 (with chunk transfer\n\ \ encoding)" con_string @@ -451,7 +452,9 @@ module Make (Encoding : Resto.ENCODING) (Log : LOGGING) = struct let output = output_media_type.construct s.types.output in let body = create_stream server con output o in let encoding = Transfer.Chunked in - Log.lwt_debug "server (%s) response code:200 (streamed)" con_string + Log.lwt_log_debug + "server (%s) response code:200 (streamed)" + con_string >>= fun () -> lwt_return_ok_response ( Response.make ~status:`OK ~encoding ~headers (), @@ -510,7 +513,7 @@ module Make (Encoding : Resto.ENCODING) (Log : LOGGING) = struct (let conn_closed ((_, con) as c) = let () = conn_closed c in let con_string = Connection.to_string con in - Log.debug "server (%s) got conn closed" con_string ; + Log.log_debug "server (%s) got conn closed" con_string ; try ConnectionMap.find con server.streams () with Not_found -> () and on_exn = function | Unix.Unix_error (Unix.EADDRINUSE, "bind", _) -> @@ -526,7 +529,7 @@ module Make (Encoding : Resto.ENCODING) (Log : LOGGING) = struct (Printexc.get_backtrace ()) and callback (io, con) req body = let con_string = Connection.to_string con in - Log.log_info "server (%s) connection accepted" con_string ; + Log.log_debug "server (%s) connection accepted" con_string ; Lwt.catch (fun () -> callback (io, con) req body) (function diff --git a/resto/src/server.mli b/resto/src/server.mli index 3e94d12f68ce84be26da1aaaebf4d60b5bef4a22..15dd0dd8eb98708356075686dfcc5d3c38213554 100644 --- a/resto/src/server.mli +++ b/resto/src/server.mli @@ -27,23 +27,23 @@ (** Serving a directory of registered services. *) module type LOGGING = sig - val debug : ('a, Format.formatter, unit, unit) format4 -> 'a + val log_debug : ('a, Format.formatter, unit, unit) format4 -> 'a val log_info : ('a, Format.formatter, unit, unit) format4 -> 'a val log_notice : ('a, Format.formatter, unit, unit) format4 -> 'a - val warn : ('a, Format.formatter, unit, unit) format4 -> 'a + val log_warn : ('a, Format.formatter, unit, unit) format4 -> 'a val log_error : ('a, Format.formatter, unit, unit) format4 -> 'a - val lwt_debug : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a + val lwt_log_debug : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a val lwt_log_info : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a val lwt_log_notice : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a - val lwt_warn : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a + val lwt_log_warn : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a val lwt_log_error : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'a end diff --git a/resto/test/acl_integration_test.ml b/resto/test/acl_integration_test.ml index 2ba2984702e9d4646d3c1bce83ddc10d45f02b6f..55a46fc417b4dd8ba84a647bf90de6e8f83b63b0 100644 --- a/resto/test/acl_integration_test.ml +++ b/resto/test/acl_integration_test.ml @@ -58,17 +58,17 @@ let json = let media_types = [json] module Logger : Resto_cohttp_server.Server.LOGGING = struct - let debug fmt = Format.kasprintf (Format.printf "[DEBUG]: %s\n%!") fmt + let log_debug fmt = Format.kasprintf (Format.printf "[DEBUG]: %s\n%!") fmt let log_info fmt = Format.kasprintf (Printf.printf "[INFO]: %s\n%!") fmt let log_notice fmt = Format.kasprintf (Printf.printf "[NOTICE]: %s\n%!") fmt - let warn fmt = Format.kasprintf (Printf.printf "[WARN]: %s\n%!") fmt + let log_warn fmt = Format.kasprintf (Printf.printf "[WARN]: %s\n%!") fmt let log_error fmt = Format.kasprintf (Printf.eprintf "[ERROR]: %s\n%!") fmt - let lwt_debug fmt = + let lwt_log_debug fmt = Format.kasprintf Lwt_fmt.(fprintf stdout "[DEBUG]: %s\n%!") fmt let lwt_log_info fmt = @@ -77,7 +77,7 @@ module Logger : Resto_cohttp_server.Server.LOGGING = struct let lwt_log_notice fmt = Format.kasprintf Lwt_fmt.(fprintf stdout "[NOTICE]: %s\n%!") fmt - let lwt_warn fmt = + let lwt_log_warn fmt = Format.kasprintf Lwt_fmt.(fprintf stdout "[WARN]: %s\n%!") fmt let lwt_log_error fmt = diff --git a/resto/test/chunked_output_integration_test.ml b/resto/test/chunked_output_integration_test.ml index 4dd9c3b89add8c43ac42415adf6bc233c7be0c77..61fba94f9dd668977a64d6a3501797a822712bc4 100644 --- a/resto/test/chunked_output_integration_test.ml +++ b/resto/test/chunked_output_integration_test.ml @@ -70,17 +70,17 @@ let json chunk_size = let media_types chunk_size = [json chunk_size] module Logger : Resto_cohttp_server.Server.LOGGING = struct - let debug fmt = Format.kasprintf (Format.printf "[DEBUG]: %s\n%!") fmt + let log_debug fmt = Format.kasprintf (Format.printf "[DEBUG]: %s\n%!") fmt let log_info fmt = Format.kasprintf (Printf.printf "[INFO]: %s\n%!") fmt let log_notice fmt = Format.kasprintf (Printf.printf "[NOTICE]: %s\n%!") fmt - let warn fmt = Format.kasprintf (Printf.printf "[WARN]: %s\n%!") fmt + let log_warn fmt = Format.kasprintf (Printf.printf "[WARN]: %s\n%!") fmt let log_error fmt = Format.kasprintf (Printf.eprintf "[ERROR]: %s\n%!") fmt - let lwt_debug fmt = + let lwt_log_debug fmt = Format.kasprintf Lwt_fmt.(fprintf stdout "[DEBUG]: %s\n%!") fmt let lwt_log_info fmt = @@ -89,7 +89,7 @@ module Logger : Resto_cohttp_server.Server.LOGGING = struct let lwt_log_notice fmt = Format.kasprintf Lwt_fmt.(fprintf stdout "[NOTICE]: %s\n%!") fmt - let lwt_warn fmt = + let lwt_log_warn fmt = Format.kasprintf Lwt_fmt.(fprintf stdout "[WARN]: %s\n%!") fmt let lwt_log_error fmt = diff --git a/resto/test/self_serving_client_test.ml b/resto/test/self_serving_client_test.ml index 13cd7cd56ea4cf9eb13f8ccb6559ee1b75f7921a..06bf295f829a1cb0c873f175fb47f74c186d829d 100644 --- a/resto/test/self_serving_client_test.ml +++ b/resto/test/self_serving_client_test.ml @@ -28,23 +28,23 @@ module Encoding = Resto_json.Encoding module Media_type = Resto_cohttp.Media_type.Make (Encoding) module NullLogger : Resto_cohttp_server.Server.LOGGING = struct - let debug fmt = Format.kasprintf ignore fmt + let log_debug fmt = Format.kasprintf ignore fmt let log_info fmt = Format.kasprintf ignore fmt let log_notice fmt = Format.kasprintf ignore fmt - let warn fmt = Format.kasprintf ignore fmt + let log_warn fmt = Format.kasprintf ignore fmt let log_error fmt = Format.kasprintf ignore fmt - let lwt_debug fmt = Format.kasprintf (fun _ -> Lwt.return_unit) fmt + let lwt_log_debug fmt = Format.kasprintf (fun _ -> Lwt.return_unit) fmt let lwt_log_info fmt = Format.kasprintf (fun _ -> Lwt.return_unit) fmt let lwt_log_notice fmt = Format.kasprintf (fun _ -> Lwt.return_unit) fmt - let lwt_warn fmt = Format.kasprintf (fun _ -> Lwt.return_unit) fmt + let lwt_log_warn fmt = Format.kasprintf (fun _ -> Lwt.return_unit) fmt let lwt_log_error fmt = Format.kasprintf (fun _ -> Lwt.return_unit) fmt end diff --git a/src/lib_mockup_proxy/RPC_client.ml b/src/lib_mockup_proxy/RPC_client.ml index 996da594127ee0d9671620be1b5c4272d228d7df..3381f13b00395549411c3589226cc8dbb5083566 100644 --- a/src/lib_mockup_proxy/RPC_client.ml +++ b/src/lib_mockup_proxy/RPC_client.ml @@ -29,23 +29,23 @@ module Service = Tezos_rpc.Service let media_types = [Tezos_rpc_http.Media_type.json] module NullLogger = struct - let debug fmt = Format.kasprintf ignore fmt + let log_debug fmt = Format.kasprintf ignore fmt let log_info fmt = Format.kasprintf ignore fmt let log_notice fmt = Format.kasprintf ignore fmt - let warn fmt = Format.kasprintf ignore fmt + let log_warn fmt = Format.kasprintf ignore fmt let log_error fmt = Format.kasprintf ignore fmt - let lwt_debug fmt = Format.kasprintf (fun _ -> Lwt.return_unit) fmt + let lwt_log_debug fmt = Format.kasprintf (fun _ -> Lwt.return_unit) fmt let lwt_log_info fmt = Format.kasprintf (fun _ -> Lwt.return_unit) fmt let lwt_log_notice fmt = Format.kasprintf (fun _ -> Lwt.return_unit) fmt - let lwt_warn fmt = Format.kasprintf (fun _ -> Lwt.return_unit) fmt + let lwt_log_warn fmt = Format.kasprintf (fun _ -> Lwt.return_unit) fmt let lwt_log_error fmt = Format.kasprintf (fun _ -> Lwt.return_unit) fmt end diff --git a/src/lib_rpc_http/RPC_server.ml b/src/lib_rpc_http/RPC_server.ml index 26d4e7a187732e51fe1d24ca53ec2325954ffed2..50530986972df1934d6c52ad422f7b19022c17b9 100644 --- a/src/lib_rpc_http/RPC_server.ml +++ b/src/lib_rpc_http/RPC_server.ml @@ -69,23 +69,23 @@ module RPC_logging = struct (Printf.sprintf "[pid:%d][resto] %s" (Unix.getpid ()) message)) fmt - let debug f = emit_async rpc_http_event_debug f + let log_debug f = emit_async rpc_http_event_debug f let log_info f = emit_async rpc_http_event_info f let log_notice f = emit_async rpc_http_event_notice f - let warn f = emit_async rpc_http_event_warning f + let log_warn f = emit_async rpc_http_event_warning f let log_error f = emit_async rpc_http_event_error f - let lwt_debug f = emit_lwt rpc_http_event_debug f + let lwt_log_debug f = emit_lwt rpc_http_event_debug f let lwt_log_info f = emit_lwt rpc_http_event_info f let lwt_log_notice f = emit_lwt rpc_http_event_notice f - let lwt_warn f = emit_lwt rpc_http_event_warning f + let lwt_log_warn f = emit_lwt rpc_http_event_warning f let lwt_log_error f = emit_lwt rpc_http_event_error f end