Skip to content

Hook for sending events zap logger to mixin messenger.

License

Notifications You must be signed in to change notification settings

xwjdsh/zapmixin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zapmixin

Go Report Card

Hook for sending events zap logger to mixin.

Usage

package main

import (
	"github.com/fox-one/mixin-sdk-go"
	"github.com/xwjdsh/zapmixin"
	"go.uber.org/zap"
)

func main() {
	client, err := mixin.NewFromKeystore(&mixin.Keystore{
		ClientID:   "<client_id>",
		SessionID:  "<session_id>",
		PrivateKey: "<private_key>",
		PinToken:   "<pin_token>",
		Scope:      "<scope>",
	})
	if err != nil {
		panic(err)
	}

	conversations := []string{"<conversation_id>"}
	h, err := zapmixin.New(client, conversations)

	logger, _ := zap.NewProduction()
	logger.WithOptions(zap.Hooks(h.Hook()))

	logger.Info("info")
	logger.Warn("warn")
	logger.Error("error")
}

Parameters

Required

Optional

  • WithThresholdLevel - Level threshold, the default level is WARN.
  • WithFixedLevel - Only the given level will send the message.
  • WithSync - The default is to send messages to mixin asynchronously.
  • WithFormatter - Custom formatter.
  • WithFilter - Filters are applied to messages to determine if any entry should not be send out.
  • WithAfter - When the message is sent, it will be called.

Installation

go get github.com/xwjdsh/zapmixin

Credits

Based on zaptelegram.

About

Hook for sending events zap logger to mixin messenger.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages