Decrease log verbosity.

This commit is contained in:
Thomas Habets 2014-06-08 02:49:27 +02:00
parent 54d2fcb9cb
commit c1d256aaa0
4 changed files with 13 additions and 3 deletions

View File

@ -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)

View File

@ -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()

View File

@ -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() {

View File

@ -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}