MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / appendLogbuf

Method appendLogbuf

pkg/controller/rtctrl/logstore.go:192–217  ·  view source on GitHub ↗
(buf []byte, force bool)

Source from the content-addressed store, hash-verified

190}
191
192func (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
219func (s *kunLogStatStore) WriteStdLog(from int, buf []byte, eof bool) (int, error) {
220 if s.flags.Has(flagClosed) {

Callers 3

WriteStdLogMethod · 0.95
WriteFunctionLogMethod · 0.95

Calls 2

LockMethod · 0.80
WriteMethod · 0.65

Tested by

no test coverage detected