From afa335ff4892dc9d71ef107147a7440ce6fa0547 Mon Sep 17 00:00:00 2001 From: James Deikun Date: Thu, 31 May 2018 17:05:00 -0400 Subject: [PATCH] move module-specific logging to the modules that use it --- src/bin_node/node_logging.ml | 10 ++++++++++ src/bin_node/node_logging.mli | 10 ++++++++++ src/bin_node/node_run_command.ml | 2 +- src/bin_node/node_shared_arg.ml | 2 +- src/bin_signer/handler.ml | 2 +- src/bin_signer/https_daemon.ml | 2 +- src/bin_signer/signer_logging.ml | 10 ++++++++++ src/bin_signer/signer_logging.mli | 10 ++++++++++ src/bin_signer/socket_daemon.ml | 2 +- src/lib_base/base_logging.ml | 10 ++++++++++ src/lib_base/base_logging.mli | 10 ++++++++++ src/lib_base/lwt_exit.ml | 2 +- src/lib_protocol_updater/updater.ml | 2 +- src/lib_protocol_updater/updater_logging.ml | 10 ++++++++++ src/lib_protocol_updater/updater_logging.mli | 10 ++++++++++ src/lib_rpc_http/RPC_logging.ml | 10 ++++++++++ src/lib_rpc_http/RPC_logging.mli | 10 ++++++++++ src/lib_rpc_http/RPC_server.ml | 2 +- src/lib_shell/chain.ml | 2 +- src/lib_shell/node.ml | 2 +- src/lib_shell/node_rpc.ml | 2 +- src/lib_shell/state.ml | 2 +- src/lib_shell/state_logging.ml | 10 ++++++++++ src/lib_shell/state_logging.mli | 10 ++++++++++ src/lib_shell/worker_logging.ml | 10 ++++++++++ src/lib_shell/worker_logging.mli | 10 ++++++++++ src/lib_stdlib/logging.ml | 20 ------------------- src/lib_stdlib/logging.mli | 20 ------------------- src/lib_storage/store_helpers.ml | 2 +- src/lib_storage/store_logging.ml | 10 ++++++++++ src/lib_storage/store_logging.mli | 10 ++++++++++ .../lib_baking/client_baking_denunciation.ml | 2 +- .../lib_baking/client_baking_endorsement.ml | 2 +- .../lib_baking/client_baking_forge.ml | 2 +- 34 files changed, 176 insertions(+), 56 deletions(-) create mode 100644 src/bin_node/node_logging.ml create mode 100644 src/bin_node/node_logging.mli create mode 100644 src/bin_signer/signer_logging.ml create mode 100644 src/bin_signer/signer_logging.mli create mode 100644 src/lib_base/base_logging.ml create mode 100644 src/lib_base/base_logging.mli create mode 100644 src/lib_protocol_updater/updater_logging.ml create mode 100644 src/lib_protocol_updater/updater_logging.mli create mode 100644 src/lib_rpc_http/RPC_logging.ml create mode 100644 src/lib_rpc_http/RPC_logging.mli create mode 100644 src/lib_shell/state_logging.ml create mode 100644 src/lib_shell/state_logging.mli create mode 100644 src/lib_shell/worker_logging.ml create mode 100644 src/lib_shell/worker_logging.mli create mode 100644 src/lib_storage/store_logging.ml create mode 100644 src/lib_storage/store_logging.mli diff --git a/src/bin_node/node_logging.ml b/src/bin_node/node_logging.ml new file mode 100644 index 000000000..504d75398 --- /dev/null +++ b/src/bin_node/node_logging.ml @@ -0,0 +1,10 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +include Tezos_stdlib.Logging.Make(struct let name = "node.main" end) diff --git a/src/bin_node/node_logging.mli b/src/bin_node/node_logging.mli new file mode 100644 index 000000000..79bef502a --- /dev/null +++ b/src/bin_node/node_logging.mli @@ -0,0 +1,10 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +include Tezos_stdlib.Logging.LOG diff --git a/src/bin_node/node_run_command.ml b/src/bin_node/node_run_command.ml index 855806b46..60f97e7cf 100644 --- a/src/bin_node/node_run_command.ml +++ b/src/bin_node/node_run_command.ml @@ -7,7 +7,7 @@ (* *) (**************************************************************************) -open Logging.Node.Main +open Node_logging let genesis : State.Chain.genesis = { time = diff --git a/src/bin_node/node_shared_arg.ml b/src/bin_node/node_shared_arg.ml index 717a9147c..1a16dca0b 100644 --- a/src/bin_node/node_shared_arg.ml +++ b/src/bin_node/node_shared_arg.ml @@ -8,7 +8,7 @@ (**************************************************************************) open Cmdliner -open Logging.Node.Main +open Node_logging let (//) = Filename.concat diff --git a/src/bin_signer/handler.ml b/src/bin_signer/handler.ml index c539c9102..5d15f1574 100644 --- a/src/bin_signer/handler.ml +++ b/src/bin_signer/handler.ml @@ -7,7 +7,7 @@ (* *) (**************************************************************************) -let log = Logging.Client.Sign.lwt_log_notice +let log = Signer_logging.lwt_log_notice let sign (cctxt : #Client_context.wallet) pkh data = log "Request for signing %d bytes of data for key %a, magic byte = %02X" diff --git a/src/bin_signer/https_daemon.ml b/src/bin_signer/https_daemon.ml index b696e4cb0..1892be5a9 100644 --- a/src/bin_signer/https_daemon.ml +++ b/src/bin_signer/https_daemon.ml @@ -7,7 +7,7 @@ (* *) (**************************************************************************) -let log = Logging.Client.Sign.lwt_log_notice +let log = Signer_logging.lwt_log_notice let run (cctxt : #Client_context.wallet) ~host ~port ~cert ~key = log "Accepting HTTPS requests on port %d" port >>= fun () -> diff --git a/src/bin_signer/signer_logging.ml b/src/bin_signer/signer_logging.ml new file mode 100644 index 000000000..84556e294 --- /dev/null +++ b/src/bin_signer/signer_logging.ml @@ -0,0 +1,10 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +include Tezos_stdlib.Logging.Make(struct let name = "client.signer" end) diff --git a/src/bin_signer/signer_logging.mli b/src/bin_signer/signer_logging.mli new file mode 100644 index 000000000..79bef502a --- /dev/null +++ b/src/bin_signer/signer_logging.mli @@ -0,0 +1,10 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +include Tezos_stdlib.Logging.LOG diff --git a/src/bin_signer/socket_daemon.ml b/src/bin_signer/socket_daemon.ml index 75ceb585f..d8b65c630 100644 --- a/src/bin_signer/socket_daemon.ml +++ b/src/bin_signer/socket_daemon.ml @@ -9,7 +9,7 @@ open Signer_messages -let log = Logging.Client.Sign.lwt_log_notice +let log = Signer_logging.lwt_log_notice let run (cctxt : #Client_context.wallet) path = Lwt_utils_unix.Socket.bind path >>=? fun fd -> diff --git a/src/lib_base/base_logging.ml b/src/lib_base/base_logging.ml new file mode 100644 index 000000000..6fe5143f1 --- /dev/null +++ b/src/lib_base/base_logging.ml @@ -0,0 +1,10 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +include Tezos_stdlib.Logging.Make(struct let name = "base" end) diff --git a/src/lib_base/base_logging.mli b/src/lib_base/base_logging.mli new file mode 100644 index 000000000..79bef502a --- /dev/null +++ b/src/lib_base/base_logging.mli @@ -0,0 +1,10 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +include Tezos_stdlib.Logging.LOG diff --git a/src/lib_base/lwt_exit.ml b/src/lib_base/lwt_exit.ml index 8b8f5d00f..f6974881c 100644 --- a/src/lib_base/lwt_exit.ml +++ b/src/lib_base/lwt_exit.ml @@ -18,7 +18,7 @@ let () = | Exit -> () | exn -> let backtrace = Printexc.get_backtrace () in - Logging.Node.Main.fatal_error "@[%a%a@]" + Base_logging.fatal_error "@[%a%a@]" (fun ppf exn -> Format.fprintf ppf "@[Uncaught (asynchronous) exception (%d):@ %a@]" diff --git a/src/lib_protocol_updater/updater.ml b/src/lib_protocol_updater/updater.ml index 1195fb503..e3f8b7b21 100644 --- a/src/lib_protocol_updater/updater.ml +++ b/src/lib_protocol_updater/updater.ml @@ -7,7 +7,7 @@ (* *) (**************************************************************************) -open Logging.Updater +open Updater_logging let (//) = Filename.concat diff --git a/src/lib_protocol_updater/updater_logging.ml b/src/lib_protocol_updater/updater_logging.ml new file mode 100644 index 000000000..d27f15842 --- /dev/null +++ b/src/lib_protocol_updater/updater_logging.ml @@ -0,0 +1,10 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +include Tezos_stdlib.Logging.Make(struct let name = "updater" end) diff --git a/src/lib_protocol_updater/updater_logging.mli b/src/lib_protocol_updater/updater_logging.mli new file mode 100644 index 000000000..79bef502a --- /dev/null +++ b/src/lib_protocol_updater/updater_logging.mli @@ -0,0 +1,10 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +include Tezos_stdlib.Logging.LOG diff --git a/src/lib_rpc_http/RPC_logging.ml b/src/lib_rpc_http/RPC_logging.ml new file mode 100644 index 000000000..05d34dbd6 --- /dev/null +++ b/src/lib_rpc_http/RPC_logging.ml @@ -0,0 +1,10 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +include Tezos_stdlib.Logging.Make(struct let name = "rpc" end) diff --git a/src/lib_rpc_http/RPC_logging.mli b/src/lib_rpc_http/RPC_logging.mli new file mode 100644 index 000000000..79bef502a --- /dev/null +++ b/src/lib_rpc_http/RPC_logging.mli @@ -0,0 +1,10 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +include Tezos_stdlib.Logging.LOG diff --git a/src/lib_rpc_http/RPC_server.ml b/src/lib_rpc_http/RPC_server.ml index 317643ebc..446d224af 100644 --- a/src/lib_rpc_http/RPC_server.ml +++ b/src/lib_rpc_http/RPC_server.ml @@ -12,4 +12,4 @@ type cors = Resto_cohttp.Cors.t = { allowed_origins : string list ; } -include Resto_cohttp.Server.Make(RPC_encoding)(Logging.RPC) +include Resto_cohttp.Server.Make(RPC_encoding)(RPC_logging) diff --git a/src/lib_shell/chain.ml b/src/lib_shell/chain.ml index f168d71af..651966caa 100644 --- a/src/lib_shell/chain.ml +++ b/src/lib_shell/chain.ml @@ -7,7 +7,7 @@ (* *) (**************************************************************************) -open Logging.Node.State +open State_logging let mempool_encoding = Mempool.encoding diff --git a/src/lib_shell/node.ml b/src/lib_shell/node.ml index 784fc0b6c..34c0328e5 100644 --- a/src/lib_shell/node.ml +++ b/src/lib_shell/node.ml @@ -8,7 +8,7 @@ (**************************************************************************) open Lwt.Infix -open Logging.Node.Worker +open Worker_logging let inject_operation validator ?chain_id bytes = let t = diff --git a/src/lib_shell/node_rpc.ml b/src/lib_shell/node_rpc.ml index d7de3d008..ce83b5659 100644 --- a/src/lib_shell/node_rpc.ml +++ b/src/lib_shell/node_rpc.ml @@ -7,7 +7,7 @@ (* *) (**************************************************************************) -open Logging.RPC +open RPC_logging let filter_bi operations (bi: Block_services.block_info) = let bi = if operations then bi else { bi with operations = None } in diff --git a/src/lib_shell/state.ml b/src/lib_shell/state.ml index 50ac27296..76304587f 100644 --- a/src/lib_shell/state.ml +++ b/src/lib_shell/state.ml @@ -7,7 +7,7 @@ (* *) (**************************************************************************) -open Logging.Node.State +open State_logging open Validation_errors module Shared = struct diff --git a/src/lib_shell/state_logging.ml b/src/lib_shell/state_logging.ml new file mode 100644 index 000000000..bb7f7d3cf --- /dev/null +++ b/src/lib_shell/state_logging.ml @@ -0,0 +1,10 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +include Tezos_stdlib.Logging.Make(struct let name = "node.state" end) diff --git a/src/lib_shell/state_logging.mli b/src/lib_shell/state_logging.mli new file mode 100644 index 000000000..79bef502a --- /dev/null +++ b/src/lib_shell/state_logging.mli @@ -0,0 +1,10 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +include Tezos_stdlib.Logging.LOG diff --git a/src/lib_shell/worker_logging.ml b/src/lib_shell/worker_logging.ml new file mode 100644 index 000000000..2aea54b15 --- /dev/null +++ b/src/lib_shell/worker_logging.ml @@ -0,0 +1,10 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +include Tezos_stdlib.Logging.Make(struct let name = "node.worker" end) diff --git a/src/lib_shell/worker_logging.mli b/src/lib_shell/worker_logging.mli new file mode 100644 index 000000000..79bef502a --- /dev/null +++ b/src/lib_shell/worker_logging.mli @@ -0,0 +1,10 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +include Tezos_stdlib.Logging.LOG diff --git a/src/lib_stdlib/logging.ml b/src/lib_stdlib/logging.ml index 1dc439bac..cf0132dd7 100644 --- a/src/lib_stdlib/logging.ml +++ b/src/lib_stdlib/logging.ml @@ -67,26 +67,6 @@ module Make(S : sig val name: string end) : LOG = struct end module Core = Make(struct let name = "core" end) -module P2p = Make(struct let name = "p2p" end) -module RPC = Make(struct let name = "rpc" end) -module Db = Make(struct let name = "db" end) -module Updater = Make(struct let name = "updater" end) -module Node = struct - module State = Make(struct let name = "node.state" end) - module Validator = Make(struct let name = "node.validator" end) - module Prevalidator = Make(struct let name = "node.prevalidator" end) - module Discoverer = Make(struct let name = "node.discoverer" end) - module Worker = Make(struct let name = "node.worker" end) - module Main = Make(struct let name = "node.main" end) -end -module Client = struct - module Blocks = Make(struct let name = "client.blocks" end) - module Baking = Make(struct let name = "client.baking" end) - module Endorsement = Make(struct let name = "client.endorsement" end) - module Revelation = Make(struct let name = "client.revealation" end) - module Denunciation = Make(struct let name = "client.denunciation" end) - module Sign = Make(struct let name = "client.signer" end) -end type level = Lwt_log_core.level = | Debug diff --git a/src/lib_stdlib/logging.mli b/src/lib_stdlib/logging.mli index 3dd66a7c6..706b656b6 100644 --- a/src/lib_stdlib/logging.mli +++ b/src/lib_stdlib/logging.mli @@ -26,26 +26,6 @@ module type LOG = sig end module Core : LOG -module P2p : LOG -module RPC : LOG -module Db : LOG -module Updater : LOG -module Node : sig - module State : LOG - module Validator : LOG - module Prevalidator : LOG - module Discoverer : LOG - module Worker : LOG - module Main : LOG -end -module Client : sig - module Blocks : LOG - module Baking : LOG - module Endorsement : LOG - module Revelation : LOG - module Denunciation : LOG - module Sign : LOG -end module Make(S: sig val name: string end) : LOG diff --git a/src/lib_storage/store_helpers.ml b/src/lib_storage/store_helpers.ml index 82c88cc69..f465dc58a 100644 --- a/src/lib_storage/store_helpers.ml +++ b/src/lib_storage/store_helpers.ml @@ -18,7 +18,7 @@ module Make_value (V : ENCODED_VALUE) = struct let to_bytes v = try Data_encoding.Binary.to_bytes_exn V.encoding v with Data_encoding.Binary.Write_error error -> - Logging.Node.State.log_error + Store_logging.log_error "Exception while serializing value %a" Data_encoding.Binary.pp_write_error error ; MBytes.create 0 diff --git a/src/lib_storage/store_logging.ml b/src/lib_storage/store_logging.ml new file mode 100644 index 000000000..4f772c45d --- /dev/null +++ b/src/lib_storage/store_logging.ml @@ -0,0 +1,10 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +include Tezos_stdlib.Logging.Make(struct let name = "db" end) diff --git a/src/lib_storage/store_logging.mli b/src/lib_storage/store_logging.mli new file mode 100644 index 000000000..79bef502a --- /dev/null +++ b/src/lib_storage/store_logging.mli @@ -0,0 +1,10 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +include Tezos_stdlib.Logging.LOG diff --git a/src/proto_alpha/lib_baking/client_baking_denunciation.ml b/src/proto_alpha/lib_baking/client_baking_denunciation.ml index fe5716e2f..57cb8979f 100644 --- a/src/proto_alpha/lib_baking/client_baking_denunciation.ml +++ b/src/proto_alpha/lib_baking/client_baking_denunciation.ml @@ -7,7 +7,7 @@ (* *) (**************************************************************************) -open Logging.Client.Denunciation +include Logging.Make(struct let name = "client.denunciation" end) let create cctxt endorsement_stream = let last_get_endorsement = ref None in diff --git a/src/proto_alpha/lib_baking/client_baking_endorsement.ml b/src/proto_alpha/lib_baking/client_baking_endorsement.ml index 1e4fe876e..70acbcdee 100644 --- a/src/proto_alpha/lib_baking/client_baking_endorsement.ml +++ b/src/proto_alpha/lib_baking/client_baking_endorsement.ml @@ -10,7 +10,7 @@ open Proto_alpha open Alpha_context -open Logging.Client.Endorsement +include Logging.Make(struct let name = "client.endorsement" end) module State : sig diff --git a/src/proto_alpha/lib_baking/client_baking_forge.ml b/src/proto_alpha/lib_baking/client_baking_forge.ml index a202c2e85..6314cd42f 100644 --- a/src/proto_alpha/lib_baking/client_baking_forge.ml +++ b/src/proto_alpha/lib_baking/client_baking_forge.ml @@ -10,7 +10,7 @@ open Proto_alpha open Alpha_context -open Logging.Client.Baking +include Logging.Make(struct let name = "client.baking" end) let generate_proof_of_work_nonce () = Rand.generate Constants.proof_of_work_nonce_size