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.
This commit is contained in:
parent
64b537d799
commit
f2037c5d52
12
logger.go
12
logger.go
@ -11,17 +11,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type messageLogger struct {
|
type messageLogger struct {
|
||||||
conn *upstreamConn
|
network *network
|
||||||
entity string
|
entity string
|
||||||
|
|
||||||
path string
|
path string
|
||||||
file *os.File
|
file *os.File
|
||||||
}
|
}
|
||||||
|
|
||||||
func newMessageLogger(uc *upstreamConn, entity string) *messageLogger {
|
func newMessageLogger(network *network, entity string) *messageLogger {
|
||||||
return &messageLogger{
|
return &messageLogger{
|
||||||
conn: uc,
|
network: network,
|
||||||
entity: entity,
|
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: enforce maximum open file handles (LRU cache of file handles)
|
||||||
// TODO: handle non-monotonic clock behaviour
|
// TODO: handle non-monotonic clock behaviour
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
path := logPath(ml.conn.network, ml.entity, now)
|
path := logPath(ml.network, ml.entity, now)
|
||||||
if ml.path != path {
|
if ml.path != path {
|
||||||
if ml.file != nil {
|
if ml.file != nil {
|
||||||
ml.file.Close()
|
ml.file.Close()
|
||||||
|
@ -1285,7 +1285,7 @@ func (uc *upstreamConn) appendLog(entity string, msg *irc.Message) {
|
|||||||
|
|
||||||
ml, ok := uc.messageLoggers[entity]
|
ml, ok := uc.messageLoggers[entity]
|
||||||
if !ok {
|
if !ok {
|
||||||
ml = newMessageLogger(uc, entity)
|
ml = newMessageLogger(uc.network, entity)
|
||||||
uc.messageLoggers[entity] = ml
|
uc.messageLoggers[entity] = ml
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user