(buf []byte, force bool)
| 190 | } |
| 191 | |
| 192 | func (s *kunLogStatStore) appendLogbuf(buf []byte, force bool) { |
| 193 | if s.remain <= 0 && !force { |
| 194 | return |
| 195 | } |
| 196 | s.mutex.Lock() |
| 197 | defer s.mutex.Unlock() |
| 198 | logbuf := s.logbuf |
| 199 | if logbuf == nil || (s.remain <= 0 && !force) { |
| 200 | return |
| 201 | } |
| 202 | to := len(buf) |
| 203 | if !force && to > s.remain { |
| 204 | to = s.remain |
| 205 | } |
| 206 | if to <= 0 { |
| 207 | return |
| 208 | } |
| 209 | logbuf.Write(buf[:to]) |
| 210 | s.remain -= to |
| 211 | if to < len(buf) { |
| 212 | if buf[to-1] != '\n' { |
| 213 | logbuf.Write([]byte{'\n'}) |
| 214 | s.remain-- |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | func (s *kunLogStatStore) WriteStdLog(from int, buf []byte, eof bool) (int, error) { |
| 220 | if s.flags.Has(flagClosed) { |
no test coverage detected