diff --git a/client.go b/client.go index cc179c8..950cbca 100644 --- a/client.go +++ b/client.go @@ -55,7 +55,7 @@ func NewClient(hostname string, conn net.Conn) *Client { func (client *Client) Processor(sink chan<- ClientEvent) { var buf_net []byte buf := make([]byte, 0) - log.Println("New client", client) + log.Println(client, "New client") sink <- ClientEvent{client, EVENT_NEW, ""} for { buf_net = make([]byte, BUF_SIZE) diff --git a/daemon.go b/daemon.go index 2cb2153..1f142c2 100644 --- a/daemon.go +++ b/daemon.go @@ -40,6 +40,7 @@ var ( ) type Daemon struct { + Verbose bool hostname string motd string clients map[*Client]bool @@ -197,6 +198,7 @@ func (daemon *Daemon) ClientRegister(client *Client, command string, cols []stri // to corresponding daemon's places and start room's processor goroutine. func (daemon *Daemon) RoomRegister(name string) (*Room, chan<- ClientEvent) { room_new := NewRoom(daemon.hostname, name, daemon.log_sink, daemon.state_sink) + room_new.Verbose = daemon.Verbose room_sink := make(chan ClientEvent) daemon.rooms[name] = room_new daemon.room_sinks[room_new] = room_sink @@ -289,7 +291,9 @@ func (daemon *Daemon) Processor(events <-chan ClientEvent) { case EVENT_MSG: cols := strings.SplitN(event.text, " ", 2) command := strings.ToUpper(cols[0]) - log.Println(client, "command", command) + if daemon.Verbose { + log.Println(client, "command", command) + } if command == "QUIT" { delete(daemon.clients, client) client.conn.Close() diff --git a/goircd.go b/goircd.go index aeca83a..e176804 100644 --- a/goircd.go +++ b/goircd.go @@ -39,6 +39,8 @@ var ( ssl = flag.Bool("ssl", false, "Use SSL only.") sslKey = flag.String("ssl_key", "", "SSL keyfile.") sslCert = flag.String("ssl_cert", "", "SSL certificate.") + + verbose = flag.Bool("v", false, "Enable verbose logging.") ) func Run() { @@ -64,6 +66,7 @@ func Run() { state_sink := make(chan StateEvent) daemon := NewDaemon(*hostname, *motd, log_sink, state_sink) + daemon.Verbose = *verbose if *statedir == "" { // Dummy statekeeper go func() { diff --git a/room.go b/room.go index 08eb46d..ccd7ae9 100644 --- a/room.go +++ b/room.go @@ -36,6 +36,7 @@ func RoomNameValid(name string) bool { } type Room struct { + Verbose bool name string topic string key string @@ -85,7 +86,9 @@ func (room *Room) Processor(events <-chan ClientEvent) { switch event.event_type { case EVENT_NEW: room.members[client] = true - log.Println(client, "joined", room.name) + if room.Verbose { + log.Println(client, "joined", room.name) + } room.SendTopic(client) room.Broadcast(fmt.Sprintf(":%s JOIN %s", client, room.name)) room.log_sink <- LogEvent{room.name, client.nickname, "joined", true}