github.com/ethereumproject/go-ethereum@v5.5.2+incompatible/p2p/discover/mlog.go (about)

     1  // Copyright 2017 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  // This file 'mlog' is home to the 'discover' package implementation of mlog.
    18  // All available mlog lines should be established here as variables and documented.
    19  // For each instance of an mlog call, the respective MLogT variable AssignDetails()
    20  // method should be called with per-use instance details.
    21  
    22  package discover
    23  
    24  import (
    25  	"github.com/ethereumproject/go-ethereum/logger"
    26  )
    27  
    28  var mlogDiscover = logger.MLogRegisterAvailable("discover", mLogLines)
    29  
    30  // mLogLines is a private slice of all available mlog LINES.
    31  // May be used for automatic mlog docmentation generator, or
    32  // for API usage/display/documentation otherwise.
    33  var mLogLines = []*logger.MLogT{
    34  	mlogPingHandleFrom,
    35  	mlogPingSendTo,
    36  	mlogPongHandleFrom,
    37  	mlogPongSendTo,
    38  	mlogFindNodeHandleFrom,
    39  	mlogFindNodeSendTo,
    40  	mlogNeighborsHandleFrom,
    41  	mlogNeighborsSendTo,
    42  }
    43  
    44  // Collect and document available mlog lines.
    45  
    46  // PING
    47  // mlogPingHandleFrom is called once for each ping request from a node FROM
    48  var mlogPingHandleFrom = &logger.MLogT{
    49  	Description: "Called once for each received PING request from peer FROM.",
    50  	Receiver:    "PING",
    51  	Verb:        "HANDLE",
    52  	Subject:     "FROM",
    53  	Details: []logger.MLogDetailT{
    54  		{Owner: "FROM", Key: "UDP_ADDRESS", Value: "STRING"},
    55  		{Owner: "FROM", Key: "ID", Value: "STRING"},
    56  		{Owner: "PING", Key: "BYTES_TRANSFERRED", Value: "INT"},
    57  	},
    58  }
    59  
    60  var mlogPingSendTo = &logger.MLogT{
    61  	Description: "Called once for each outgoing PING request to peer TO.",
    62  	Receiver:    "PING",
    63  	Verb:        "SEND",
    64  	Subject:     "TO",
    65  	Details: []logger.MLogDetailT{
    66  		{Owner: "TO", Key: "UDP_ADDRESS", Value: "STRING"},
    67  		{Owner: "PING", Key: "BYTES_TRANSFERRED", Value: "INT"},
    68  	},
    69  }
    70  
    71  // PONG
    72  // mlogPongHandleFrom is called once for each pong request from a node FROM
    73  var mlogPongHandleFrom = &logger.MLogT{
    74  	Description: "Called once for each received PONG request from peer FROM.",
    75  	Receiver:    "PONG",
    76  	Verb:        "HANDLE",
    77  	Subject:     "FROM",
    78  	Details: []logger.MLogDetailT{
    79  		{Owner: "FROM", Key: "UDP_ADDRESS", Value: "STRING"},
    80  		{Owner: "FROM", Key: "ID", Value: "STRING"},
    81  		{Owner: "PONG", Key: "BYTES_TRANSFERRED", Value: "INT"},
    82  	},
    83  }
    84  
    85  // mlogPingHandleFrom is called once for each ping request from a node FROM
    86  var mlogPongSendTo = &logger.MLogT{
    87  	Description: "Called once for each outgoing PONG request to peer TO.",
    88  	Receiver:    "PONG",
    89  	Verb:        "SEND",
    90  	Subject:     "TO",
    91  	Details: []logger.MLogDetailT{
    92  		{Owner: "TO", Key: "UDP_ADDRESS", Value: "STRING"},
    93  		{Owner: "PONG", Key: "BYTES_TRANSFERRED", Value: "INT"},
    94  	},
    95  }
    96  
    97  // FINDNODE
    98  // mlogFindNodeHandleFrom is called once for each findnode request from a node FROM
    99  var mlogFindNodeHandleFrom = &logger.MLogT{
   100  	Description: "Called once for each received FIND_NODE request from peer FROM.",
   101  	Receiver:    "FINDNODE",
   102  	Verb:        "HANDLE",
   103  	Subject:     "FROM",
   104  	Details: []logger.MLogDetailT{
   105  		{Owner: "FROM", Key: "UDP_ADDRESS", Value: "STRING"},
   106  		{Owner: "FROM", Key: "ID", Value: "STRING"},
   107  		{Owner: "FINDNODE", Key: "BYTES_TRANSFERRED", Value: "INT"},
   108  	},
   109  }
   110  
   111  // mlogFindNodeHandleFrom is called once for each findnode request from a node FROM
   112  var mlogFindNodeSendTo = &logger.MLogT{
   113  	Description: "Called once for each received FIND_NODE request from peer FROM.",
   114  	Receiver:    "FINDNODE",
   115  	Verb:        "SEND",
   116  	Subject:     "TO",
   117  	Details: []logger.MLogDetailT{
   118  		{Owner: "TO", Key: "UDP_ADDRESS", Value: "STRING"},
   119  		{Owner: "FINDNODE", Key: "BYTES_TRANSFERRED", Value: "INT"},
   120  	},
   121  }
   122  
   123  // NEIGHBORS
   124  // mlogNeighborsHandleFrom is called once for each neighbors request from a node FROM
   125  var mlogNeighborsHandleFrom = &logger.MLogT{
   126  	Description: `Called once for each received NEIGHBORS request from peer FROM.`,
   127  	Receiver:    "NEIGHBORS",
   128  	Verb:        "HANDLE",
   129  	Subject:     "FROM",
   130  	Details: []logger.MLogDetailT{
   131  		{Owner: "FROM", Key: "UDP_ADDRESS", Value: "STRING"},
   132  		{Owner: "FROM", Key: "ID", Value: "STRING"},
   133  		{Owner: "NEIGHBORS", Key: "BYTES_TRANSFERRED", Value: "INT"},
   134  	},
   135  }
   136  
   137  // mlogFindNodeSendNeighbors is called once for each sent NEIGHBORS request
   138  var mlogNeighborsSendTo = &logger.MLogT{
   139  	Description: `Called once for each outgoing NEIGHBORS request to peer TO.`,
   140  	Receiver:    "NEIGHBORS",
   141  	Verb:        "SEND",
   142  	Subject:     "TO",
   143  	Details: []logger.MLogDetailT{
   144  		{Owner: "TO", Key: "UDP_ADDRESS", Value: "STRING"},
   145  		{Owner: "NEIGHBORS", Key: "BYTES_TRANSFERRED", Value: "INT"},
   146  	},
   147  }