chat log to stdout

This commit is contained in:
Stephen McQuay 2015-04-05 22:48:39 -07:00
parent 287574622a
commit ccd7e8353b
3 changed files with 6 additions and 5 deletions

View File

@ -26,7 +26,7 @@ func main() {
config := &Config{
Host: "",
Port: 8000,
LogLevel: int(logging.DEBUG),
LogLevel: int(logging.INFO),
}
err := envconfig.Process("chat", config)
if err != nil {
@ -65,7 +65,7 @@ func main() {
logs.Fatal("problem getting hostname:", err)
}
}
logs.Debug("serving at: http://%s:%d/", hostname, config.Port)
logs.Info("serving at: http://%s:%d/", hostname, config.Port)
addr := fmt.Sprintf("%s:%d", config.Host, config.Port)
err = http.ListenAndServe(addr, sm)

View File

@ -27,7 +27,7 @@ func addRoutes(sm *http.ServeMux, chat *Chat, staticFiles string) {
}
if staticFiles == "" {
logs.Critical("embedded static file serving")
logs.Debug("embedded static file serving")
sm.Handle(
prefix["static"],
http.FileServer(
@ -50,7 +50,7 @@ func addRoutes(sm *http.ServeMux, chat *Chat, staticFiles string) {
},
)
} else {
logs.Critical("setting up dev mode static file serving")
logs.Debug("setting up dev mode static file serving")
sm.Handle(
prefix["static"],
http.StripPrefix(

View File

@ -1,6 +1,7 @@
package chat
import (
"fmt"
"net/http"
"sync"
@ -54,7 +55,7 @@ func (c *Chat) Sender() {
select {
case msg := <-c.chatter:
c.ulock.Lock()
logs.Debug("got message: %q", msg)
fmt.Println(msg)
for name, user := range c.users {
logs.Debug("\tsending %s: %q", name, msg)
user.send <- msg