mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
logging: Add userinput and output, fix up lots
This commit is contained in:
parent
415a8117ee
commit
b328a4fcd3
@ -17,6 +17,7 @@ New release of Oragono!
|
|||||||
* Added `USERHOST` command (thanks @vegax87).
|
* Added `USERHOST` command (thanks @vegax87).
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
* Logging is now much better and useful.
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
@ -264,6 +264,8 @@ func (channel *Channel) Join(client *Client, key string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client.server.logger.Log(LogDebug, "join", fmt.Sprintf("%s joined channel %s", client.nick, channel.name))
|
||||||
|
|
||||||
for member := range channel.members {
|
for member := range channel.members {
|
||||||
if member.capabilities[ExtendedJoin] {
|
if member.capabilities[ExtendedJoin] {
|
||||||
member.Send(nil, client.nickMaskString, "JOIN", channel.name, client.account.Name, client.realname)
|
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)
|
member.Send(nil, client.nickMaskString, "PART", channel.name, message)
|
||||||
}
|
}
|
||||||
channel.Quit(client)
|
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) {
|
func (channel *Channel) GetTopic(client *Client) {
|
||||||
|
@ -170,6 +170,8 @@ func (client *Client) run() {
|
|||||||
|
|
||||||
maxlenTags, maxlenRest := client.maxlens()
|
maxlenTags, maxlenRest := client.maxlens()
|
||||||
|
|
||||||
|
client.server.logger.Log(LogDebug, "userinput ", client.nick, " ->", line)
|
||||||
|
|
||||||
msg, err = ircmsg.ParseLineMaxLen(line, maxlenTags, maxlenRest)
|
msg, err = ircmsg.ParseLineMaxLen(line, maxlenTags, maxlenRest)
|
||||||
if err == ircmsg.ErrorLineIsEmpty {
|
if err == ircmsg.ErrorLineIsEmpty {
|
||||||
continue
|
continue
|
||||||
@ -402,7 +404,7 @@ func (client *Client) AllNickmasks() []string {
|
|||||||
// SetNickname sets the very first nickname for the client.
|
// SetNickname sets the very first nickname for the client.
|
||||||
func (client *Client) SetNickname(nickname string) error {
|
func (client *Client) SetNickname(nickname string) error {
|
||||||
if client.HasNick() {
|
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
|
return ErrNickAlreadySet
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,6 +421,7 @@ func (client *Client) ChangeNickname(nickname string) error {
|
|||||||
origNickMask := client.nickMaskString
|
origNickMask := client.nickMaskString
|
||||||
err := client.server.clients.Replace(client.nick, nickname, client)
|
err := client.server.clients.Replace(client.nick, nickname, client)
|
||||||
if err == nil {
|
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.server.whoWas.Append(client)
|
||||||
client.nick = nickname
|
client.nick = nickname
|
||||||
client.updateNickMask()
|
client.updateNickMask()
|
||||||
@ -443,6 +446,8 @@ func (client *Client) destroy() {
|
|||||||
return
|
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
|
// send quit/error message to client if they haven't been sent already
|
||||||
client.Quit("Connection closed")
|
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"
|
line = line[:len(line)-3] + "\r\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client.server.logger.Log(LogDebug, "useroutput", client.nick, "<- ", strings.TrimRight(line, "\r\n"))
|
||||||
|
|
||||||
client.socket.Write(line)
|
client.socket.Write(line)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/mgutz/ansi"
|
"github.com/mgutz/ansi"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -115,7 +117,8 @@ func (logger *SingleLogger) Log(level LogLevel, logType string, messageParts ...
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ensure we're capturing this logType
|
// 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 {
|
if !capturing {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -644,6 +644,7 @@ func (server *Server) tryRegister(c *Client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// continue registration
|
// continue registration
|
||||||
|
server.logger.Log(LogDebug, "localconnect", fmt.Sprintf("Client registered [%s]", c.nick))
|
||||||
c.Register()
|
c.Register()
|
||||||
|
|
||||||
// send welcome text
|
// send welcome text
|
||||||
@ -657,8 +658,6 @@ func (server *Server) tryRegister(c *Client) {
|
|||||||
c.RplISupport()
|
c.RplISupport()
|
||||||
server.MOTD(c)
|
server.MOTD(c)
|
||||||
c.Send(nil, c.nickMaskString, RPL_UMODEIS, c.nick, c.ModeString())
|
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.
|
// MOTD serves the Message of the Day.
|
||||||
|
@ -196,10 +196,15 @@ logging:
|
|||||||
# password password hashing and comparing
|
# password password hashing and comparing
|
||||||
# userinput raw lines sent by users
|
# userinput raw lines sent by users
|
||||||
# useroutput raw lines sent to users
|
# useroutput raw lines sent to users
|
||||||
type: "* -userinput -useroutput"
|
type: "* -userinput -useroutput -localconnect -localconnect-ip"
|
||||||
|
|
||||||
# one of: debug info warn error
|
# 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 configuration
|
||||||
datastore:
|
datastore:
|
||||||
|
Loading…
Reference in New Issue
Block a user