From f2037c5d525aa414b91c11b0981015ea9acd85da Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 7 Apr 2020 21:54:24 +0200 Subject: [PATCH] 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. --- logger.go | 12 ++++++------ upstream.go | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/logger.go b/logger.go index 6cc5302..fe2a58c 100644 --- a/logger.go +++ b/logger.go @@ -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() diff --git a/upstream.go b/upstream.go index 63c4965..ae3cd71 100644 --- a/upstream.go +++ b/upstream.go @@ -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 }