diff --git a/CHANGELOG.md b/CHANGELOG.md index 35821680..b151426a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ New release of Oragono! * Added `USERHOST` command (thanks @vegax87). ### Changed +* Logging is now much better and useful. ### Removed diff --git a/irc/channel.go b/irc/channel.go index 5b26a467..002f6f54 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -264,6 +264,8 @@ func (channel *Channel) Join(client *Client, key string) { return } + client.server.logger.Log(LogDebug, "join", fmt.Sprintf("%s joined channel %s", client.nick, channel.name)) + for member := range channel.members { if member.capabilities[ExtendedJoin] { member.Send(nil, client.nickMaskString, "JOIN", channel.name, client.account.Name, client.realname) @@ -303,6 +305,8 @@ func (channel *Channel) Part(client *Client, message string) { member.Send(nil, client.nickMaskString, "PART", channel.name, message) } channel.Quit(client) + + client.server.logger.Log(LogDebug, "part", fmt.Sprintf("%s left channel %s", client.nick, channel.name)) } func (channel *Channel) GetTopic(client *Client) { diff --git a/irc/client.go b/irc/client.go index 644b6200..829ab425 100644 --- a/irc/client.go +++ b/irc/client.go @@ -170,6 +170,8 @@ func (client *Client) run() { maxlenTags, maxlenRest := client.maxlens() + client.server.logger.Log(LogDebug, "userinput ", client.nick, " ->", line) + msg, err = ircmsg.ParseLineMaxLen(line, maxlenTags, maxlenRest) if err == ircmsg.ErrorLineIsEmpty { continue @@ -402,7 +404,7 @@ func (client *Client) AllNickmasks() []string { // SetNickname sets the very first nickname for the client. func (client *Client) SetNickname(nickname string) error { if client.HasNick() { - client.server.logger.Log(LogError, "nick", client.nick, fmt.Sprintf("%s nickname already set, something is wrong with server consistency", client.nickMaskString)) + client.server.logger.Log(LogError, "nick", fmt.Sprintf("%s nickname already set, something is wrong with server consistency", client.nickMaskString)) return ErrNickAlreadySet } @@ -419,6 +421,7 @@ func (client *Client) ChangeNickname(nickname string) error { origNickMask := client.nickMaskString err := client.server.clients.Replace(client.nick, nickname, client) if err == nil { + client.server.logger.Log(LogDebug, "nick", fmt.Sprintf("%s changed nickname to %s", client.nick, nickname)) client.server.whoWas.Append(client) client.nick = nickname client.updateNickMask() @@ -443,6 +446,8 @@ func (client *Client) destroy() { return } + client.server.logger.Log(LogDebug, "quit", fmt.Sprintf("%s is no longer on the server", client.nick)) + // send quit/error message to client if they haven't been sent already client.Quit("Connection closed") @@ -590,6 +595,8 @@ func (client *Client) Send(tags *map[string]ircmsg.TagValue, prefix string, comm line = line[:len(line)-3] + "\r\n" } + client.server.logger.Log(LogDebug, "useroutput", client.nick, "<- ", strings.TrimRight(line, "\r\n")) + client.socket.Write(line) return nil } diff --git a/irc/logger.go b/irc/logger.go index 9fc8bf7d..84d8e393 100644 --- a/irc/logger.go +++ b/irc/logger.go @@ -9,6 +9,8 @@ import ( "os" "time" + "strings" + "github.com/mgutz/ansi" ) @@ -115,7 +117,8 @@ func (logger *SingleLogger) Log(level LogLevel, logType string, messageParts ... } // ensure we're capturing this logType - capturing := (logger.Types["*"] || logger.Types[logType]) && !logger.ExcludedTypes["*"] && !logger.ExcludedTypes[logType] + logTypeCleaned := strings.ToLower(strings.TrimSpace(logType)) + capturing := (logger.Types["*"] || logger.Types[logTypeCleaned]) && !logger.ExcludedTypes["*"] && !logger.ExcludedTypes[logTypeCleaned] if !capturing { return } diff --git a/irc/server.go b/irc/server.go index d7ac1e8f..9d2b70fd 100644 --- a/irc/server.go +++ b/irc/server.go @@ -644,6 +644,7 @@ func (server *Server) tryRegister(c *Client) { } // continue registration + server.logger.Log(LogDebug, "localconnect", fmt.Sprintf("Client registered [%s]", c.nick)) c.Register() // send welcome text @@ -657,8 +658,6 @@ func (server *Server) tryRegister(c *Client) { c.RplISupport() server.MOTD(c) c.Send(nil, c.nickMaskString, RPL_UMODEIS, c.nick, c.ModeString()) - - server.logger.Log(LogDebug, "localconnect", fmt.Sprintf("Client registered [%s]", c.nick)) } // MOTD serves the Message of the Day. diff --git a/oragono.yaml b/oragono.yaml index 502cd47f..6f4bd6e6 100644 --- a/oragono.yaml +++ b/oragono.yaml @@ -196,10 +196,15 @@ logging: # password password hashing and comparing # userinput raw lines sent by users # useroutput raw lines sent to users - type: "* -userinput -useroutput" + type: "* -userinput -useroutput -localconnect -localconnect-ip" # one of: debug info warn error - level: warn + level: info + - + # avoid logging IP addresses to file + method: stderr + type: localconnect localconnect-ip + level: debug # datastore configuration datastore: