examples/interact.go
changeset 103 f27f78706623
parent 101 5d721a565503
child 105 aa895dfae3f6
equal deleted inserted replaced
102:872e936f9f3f 103:f27f78706623
     6 
     6 
     7 import (
     7 import (
     8 	xmpp ".."
     8 	xmpp ".."
     9 	"flag"
     9 	"flag"
    10 	"fmt"
    10 	"fmt"
    11 	"io"
       
    12 	"log"
    11 	"log"
    13 	"os"
    12 	"os"
    14 )
    13 )
    15 
    14 
       
    15 type StdLogger struct {
       
    16 }
       
    17 
       
    18 func (s *StdLogger) Log(v ...interface{}) {
       
    19 	log.Println(v)
       
    20 }
       
    21 
       
    22 func (s *StdLogger) Logf(fmt string, v ...interface{}) {
       
    23 	log.Printf(fmt, v)
       
    24 }
       
    25 
    16 func init() {
    26 func init() {
    17 	r, w := io.Pipe()
    27 	logger := &StdLogger{}
    18 	go io.Copy(os.Stdout, r)
    28 	xmpp.Debug = logger
    19 	xmpp.Debug = log.New(w, "debug: ", 0)
    29 	xmpp.Info = logger
    20 	xmpp.Info = log.New(w, "info: ", 0)
    30 	xmpp.Warn = logger
    21 	xmpp.Warn = log.New(w, "warn: ", 0)
       
    22 }
    31 }
    23 
    32 
    24 // Demonstrate the API, and allow the user to interact with an XMPP
    33 // Demonstrate the API, and allow the user to interact with an XMPP
    25 // server via the terminal.
    34 // server via the terminal.
    26 func main() {
    35 func main() {