github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/core/logger/tailer.go (about) 1 // Copyright 2022 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package logger 5 6 import ( 7 "time" 8 9 "github.com/juju/loggo" 10 ) 11 12 // LogTailer allows for retrieval of Juju's logs. 13 // It first returns any matching already recorded logs and 14 // then waits for additional matching logs as they appear. 15 type LogTailer interface { 16 // Logs returns the channel through which the LogTailer returns Juju logs. 17 // It will be closed when the tailer stops. 18 Logs() <-chan *LogRecord 19 20 // Dying returns a channel which will be closed as the LogTailer stops. 21 Dying() <-chan struct{} 22 23 // Stop is used to request that the LogTailer stops. 24 // It blocks until the LogTailer has stopped. 25 Stop() error 26 27 // Err returns the error that caused the LogTailer to stopped. 28 // If it hasn't stopped or stopped without error nil will be returned. 29 Err() error 30 } 31 32 // LogTailerParams specifies the filtering a LogTailer should 33 // apply to log records in order to decide which to return. 34 type LogTailerParams struct { 35 StartID int64 36 StartTime time.Time 37 MinLevel loggo.Level 38 InitialLines int 39 NoTail bool 40 IncludeEntity []string 41 ExcludeEntity []string 42 IncludeModule []string 43 ExcludeModule []string 44 IncludeLabel []string 45 ExcludeLabel []string 46 }