Make newMessageLogger take a *network instead of an *upstreamConn

There's no reason why messgeLogger needs access to the whole connection,
the network is enough.

git-svn-id: file:///srv/svn/repo/suika/trunk@248 f0ae65fe-ee39-954e-97ec-027ff2717ef4
This commit is contained in:
contact 2020-04-07 19:54:24 +00:00
parent 2381bdc3aa
commit cec36bb0e1
2 changed files with 7 additions and 7 deletions

View File

@ -11,17 +11,17 @@ import (
)
type messageLogger struct {
conn *upstreamConn
entity string
network *network
entity string
path string
file *os.File
}
func newMessageLogger(uc *upstreamConn, entity string) *messageLogger {
func newMessageLogger(network *network, entity string) *messageLogger {
return &messageLogger{
conn: uc,
entity: entity,
network: network,
entity: entity,
}
}
@ -46,7 +46,7 @@ func (ml *messageLogger) Append(msg *irc.Message) error {
// TODO: enforce maximum open file handles (LRU cache of file handles)
// TODO: handle non-monotonic clock behaviour
now := time.Now()
path := logPath(ml.conn.network, ml.entity, now)
path := logPath(ml.network, ml.entity, now)
if ml.path != path {
if ml.file != nil {
ml.file.Close()

View File

@ -1285,7 +1285,7 @@ func (uc *upstreamConn) appendLog(entity string, msg *irc.Message) {
ml, ok := uc.messageLoggers[entity]
if !ok {
ml = newMessageLogger(uc, entity)
ml = newMessageLogger(uc.network, entity)
uc.messageLoggers[entity] = ml
}