weekface / mgorus Goto Github PK
View Code? Open in Web Editor NEWMongodb Hooks for Logrus
License: MIT License
Mongodb Hooks for Logrus
License: MIT License
logHook, err := mgorus.NewHooker(cnf.LogHook.DBHost, cnf.LogHook.DBName, cnf.LogHook.System)
if err != nil {
return nil, err
}
svc.Logger = log.New()
svc.Hooks.Add(logHook)
log.SetLevel(logrus.ErrorLevel)
in fact shows all levels logs
Sirupsen changed their username to lowercase sirupsen. Using this library creates an error when using the new github.com/sirupsen/logrus path in linking code.
Mongodb authentication with authenticationDatabase
Do not have this option
โ ~ mongo --help |grep authenticationDatabase
--authenticationDatabase arg user source (defaults to dbname)
Is there any way I can choose the collection dynamically when writing the log?
I need to log to different collections based on if it's a message, execution result etc ...
Hi,
thank you for providing this logrus hook.
I can't connect to my mongo cluster using the provided constructors.
After few attempts I was able to connect to the mongo cluster with this code (coming from few different post found on internet, none of which was enough to work):
dialInfo := &mgo.DialInfo{
Addrs: []string{
"cluster-prefix-1.mongodb.net:27017",
"cluster-prefix-2.mongodb.net:27017",
"cluster-prefix-3.mongodb.net:27017",
},
Timeout: 20 * time.Second,
Database: "admin",
Username: "USER",
Password: "PW",
DialServer: func(addr *mgo.ServerAddr) (net.Conn, error) {
conn, err := tls.Dial("tcp", addr.String(), &tls.Config{InsecureSkipVerify: true})
return conn, err
},
}
s, err := mgo.DialWithInfo(dialInfo)
if err != nil {
log.Fatalf(can't connect: %v\n", err)
}
I propose the following new constructor with this PR to let the users be free to connect in whichever way they can:
func NewHookerFromCollection(collection *mgo.Collection)*hooker{
return &hooker{c: collection}
}
How do I authenticate with my DB? Using MongoDb authentication in the url failed to work.
Thanks.
Hello, I'm just opening this issue to let you know, the next release of logrus (v1.2.0) will add a new trace level named Trace below Debug.
Here is the PR for reference sirupsen/logrus#844
You may want to take into account this new level.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.