1
0
Fork 0
forked from External/grumble

Improved logging.

This commit is contained in:
Mikkel Krautz 2011-11-10 00:38:59 +01:00
parent 244027d41b
commit b13dbeadf1
6 changed files with 82 additions and 6 deletions

View file

@ -26,7 +26,6 @@ import (
"hash"
"log"
"net"
"os"
"path/filepath"
"strings"
"sync"
@ -122,7 +121,7 @@ type clientLogForwarder struct {
}
func (lf clientLogForwarder) Write(incoming []byte) (int, error) {
buf := bytes.NewBuffer(nil)
buf := new(bytes.Buffer)
buf.WriteString(fmt.Sprintf("<%v:%v(%v)> ", lf.client.Session, lf.client.ShownName(), lf.client.UserId()))
buf.Write(incoming)
lf.logger.Output(3, buf.String())
@ -166,7 +165,7 @@ func NewServer(id int64, addr string, port int) (s *Server, err error) {
s.Channels[0] = NewChannel(0, "Root")
s.nextChanId = 1
s.Logger = log.New(os.Stdout, fmt.Sprintf("[%v] ", s.Id), log.LstdFlags|log.Lmicroseconds)
s.Logger = log.New(&LogTarget, fmt.Sprintf("[%v] ", s.Id), log.LstdFlags|log.Lmicroseconds)
return
}