export logger so it can be disabled

This commit is contained in:
Andrew Gallant (Ocelot) 2012-05-16 23:26:19 -04:00
parent 45a4ee92eb
commit 424f293671
2 changed files with 15 additions and 15 deletions

View File

@ -33,8 +33,8 @@ func (c *Conn) connect(display string) error {
authName, authData, err := readAuthority(c.host, c.display)
noauth := false
if err != nil {
logger.Printf("Could not get authority info: %v", err)
logger.Println("Trying connection without authority info...")
Logger.Printf("Could not get authority info: %v", err)
Logger.Println("Trying connection without authority info...")
authName = ""
authData = []byte{}
noauth = true

View File

@ -10,7 +10,7 @@ import (
)
var (
logger = log.New(os.Stderr, "XGB: ", 0)
Logger = log.New(os.Stderr, "XGB: ", 0)
// ExtLock is a lock used whenever new extensions are initialized.
// It should not be used. It is exported for use in the extension
@ -304,8 +304,8 @@ func (c *Conn) sendRequests() {
// writeBuffer is a convenience function for writing a byte slice to the wire.
func (c *Conn) writeBuffer(buf []byte) {
if _, err := c.conn.Write(buf); err != nil {
logger.Printf("Write error: %s", err)
logger.Fatal("A write error is unrecoverable. Exiting...")
Logger.Printf("Write error: %s", err)
Logger.Fatal("A write error is unrecoverable. Exiting...")
}
}
@ -333,8 +333,8 @@ func (c *Conn) readResponses() {
err, event, seq = nil, nil, 0
if _, err := io.ReadFull(c.conn, buf); err != nil {
logger.Printf("Read error: %s", err)
logger.Fatal("A read error is unrecoverable. Exiting...")
Logger.Printf("Read error: %s", err)
Logger.Fatal("A read error is unrecoverable. Exiting...")
}
switch buf[0] {
@ -343,7 +343,7 @@ func (c *Conn) readResponses() {
// generated) by looking it up by the error number.
newErrFun, ok := NewErrorFuncs[int(buf[1])]
if !ok {
logger.Printf("BUG: Could not find error constructor function "+
Logger.Printf("BUG: Could not find error constructor function "+
"for error with number %d.", buf[1])
continue
}
@ -362,8 +362,8 @@ func (c *Conn) readResponses() {
biggerBuf := make([]byte, byteCount)
copy(biggerBuf[:32], buf)
if _, err := io.ReadFull(c.conn, biggerBuf[32:]); err != nil {
logger.Printf("Read error: %s", err)
logger.Fatal("A read error is unrecoverable. Exiting...")
Logger.Printf("Read error: %s", err)
Logger.Fatal("A read error is unrecoverable. Exiting...")
}
replyBytes = biggerBuf
} else {
@ -380,7 +380,7 @@ func (c *Conn) readResponses() {
evNum := int(buf[0] & 127)
newEventFun, ok := NewEventFuncs[evNum]
if !ok {
logger.Printf("BUG: Could not find event construct function "+
Logger.Printf("BUG: Could not find event construct function "+
"for event with number %d.", evNum)
continue
}
@ -429,7 +429,7 @@ func (c *Conn) readResponses() {
}
} else { // this is a reply
if cookie.replyChan == nil {
logger.Printf("Reply with sequence id %d does not "+
Logger.Printf("Reply with sequence id %d does not "+
"have a cookie with a valid reply channel.", seq)
continue
} else {
@ -442,12 +442,12 @@ func (c *Conn) readResponses() {
switch {
// Checked requests with replies
case cookie.replyChan != nil && cookie.errorChan != nil:
logger.Printf("Found cookie with sequence id %d that is "+
Logger.Printf("Found cookie with sequence id %d that is "+
"expecting a reply but will never get it. Currently "+
"on sequence number %d", cookie.Sequence, seq)
// Unchecked requests with replies
case cookie.replyChan != nil && cookie.pingChan != nil:
logger.Printf("Found cookie with sequence id %d that is "+
Logger.Printf("Found cookie with sequence id %d that is "+
"expecting a reply (and not an error) but will never "+
"get it. Currently on sequence number %d",
cookie.Sequence, seq)
@ -470,7 +470,7 @@ func processEventOrError(everr eventOrError) (Event, Error) {
case Error:
return nil, ee
default:
logger.Printf("Invalid event/error type: %T", everr)
Logger.Printf("Invalid event/error type: %T", everr)
return nil, nil
}
panic("unreachable")