Decrease log verbosity.
This commit is contained in:
parent
54d2fcb9cb
commit
c1d256aaa0
@ -55,7 +55,7 @@ func NewClient(hostname string, conn net.Conn) *Client {
|
|||||||
func (client *Client) Processor(sink chan<- ClientEvent) {
|
func (client *Client) Processor(sink chan<- ClientEvent) {
|
||||||
var buf_net []byte
|
var buf_net []byte
|
||||||
buf := make([]byte, 0)
|
buf := make([]byte, 0)
|
||||||
log.Println("New client", client)
|
log.Println(client, "New client")
|
||||||
sink <- ClientEvent{client, EVENT_NEW, ""}
|
sink <- ClientEvent{client, EVENT_NEW, ""}
|
||||||
for {
|
for {
|
||||||
buf_net = make([]byte, BUF_SIZE)
|
buf_net = make([]byte, BUF_SIZE)
|
||||||
|
@ -40,6 +40,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Daemon struct {
|
type Daemon struct {
|
||||||
|
Verbose bool
|
||||||
hostname string
|
hostname string
|
||||||
motd string
|
motd string
|
||||||
clients map[*Client]bool
|
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.
|
// to corresponding daemon's places and start room's processor goroutine.
|
||||||
func (daemon *Daemon) RoomRegister(name string) (*Room, chan<- ClientEvent) {
|
func (daemon *Daemon) RoomRegister(name string) (*Room, chan<- ClientEvent) {
|
||||||
room_new := NewRoom(daemon.hostname, name, daemon.log_sink, daemon.state_sink)
|
room_new := NewRoom(daemon.hostname, name, daemon.log_sink, daemon.state_sink)
|
||||||
|
room_new.Verbose = daemon.Verbose
|
||||||
room_sink := make(chan ClientEvent)
|
room_sink := make(chan ClientEvent)
|
||||||
daemon.rooms[name] = room_new
|
daemon.rooms[name] = room_new
|
||||||
daemon.room_sinks[room_new] = room_sink
|
daemon.room_sinks[room_new] = room_sink
|
||||||
@ -289,7 +291,9 @@ func (daemon *Daemon) Processor(events <-chan ClientEvent) {
|
|||||||
case EVENT_MSG:
|
case EVENT_MSG:
|
||||||
cols := strings.SplitN(event.text, " ", 2)
|
cols := strings.SplitN(event.text, " ", 2)
|
||||||
command := strings.ToUpper(cols[0])
|
command := strings.ToUpper(cols[0])
|
||||||
|
if daemon.Verbose {
|
||||||
log.Println(client, "command", command)
|
log.Println(client, "command", command)
|
||||||
|
}
|
||||||
if command == "QUIT" {
|
if command == "QUIT" {
|
||||||
delete(daemon.clients, client)
|
delete(daemon.clients, client)
|
||||||
client.conn.Close()
|
client.conn.Close()
|
||||||
|
@ -39,6 +39,8 @@ var (
|
|||||||
ssl = flag.Bool("ssl", false, "Use SSL only.")
|
ssl = flag.Bool("ssl", false, "Use SSL only.")
|
||||||
sslKey = flag.String("ssl_key", "", "SSL keyfile.")
|
sslKey = flag.String("ssl_key", "", "SSL keyfile.")
|
||||||
sslCert = flag.String("ssl_cert", "", "SSL certificate.")
|
sslCert = flag.String("ssl_cert", "", "SSL certificate.")
|
||||||
|
|
||||||
|
verbose = flag.Bool("v", false, "Enable verbose logging.")
|
||||||
)
|
)
|
||||||
|
|
||||||
func Run() {
|
func Run() {
|
||||||
@ -64,6 +66,7 @@ func Run() {
|
|||||||
|
|
||||||
state_sink := make(chan StateEvent)
|
state_sink := make(chan StateEvent)
|
||||||
daemon := NewDaemon(*hostname, *motd, log_sink, state_sink)
|
daemon := NewDaemon(*hostname, *motd, log_sink, state_sink)
|
||||||
|
daemon.Verbose = *verbose
|
||||||
if *statedir == "" {
|
if *statedir == "" {
|
||||||
// Dummy statekeeper
|
// Dummy statekeeper
|
||||||
go func() {
|
go func() {
|
||||||
|
3
room.go
3
room.go
@ -36,6 +36,7 @@ func RoomNameValid(name string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Room struct {
|
type Room struct {
|
||||||
|
Verbose bool
|
||||||
name string
|
name string
|
||||||
topic string
|
topic string
|
||||||
key string
|
key string
|
||||||
@ -85,7 +86,9 @@ func (room *Room) Processor(events <-chan ClientEvent) {
|
|||||||
switch event.event_type {
|
switch event.event_type {
|
||||||
case EVENT_NEW:
|
case EVENT_NEW:
|
||||||
room.members[client] = true
|
room.members[client] = true
|
||||||
|
if room.Verbose {
|
||||||
log.Println(client, "joined", room.name)
|
log.Println(client, "joined", room.name)
|
||||||
|
}
|
||||||
room.SendTopic(client)
|
room.SendTopic(client)
|
||||||
room.Broadcast(fmt.Sprintf(":%s JOIN %s", client, room.name))
|
room.Broadcast(fmt.Sprintf(":%s JOIN %s", client, room.name))
|
||||||
room.log_sink <- LogEvent{room.name, client.nickname, "joined", true}
|
room.log_sink <- LogEvent{room.name, client.nickname, "joined", true}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user