// Must initialize the mongo session func InitMongo(url string) (err error) { mongolog := log.New(os.Stderr, "MONGO ", log.LstdFlags) mgo.SetLogger(mongolog) mgo.SetDebug(true) session, err = mgo.Dial(url) return err }
func openMgoSession(t *testing.T) *mgo.Session { mgo.SetLogger(log.New(os.Stderr, "MONGO ", log.LstdFlags)) mgo.SetDebug(true) s, err := mgo.Dial("localhost") if err != nil { t.Fatalf("Error opening mongo session. %v", err) } return s }
// sets global logger based on verbosity level in configuration // optional parameter: default.verbose (defaults to true if not present or incorrectly set) func InitLogger() { verbose, err := configFile.GetBool("default", "verbose") logger = log4go.NewVerboseLogger(verbose, nil, "") if err != nil { logger.Warn(err) verbose = true } logger.Printf("verbose set [%v]", verbose) if verbose { mgo.SetLogger(logger) mgo.SetDebug(verbose) } }
func (s *S) SetUpSuite(c *C) { mgo.SetDebug(true) mgo.SetStats(true) s.StartAll() }