Browse Source

logging: Add userinput and output, fix up lots

tags/v0.7.0
Daniel Oaks 7 years ago
parent
commit
b328a4fcd3
6 changed files with 25 additions and 6 deletions
  1. 1
    0
      CHANGELOG.md
  2. 4
    0
      irc/channel.go
  3. 8
    1
      irc/client.go
  4. 4
    1
      irc/logger.go
  5. 1
    2
      irc/server.go
  6. 7
    2
      oragono.yaml

+ 1
- 0
CHANGELOG.md View File

17
 * Added `USERHOST` command (thanks @vegax87).
17
 * Added `USERHOST` command (thanks @vegax87).
18
  
18
  
19
 ### Changed
19
 ### Changed
20
+* Logging is now much better and useful.
20
  
21
  
21
 ### Removed
22
 ### Removed
22
  
23
  

+ 4
- 0
irc/channel.go View File

264
 		return
264
 		return
265
 	}
265
 	}
266
 
266
 
267
+	client.server.logger.Log(LogDebug, "join", fmt.Sprintf("%s joined channel %s", client.nick, channel.name))
268
+
267
 	for member := range channel.members {
269
 	for member := range channel.members {
268
 		if member.capabilities[ExtendedJoin] {
270
 		if member.capabilities[ExtendedJoin] {
269
 			member.Send(nil, client.nickMaskString, "JOIN", channel.name, client.account.Name, client.realname)
271
 			member.Send(nil, client.nickMaskString, "JOIN", channel.name, client.account.Name, client.realname)
303
 		member.Send(nil, client.nickMaskString, "PART", channel.name, message)
305
 		member.Send(nil, client.nickMaskString, "PART", channel.name, message)
304
 	}
306
 	}
305
 	channel.Quit(client)
307
 	channel.Quit(client)
308
+
309
+	client.server.logger.Log(LogDebug, "part", fmt.Sprintf("%s left channel %s", client.nick, channel.name))
306
 }
310
 }
307
 
311
 
308
 func (channel *Channel) GetTopic(client *Client) {
312
 func (channel *Channel) GetTopic(client *Client) {

+ 8
- 1
irc/client.go View File

170
 
170
 
171
 		maxlenTags, maxlenRest := client.maxlens()
171
 		maxlenTags, maxlenRest := client.maxlens()
172
 
172
 
173
+		client.server.logger.Log(LogDebug, "userinput ", client.nick, " ->", line)
174
+
173
 		msg, err = ircmsg.ParseLineMaxLen(line, maxlenTags, maxlenRest)
175
 		msg, err = ircmsg.ParseLineMaxLen(line, maxlenTags, maxlenRest)
174
 		if err == ircmsg.ErrorLineIsEmpty {
176
 		if err == ircmsg.ErrorLineIsEmpty {
175
 			continue
177
 			continue
402
 // SetNickname sets the very first nickname for the client.
404
 // SetNickname sets the very first nickname for the client.
403
 func (client *Client) SetNickname(nickname string) error {
405
 func (client *Client) SetNickname(nickname string) error {
404
 	if client.HasNick() {
406
 	if client.HasNick() {
405
-		client.server.logger.Log(LogError, "nick", client.nick, fmt.Sprintf("%s nickname already set, something is wrong with server consistency", client.nickMaskString))
407
+		client.server.logger.Log(LogError, "nick", fmt.Sprintf("%s nickname already set, something is wrong with server consistency", client.nickMaskString))
406
 		return ErrNickAlreadySet
408
 		return ErrNickAlreadySet
407
 	}
409
 	}
408
 
410
 
419
 	origNickMask := client.nickMaskString
421
 	origNickMask := client.nickMaskString
420
 	err := client.server.clients.Replace(client.nick, nickname, client)
422
 	err := client.server.clients.Replace(client.nick, nickname, client)
421
 	if err == nil {
423
 	if err == nil {
424
+		client.server.logger.Log(LogDebug, "nick", fmt.Sprintf("%s changed nickname to %s", client.nick, nickname))
422
 		client.server.whoWas.Append(client)
425
 		client.server.whoWas.Append(client)
423
 		client.nick = nickname
426
 		client.nick = nickname
424
 		client.updateNickMask()
427
 		client.updateNickMask()
443
 		return
446
 		return
444
 	}
447
 	}
445
 
448
 
449
+	client.server.logger.Log(LogDebug, "quit", fmt.Sprintf("%s is no longer on the server", client.nick))
450
+
446
 	// send quit/error message to client if they haven't been sent already
451
 	// send quit/error message to client if they haven't been sent already
447
 	client.Quit("Connection closed")
452
 	client.Quit("Connection closed")
448
 
453
 
590
 		line = line[:len(line)-3] + "\r\n"
595
 		line = line[:len(line)-3] + "\r\n"
591
 	}
596
 	}
592
 
597
 
598
+	client.server.logger.Log(LogDebug, "useroutput", client.nick, "<- ", strings.TrimRight(line, "\r\n"))
599
+
593
 	client.socket.Write(line)
600
 	client.socket.Write(line)
594
 	return nil
601
 	return nil
595
 }
602
 }

+ 4
- 1
irc/logger.go View File

9
 	"os"
9
 	"os"
10
 	"time"
10
 	"time"
11
 
11
 
12
+	"strings"
13
+
12
 	"github.com/mgutz/ansi"
14
 	"github.com/mgutz/ansi"
13
 )
15
 )
14
 
16
 
115
 	}
117
 	}
116
 
118
 
117
 	// ensure we're capturing this logType
119
 	// ensure we're capturing this logType
118
-	capturing := (logger.Types["*"] || logger.Types[logType]) && !logger.ExcludedTypes["*"] && !logger.ExcludedTypes[logType]
120
+	logTypeCleaned := strings.ToLower(strings.TrimSpace(logType))
121
+	capturing := (logger.Types["*"] || logger.Types[logTypeCleaned]) && !logger.ExcludedTypes["*"] && !logger.ExcludedTypes[logTypeCleaned]
119
 	if !capturing {
122
 	if !capturing {
120
 		return
123
 		return
121
 	}
124
 	}

+ 1
- 2
irc/server.go View File

644
 	}
644
 	}
645
 
645
 
646
 	// continue registration
646
 	// continue registration
647
+	server.logger.Log(LogDebug, "localconnect", fmt.Sprintf("Client registered [%s]", c.nick))
647
 	c.Register()
648
 	c.Register()
648
 
649
 
649
 	// send welcome text
650
 	// send welcome text
657
 	c.RplISupport()
658
 	c.RplISupport()
658
 	server.MOTD(c)
659
 	server.MOTD(c)
659
 	c.Send(nil, c.nickMaskString, RPL_UMODEIS, c.nick, c.ModeString())
660
 	c.Send(nil, c.nickMaskString, RPL_UMODEIS, c.nick, c.ModeString())
660
-
661
-	server.logger.Log(LogDebug, "localconnect", fmt.Sprintf("Client registered [%s]", c.nick))
662
 }
661
 }
663
 
662
 
664
 // MOTD serves the Message of the Day.
663
 // MOTD serves the Message of the Day.

+ 7
- 2
oragono.yaml View File

196
         #   password        password hashing and comparing
196
         #   password        password hashing and comparing
197
         #   userinput       raw lines sent by users
197
         #   userinput       raw lines sent by users
198
         #   useroutput      raw lines sent to users
198
         #   useroutput      raw lines sent to users
199
-        type: "* -userinput -useroutput"
199
+        type: "* -userinput -useroutput -localconnect -localconnect-ip"
200
 
200
 
201
         # one of: debug info warn error
201
         # one of: debug info warn error
202
-        level: warn
202
+        level: info
203
+    -
204
+        # avoid logging IP addresses to file
205
+        method: stderr
206
+        type: localconnect localconnect-ip
207
+        level: debug
203
 
208
 
204
 # datastore configuration
209
 # datastore configuration
205
 datastore:
210
 datastore:

Loading…
Cancel
Save