mgorus

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2022 License: MIT Imports: 8 Imported by: 0

README

Mongodb Hooks for Logrus

Install

$ go get github.com/cptpower/mgorus

Usage

package main

import (
	"github.com/sirupsen/logrus"
	"github.com/cptpower/mgorus"
)

func main() {
	log := logrus.New()
	hooker, err := mgorus.NewHooker("mongodb://localhost:27017", "db", "collection")
	if err == nil {
	    log.Hooks.Add(hooker)
	} else {
		fmt.Print(err)
	}

	log.WithFields(logrus.Fields{
		"name": "zhangsan",
		"age":  28,
	}).Error("Hello world!")
}

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHooker

func NewHooker(mgoUrl, db, collection string) (*hooker, error)

func NewHookerFromCollection

func NewHookerFromCollection(collection *mongo.Collection) *hooker

Types

type M

type M bson.M

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL