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

View File

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

View File

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