mirror of https://github.com/status-im/go-waku.git
chore: allow setting custom logger name and change debug level to storeV3 client (#1118)
This commit is contained in:
parent
ad1b0948e3
commit
0e223591ed
|
@ -86,7 +86,7 @@ func nonRecoverError(err error) error {
|
|||
func Execute(options NodeOptions) error {
|
||||
// Set encoding for logs (console, json, ...)
|
||||
// Note that libp2p reads the encoding from GOLOG_LOG_FMT env var.
|
||||
utils.InitLogger(options.LogEncoding, options.LogOutput)
|
||||
utils.InitLogger(options.LogEncoding, options.LogOutput, "gowaku")
|
||||
|
||||
hostAddr, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("%s:%d", options.Address, options.Port))
|
||||
if err != nil {
|
||||
|
|
|
@ -14,7 +14,7 @@ func main() {
|
|||
app := &cli.App{
|
||||
Flags: getFlags(),
|
||||
Action: func(c *cli.Context) error {
|
||||
utils.InitLogger("console", "file:chat2.log")
|
||||
utils.InitLogger("console", "file:chat2.log", "chat2")
|
||||
|
||||
lvl, err := logging.LevelFromString(options.LogLevel)
|
||||
if err != nil {
|
||||
|
|
|
@ -246,8 +246,9 @@ func (s *WakuStore) next(ctx context.Context, r *Result) (*Result, error) {
|
|||
}
|
||||
|
||||
func (s *WakuStore) queryFrom(ctx context.Context, storeRequest *pb.StoreQueryRequest, selectedPeer peer.ID) (*pb.StoreQueryResponse, error) {
|
||||
logger := s.log.With(logging.HostID("peer", selectedPeer))
|
||||
logger.Info("sending store request")
|
||||
logger := s.log.With(logging.HostID("peer", selectedPeer), zap.String("requestId", hex.EncodeToString([]byte(storeRequest.RequestId))))
|
||||
|
||||
logger.Debug("sending store request")
|
||||
|
||||
stream, err := s.h.NewStream(ctx, selectedPeer, StoreQueryID_v300)
|
||||
if err != nil {
|
||||
|
|
|
@ -12,9 +12,14 @@ var log *zap.Logger
|
|||
var messageLoggers map[string]*zap.Logger
|
||||
|
||||
// Logger creates a zap.Logger with some reasonable defaults
|
||||
func Logger() *zap.Logger {
|
||||
func Logger(name ...string) *zap.Logger {
|
||||
loggerName := "gowaku"
|
||||
if len(name) != 0 {
|
||||
loggerName = name[0]
|
||||
}
|
||||
|
||||
if log == nil {
|
||||
InitLogger("console", "stdout")
|
||||
InitLogger("console", "stdout", loggerName)
|
||||
}
|
||||
return log
|
||||
}
|
||||
|
@ -34,7 +39,7 @@ func MessagesLogger(prefix string) *zap.Logger {
|
|||
}
|
||||
|
||||
// InitLogger initializes a global logger using an specific encoding
|
||||
func InitLogger(encoding string, output string) {
|
||||
func InitLogger(encoding string, output string, name string) {
|
||||
cfg := logging.GetConfig()
|
||||
|
||||
if encoding == "json" {
|
||||
|
@ -72,5 +77,5 @@ func InitLogger(encoding string, output string) {
|
|||
|
||||
logging.SetupLogging(cfg)
|
||||
|
||||
log = logging.Logger("gowaku").Desugar()
|
||||
log = logging.Logger(name).Desugar()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue