LogFile is Logger implementation for default Docker logging.
| 29 | |
| 30 | // LogFile is Logger implementation for default Docker logging. |
| 31 | type LogFile struct { |
| 32 | mu sync.Mutex // protects the logfile access |
| 33 | closed chan struct{} |
| 34 | rotateMu sync.Mutex // blocks the next rotation until the current rotation is completed |
| 35 | // Lock out readers while performing a non-atomic sequence of filesystem |
| 36 | // operations (RLock: open, Lock: rename, delete). |
| 37 | // |
| 38 | // fsopMu should be locked for writing only while holding rotateMu. |
| 39 | fsopMu sync.RWMutex |
| 40 | |
| 41 | // Logger configuration |
| 42 | |
| 43 | capacity int64 // maximum size of each file |
| 44 | maxFiles int // maximum number of files |
| 45 | compress bool // whether old versions of log files are compressed |
| 46 | perms os.FileMode |
| 47 | |
| 48 | // Log file codec |
| 49 | |
| 50 | createDecoder MakeDecoderFn |
| 51 | getTailReader GetTailReaderFunc |
| 52 | |
| 53 | // Log reader state in a 1-buffered channel. |
| 54 | // |
| 55 | // Share memory by communicating: receive to acquire, send to release. |
| 56 | // The state struct is passed around by value so that use-after-send |
| 57 | // bugs cannot escalate to data races. |
| 58 | // |
| 59 | // A method which receives the state value takes ownership of it. The |
| 60 | // owner is responsible for either passing ownership along or sending |
| 61 | // the state back to the channel. By convention, the semantics of |
| 62 | // passing along ownership is expressed with function argument types. |
| 63 | // Methods which take a pointer *logReadState argument borrow the state, |
| 64 | // analogous to functions which require a lock to be held when calling. |
| 65 | // The caller retains ownership. Calling a method which takes a |
| 66 | // value logFileState argument gives ownership to the callee. |
| 67 | read chan logReadState |
| 68 | |
| 69 | decompress *sharedTempFileConverter |
| 70 | |
| 71 | pos logPos // Current log file write position. |
| 72 | f *os.File // Current log file for writing. |
| 73 | lastTimestamp time.Time // timestamp of the last log |
| 74 | } |
| 75 | |
| 76 | type logPos struct { |
| 77 | // Size of the current file. |
nothing calls this directly
no outgoing calls
no test coverage detected