Add the ability to turn on/off debug logging

This commit is contained in:
Sarah Jamie Lewis 2015-10-15 23:27:16 -07:00
parent 4ff30ee723
commit 2d93acf065
1 changed files with 8 additions and 2 deletions

View File

@ -33,8 +33,14 @@ type Ricochet struct {
// Init sets up the Ricochet object. It takes in a filename of a hidden service // Init sets up the Ricochet object. It takes in a filename of a hidden service
// private_key file so it can successfully authenticate itself with other // private_key file so it can successfully authenticate itself with other
// clients. // clients.
func (r *Ricochet) Init(filename string) { func (r *Ricochet) Init(filename string, debugLog bool) {
r.logger = log.New(os.Stdout, "[Ricochet]: ", log.Ltime|log.Lmicroseconds)
if debugLog {
r.logger = log.New(os.Stdout, "[Ricochet]: ", log.Ltime|log.Lmicroseconds)
} else {
r.logger = log.New(ioutil.Discard, "[Ricochet]: ", log.Ltime|log.Lmicroseconds)
}
pemData, err := ioutil.ReadFile(filename) pemData, err := ioutil.ReadFile(filename)
if err != nil { if err != nil {