From 5c4f1ce43fbe8fe6dd1c4d3c8c145df56a0746b2 Mon Sep 17 00:00:00 2001 From: Lorenzo Delgado Date: Thu, 3 Nov 2022 16:36:24 +0100 Subject: [PATCH] chore: make log topics consistent with nim-chronicles style --- waku/v2/node/discv5/waku_discv5.nim | 2 +- waku/v2/node/dnsdisc/waku_dnsdisc.nim | 2 +- waku/v2/node/jsonrpc/admin_api.nim | 2 +- waku/v2/node/jsonrpc/debug_api.nim | 2 +- waku/v2/node/jsonrpc/filter_api.nim | 2 +- waku/v2/node/jsonrpc/private_api.nim | 2 +- waku/v2/node/jsonrpc/relay_api.nim | 2 +- waku/v2/node/jsonrpc/store_api.nim | 2 +- waku/v2/node/message_cache.nim | 3 ++- waku/v2/node/peer_manager/peer_manager.nim | 6 ++---- waku/v2/node/rest/debug/debug_api.nim | 3 ++- waku/v2/node/rest/relay/relay_api.nim | 3 ++- waku/v2/node/rest/relay/topic_cache.nim | 3 ++- waku/v2/node/rest/serdes.nim | 3 ++- .../message/message_retention_policy_capacity.nim | 2 +- .../storage/message/message_retention_policy_time.nim | 2 +- .../node/storage/message/queue_store/queue_store.nim | 2 +- .../storage/message/sqlite_store/sqlite_store.nim | 2 +- waku/v2/node/waku_metrics.nim | 2 +- waku/v2/node/waku_node.nim | 2 +- waku/v2/protocol/waku_filter/client.nim | 2 +- waku/v2/protocol/waku_filter/protocol.nim | 2 +- waku/v2/protocol/waku_lightpush/client.nim | 2 +- waku/v2/protocol/waku_lightpush/protocol.nim | 2 +- waku/v2/protocol/waku_noise/noise.nim | 2 +- .../waku_noise/noise_handshake_processing.nim | 2 +- waku/v2/protocol/waku_noise/noise_types.nim | 2 +- waku/v2/protocol/waku_noise/noise_utils.nim | 2 +- waku/v2/protocol/waku_peer_exchange/protocol.nim | 2 +- waku/v2/protocol/waku_relay.nim | 11 ++++++----- .../waku_rln_relay/waku_rln_relay_metrics.nim | 2 +- .../protocol/waku_rln_relay/waku_rln_relay_utils.nim | 2 +- waku/v2/protocol/waku_store/client.nim | 2 +- waku/v2/protocol/waku_store/protocol.nim | 2 +- waku/v2/protocol/waku_swap/waku_swap.nim | 2 +- waku/v2/protocol/waku_swap/waku_swap_contracts.nim | 2 +- 36 files changed, 47 insertions(+), 43 deletions(-) diff --git a/waku/v2/node/discv5/waku_discv5.nim b/waku/v2/node/discv5/waku_discv5.nim index f31515087..34126c9bf 100644 --- a/waku/v2/node/discv5/waku_discv5.nim +++ b/waku/v2/node/discv5/waku_discv5.nim @@ -15,7 +15,7 @@ declarePublicGauge waku_discv5_discovered, "number of nodes discovered" declarePublicGauge waku_discv5_errors, "number of waku discv5 errors", ["type"] logScope: - topics = "wakudiscv5" + topics = "waku discv5" type WakuDiscoveryV5* = ref object diff --git a/waku/v2/node/dnsdisc/waku_dnsdisc.nim b/waku/v2/node/dnsdisc/waku_dnsdisc.nim index 80df6b84e..b19eb031f 100644 --- a/waku/v2/node/dnsdisc/waku_dnsdisc.nim +++ b/waku/v2/node/dnsdisc/waku_dnsdisc.nim @@ -26,7 +26,7 @@ declarePublicGauge waku_dnsdisc_discovered, "number of nodes discovered" declarePublicGauge waku_dnsdisc_errors, "number of waku dnsdisc errors", ["type"] logScope: - topics = "wakudnsdisc" + topics = "waku dnsdisc" type WakuDnsDiscovery* = object diff --git a/waku/v2/node/jsonrpc/admin_api.nim b/waku/v2/node/jsonrpc/admin_api.nim index 982534c87..da4bb15fe 100644 --- a/waku/v2/node/jsonrpc/admin_api.nim +++ b/waku/v2/node/jsonrpc/admin_api.nim @@ -17,7 +17,7 @@ import export jsonrpc_types logScope: - topics = "admin api" + topics = "waku node jsonrpc admin_api" const futTimeout* = 30.seconds # Max time to wait for futures diff --git a/waku/v2/node/jsonrpc/debug_api.nim b/waku/v2/node/jsonrpc/debug_api.nim index 0ae3a3fd6..ce642b92d 100644 --- a/waku/v2/node/jsonrpc/debug_api.nim +++ b/waku/v2/node/jsonrpc/debug_api.nim @@ -6,7 +6,7 @@ import ../waku_node logScope: - topics = "debug api" + topics = "waku node jsonrpc debug_api" proc installDebugApiHandlers*(node: WakuNode, rpcsrv: RpcServer) = diff --git a/waku/v2/node/jsonrpc/filter_api.nim b/waku/v2/node/jsonrpc/filter_api.nim index 1208c6a76..e0e0b47b1 100644 --- a/waku/v2/node/jsonrpc/filter_api.nim +++ b/waku/v2/node/jsonrpc/filter_api.nim @@ -14,7 +14,7 @@ import export jsonrpc_types logScope: - topics = "wakunode.rpc.filter" + topics = "waku node jsonrpc filter_api" const DefaultPubsubTopic: PubsubTopic = "/waku/2/default-waku/proto" diff --git a/waku/v2/node/jsonrpc/private_api.nim b/waku/v2/node/jsonrpc/private_api.nim index 4ffac4ff0..bc021c78e 100644 --- a/waku/v2/node/jsonrpc/private_api.nim +++ b/waku/v2/node/jsonrpc/private_api.nim @@ -14,7 +14,7 @@ import export waku_payload, jsonrpc_types logScope: - topics = "private api" + topics = "waku node jsonrpc private_api" const futTimeout* = 5.seconds # Max time to wait for futures diff --git a/waku/v2/node/jsonrpc/relay_api.nim b/waku/v2/node/jsonrpc/relay_api.nim index c909c010c..1c3a113bc 100644 --- a/waku/v2/node/jsonrpc/relay_api.nim +++ b/waku/v2/node/jsonrpc/relay_api.nim @@ -13,7 +13,7 @@ import export jsonrpc_types logScope: - topics = "relay api" + topics = "waku node jsonrpc relay_api" const futTimeout* = 5.seconds # Max time to wait for futures const maxCache* = 30 # Max number of messages cached per topic @TODO make this configurable diff --git a/waku/v2/node/jsonrpc/store_api.nim b/waku/v2/node/jsonrpc/store_api.nim index 6a130ea75..53e009348 100644 --- a/waku/v2/node/jsonrpc/store_api.nim +++ b/waku/v2/node/jsonrpc/store_api.nim @@ -15,7 +15,7 @@ import export jsonrpc_types logScope: - topics = "store api" + topics = "waku node jsonrpc store_api" proc installStoreApiHandlers*(node: WakuNode, rpcsrv: RpcServer) = const futTimeout = 5.seconds diff --git a/waku/v2/node/message_cache.nim b/waku/v2/node/message_cache.nim index 8fff7ab89..848be7423 100644 --- a/waku/v2/node/message_cache.nim +++ b/waku/v2/node/message_cache.nim @@ -9,7 +9,8 @@ import import ../protocol/waku_message -logScope: topics = "message_cache" +logScope: + topics = "waku node message_cache" const DefaultMessageCacheCapacity*: uint = 30 # Max number of messages cached per topic @TODO make this configurable diff --git a/waku/v2/node/peer_manager/peer_manager.nim b/waku/v2/node/peer_manager/peer_manager.nim index 2a50cd6a5..7bfb0a6e4 100644 --- a/waku/v2/node/peer_manager/peer_manager.nim +++ b/waku/v2/node/peer_manager/peer_manager.nim @@ -15,7 +15,7 @@ declarePublicCounter waku_node_conns_initiated, "Number of connections initiated declarePublicGauge waku_peers_errors, "Number of peer manager errors", ["type"] logScope: - topics = "wakupeers" + topics = "waku node peer_manager" type PeerManager* = ref object of RootObj @@ -130,15 +130,13 @@ proc new*(T: type PeerManager, switch: Switch, storage: PeerStorage = nil): Peer peerStore: WakuPeerStore.new(), storage: storage) - debug "creating new PeerManager" - proc peerHook(peerId: PeerID, event: ConnEvent): Future[void] {.gcsafe.} = onConnEvent(pm, peerId, event) pm.switch.addConnEventHandler(peerHook, ConnEventKind.Connected) pm.switch.addConnEventHandler(peerHook, ConnEventKind.Disconnected) - if not storage.isNil: + if not storage.isNil(): debug "found persistent peer storage" pm.loadFromStorage() # Load previously managed peers. else: diff --git a/waku/v2/node/rest/debug/debug_api.nim b/waku/v2/node/rest/debug/debug_api.nim index cda28c595..bed75a785 100644 --- a/waku/v2/node/rest/debug/debug_api.nim +++ b/waku/v2/node/rest/debug/debug_api.nim @@ -10,7 +10,8 @@ import "."/api_types import ".."/[serdes, utils] import ../../waku_node -logScope: topics = "rest_api_debug" +logScope: + topics = "waku node rest debug_api" #### Server request handlers diff --git a/waku/v2/node/rest/relay/relay_api.nim b/waku/v2/node/rest/relay/relay_api.nim index 4c94455c3..9193ee756 100644 --- a/waku/v2/node/rest/relay/relay_api.nim +++ b/waku/v2/node/rest/relay/relay_api.nim @@ -14,7 +14,8 @@ import ./api_types, ./topic_cache -logScope: topics = "rest_api_relay" +logScope: + topics = "waku node rest relay_api" ##### Topic cache diff --git a/waku/v2/node/rest/relay/topic_cache.nim b/waku/v2/node/rest/relay/topic_cache.nim index 3a1a42428..f640c4485 100644 --- a/waku/v2/node/rest/relay/topic_cache.nim +++ b/waku/v2/node/rest/relay/topic_cache.nim @@ -9,7 +9,8 @@ import ../../../protocol/waku_message, ../../message_cache -logScope: topics = "rest_api_relay_topiccache" +logScope: + topics = "waku node rest relay_api" export message_cache diff --git a/waku/v2/node/rest/serdes.nim b/waku/v2/node/rest/serdes.nim index ae0fa774a..fab84bdc8 100644 --- a/waku/v2/node/rest/serdes.nim +++ b/waku/v2/node/rest/serdes.nim @@ -9,7 +9,8 @@ import json_serialization/std/[options, net, sets], presto/common -logScope: topics = "rest_api_serdes" +logScope: + topics = "waku node rest" Json.createFlavor RestJson diff --git a/waku/v2/node/storage/message/message_retention_policy_capacity.nim b/waku/v2/node/storage/message/message_retention_policy_capacity.nim index 0e017040e..5acd54548 100644 --- a/waku/v2/node/storage/message/message_retention_policy_capacity.nim +++ b/waku/v2/node/storage/message/message_retention_policy_capacity.nim @@ -8,7 +8,7 @@ import ./message_retention_policy logScope: - topics = "message_store.sqlite_store.retention_policy.capacity" + topics = "waku node message_store retention_policy" const StoreDefaultCapacity*: int = 25_000 diff --git a/waku/v2/node/storage/message/message_retention_policy_time.nim b/waku/v2/node/storage/message/message_retention_policy_time.nim index d0743453e..361d1405c 100644 --- a/waku/v2/node/storage/message/message_retention_policy_time.nim +++ b/waku/v2/node/storage/message/message_retention_policy_time.nim @@ -11,7 +11,7 @@ import ./message_retention_policy logScope: - topics = "message_store.sqlite_store.retention_policy.time" + topics = "waku node message_store retention_policy" const StoreDefaultRetentionTime*: int64 = 30.days.seconds diff --git a/waku/v2/node/storage/message/queue_store/queue_store.nim b/waku/v2/node/storage/message/queue_store/queue_store.nim index 47cc6b7c8..7dc99ac2f 100644 --- a/waku/v2/node/storage/message/queue_store/queue_store.nim +++ b/waku/v2/node/storage/message/queue_store/queue_store.nim @@ -14,7 +14,7 @@ import logScope: - topics = "message_store.storequeue" + topics = "waku node message_store storequeue" const StoreQueueDefaultMaxCapacity* = 25_000 diff --git a/waku/v2/node/storage/message/sqlite_store/sqlite_store.nim b/waku/v2/node/storage/message/sqlite_store/sqlite_store.nim index 64afc5dbe..3824770e9 100644 --- a/waku/v2/node/storage/message/sqlite_store/sqlite_store.nim +++ b/waku/v2/node/storage/message/sqlite_store/sqlite_store.nim @@ -15,7 +15,7 @@ import ./queries logScope: - topics = "message_store.sqlite" + topics = "waku node message_store sqlite" proc init(db: SqliteDatabase): MessageStoreResult[void] = diff --git a/waku/v2/node/waku_metrics.nim b/waku/v2/node/waku_metrics.nim index 45a389ff6..148392ef7 100644 --- a/waku/v2/node/waku_metrics.nim +++ b/waku/v2/node/waku_metrics.nim @@ -22,7 +22,7 @@ when defined(rln) or defined(rlnzerokit): const LogInterval = 30.seconds logScope: - topics = "waku.metrics" + topics = "waku node metrics" proc startMetricsServer*(serverIp: ValidIpAddress, serverPort: Port) = diff --git a/waku/v2/node/waku_node.nim b/waku/v2/node/waku_node.nim index 35eed81c4..c51accb15 100644 --- a/waku/v2/node/waku_node.nim +++ b/waku/v2/node/waku_node.nim @@ -46,7 +46,7 @@ declarePublicGauge waku_store_peers, "number of store peers" declarePublicGauge waku_px_peers, "number of peers (in the node's peerManager) supporting the peer exchange protocol" logScope: - topics = "wakunode" + topics = "waku node" # Git version in git describe format (defined compile time) diff --git a/waku/v2/protocol/waku_filter/client.nim b/waku/v2/protocol/waku_filter/client.nim index 9f8040b87..3848befda 100644 --- a/waku/v2/protocol/waku_filter/client.nim +++ b/waku/v2/protocol/waku_filter/client.nim @@ -19,7 +19,7 @@ import logScope: - topics = "wakufilter.client" + topics = "waku filter client" const Defaultstring = "/waku/2/default-waku/proto" diff --git a/waku/v2/protocol/waku_filter/protocol.nim b/waku/v2/protocol/waku_filter/protocol.nim index ebccb4759..379087770 100644 --- a/waku/v2/protocol/waku_filter/protocol.nim +++ b/waku/v2/protocol/waku_filter/protocol.nim @@ -16,7 +16,7 @@ import logScope: - topics = "wakufilter" + topics = "waku filter" const diff --git a/waku/v2/protocol/waku_lightpush/client.nim b/waku/v2/protocol/waku_lightpush/client.nim index 329be7aff..c0e616d1c 100644 --- a/waku/v2/protocol/waku_lightpush/client.nim +++ b/waku/v2/protocol/waku_lightpush/client.nim @@ -18,7 +18,7 @@ import logScope: - topics = "wakulightpush.client" + topics = "waku lightpush client" type WakuLightPushClient* = ref object diff --git a/waku/v2/protocol/waku_lightpush/protocol.nim b/waku/v2/protocol/waku_lightpush/protocol.nim index 8fe7282ba..02a7301e4 100644 --- a/waku/v2/protocol/waku_lightpush/protocol.nim +++ b/waku/v2/protocol/waku_lightpush/protocol.nim @@ -16,7 +16,7 @@ import logScope: - topics = "wakulightpush" + topics = "waku lightpush" const WakuLightPushCodec* = "/vac/waku/lightpush/2.0.0-beta1" diff --git a/waku/v2/protocol/waku_noise/noise.nim b/waku/v2/protocol/waku_noise/noise.nim index 94a0f9e7c..e3f634a39 100644 --- a/waku/v2/protocol/waku_noise/noise.nim +++ b/waku/v2/protocol/waku_noise/noise.nim @@ -23,7 +23,7 @@ import libp2p/protocols/secure/secure import ./noise_types logScope: - topics = "wakunoise" + topics = "waku noise" ################################################################# diff --git a/waku/v2/protocol/waku_noise/noise_handshake_processing.nim b/waku/v2/protocol/waku_noise/noise_handshake_processing.nim index 500ad55a1..399b446fb 100644 --- a/waku/v2/protocol/waku_noise/noise_handshake_processing.nim +++ b/waku/v2/protocol/waku_noise/noise_handshake_processing.nim @@ -19,7 +19,7 @@ import ./noise import ./noise_utils logScope: - topics = "wakunoise" + topics = "waku noise" ################################################################# diff --git a/waku/v2/protocol/waku_noise/noise_types.nim b/waku/v2/protocol/waku_noise/noise_types.nim index 7c1dee6ac..911803010 100644 --- a/waku/v2/protocol/waku_noise/noise_types.nim +++ b/waku/v2/protocol/waku_noise/noise_types.nim @@ -18,7 +18,7 @@ import libp2p/errors import libp2p/crypto/[crypto, chacha20poly1305, curve25519] logScope: - topics = "wakunoise" + topics = "waku noise" ################################################################# diff --git a/waku/v2/protocol/waku_noise/noise_utils.nim b/waku/v2/protocol/waku_noise/noise_utils.nim index 91fbb3c43..a16208e68 100644 --- a/waku/v2/protocol/waku_noise/noise_utils.nim +++ b/waku/v2/protocol/waku_noise/noise_utils.nim @@ -19,7 +19,7 @@ import ./noise_types import ./noise logScope: - topics = "wakunoise" + topics = "waku noise" ################################################################# diff --git a/waku/v2/protocol/waku_peer_exchange/protocol.nim b/waku/v2/protocol/waku_peer_exchange/protocol.nim index 55c5a4db7..3ed514f3c 100644 --- a/waku/v2/protocol/waku_peer_exchange/protocol.nim +++ b/waku/v2/protocol/waku_peer_exchange/protocol.nim @@ -24,7 +24,7 @@ declarePublicGauge waku_px_peers_cached, "number of peer exchange peer ENRs cach declarePublicGauge waku_px_errors, "number of peer exchange errors", ["type"] logScope: - topics = "wakupx" + topics = "waku peer_exchange" const diff --git a/waku/v2/protocol/waku_relay.nim b/waku/v2/protocol/waku_relay.nim index 73ee6d08a..38786a692 100644 --- a/waku/v2/protocol/waku_relay.nim +++ b/waku/v2/protocol/waku_relay.nim @@ -8,14 +8,15 @@ else: {.push raises: [].} import - std/[tables, sets], - chronos, chronicles, metrics, - libp2p/protocols/pubsub/[pubsub, gossipsub], - libp2p/protocols/pubsub/rpc/messages, + chronos, + chronicles, + metrics, + libp2p/protocols/pubsub/pubsub, + libp2p/protocols/pubsub/gossipsub, libp2p/stream/connection logScope: - topics = "wakurelay" + topics = "waku relay" const WakuRelayCodec* = "/vac/waku/relay/2.0.0" diff --git a/waku/v2/protocol/waku_rln_relay/waku_rln_relay_metrics.nim b/waku/v2/protocol/waku_rln_relay/waku_rln_relay_metrics.nim index 2175062a5..9e05a43b8 100644 --- a/waku/v2/protocol/waku_rln_relay/waku_rln_relay_metrics.nim +++ b/waku/v2/protocol/waku_rln_relay/waku_rln_relay_metrics.nim @@ -11,7 +11,7 @@ import export metrics logScope: - topics = "waku-rln-relay.metrics" + topics = "waku rln_relay" func generateBucketsForHistogram*(length: int): seq[float64] = ## Generate a custom set of 5 buckets for a given length diff --git a/waku/v2/protocol/waku_rln_relay/waku_rln_relay_utils.nim b/waku/v2/protocol/waku_rln_relay/waku_rln_relay_utils.nim index 19b876d7e..b29bedcda 100644 --- a/waku/v2/protocol/waku_rln_relay/waku_rln_relay_utils.nim +++ b/waku/v2/protocol/waku_rln_relay/waku_rln_relay_utils.nim @@ -23,7 +23,7 @@ import ../waku_message logScope: - topics = "wakurlnrelayutils" + topics = "waku rln_relay" type MerkleNodeResult* = RlnRelayResult[MerkleNode] type RateLimitProofResult* = RlnRelayResult[RateLimitProof] diff --git a/waku/v2/protocol/waku_store/client.nim b/waku/v2/protocol/waku_store/client.nim index 4cc7bfc4c..b680b36d1 100644 --- a/waku/v2/protocol/waku_store/client.nim +++ b/waku/v2/protocol/waku_store/client.nim @@ -22,7 +22,7 @@ import logScope: - topics = "wakustore.client" + topics = "waku store client" type WakuStoreClient* = ref object diff --git a/waku/v2/protocol/waku_store/protocol.nim b/waku/v2/protocol/waku_store/protocol.nim index aaf542b7a..459253ce0 100644 --- a/waku/v2/protocol/waku_store/protocol.nim +++ b/waku/v2/protocol/waku_store/protocol.nim @@ -29,7 +29,7 @@ import logScope: - topics = "wakustore" + topics = "waku store" const diff --git a/waku/v2/protocol/waku_swap/waku_swap.nim b/waku/v2/protocol/waku_swap/waku_swap.nim index e154f522a..3a7ea8562 100644 --- a/waku/v2/protocol/waku_swap/waku_swap.nim +++ b/waku/v2/protocol/waku_swap/waku_swap.nim @@ -55,7 +55,7 @@ declarePublicGauge waku_swap_messages, "number of swap messages received", ["typ declarePublicHistogram waku_peer_swap_account_balance, "Swap Account Balance for waku peers, aggregated into buckets based on threshold limits", buckets = swapAccountBalanceBuckets logScope: - topics = "wakuswap" + topics = "waku swap" const WakuSwapCodec* = "/vac/waku/swap/2.0.0-beta1" diff --git a/waku/v2/protocol/waku_swap/waku_swap_contracts.nim b/waku/v2/protocol/waku_swap/waku_swap_contracts.nim index 5f437b314..946736211 100644 --- a/waku/v2/protocol/waku_swap/waku_swap_contracts.nim +++ b/waku/v2/protocol/waku_swap/waku_swap_contracts.nim @@ -10,7 +10,7 @@ import chronicles, stew/results logScope: - topics = "wakuswapcontracts" + topics = "waku swap" # TODO Richer error types than string, overkill for now... type NodeTaskJsonResult = Result[JsonNode, string]