MCPcopy
hub / github.com/sirupsen/logrus / log

Method log

entry.go:224–265  ·  view source on GitHub ↗
(level Level, msg string)

Source from the content-addressed store, hash-verified

222}
223
224func (entry *Entry) log(level Level, msg string) {
225 var buffer *bytes.Buffer
226
227 newEntry := entry.Dup()
228
229 if newEntry.Time.IsZero() {
230 newEntry.Time = time.Now()
231 }
232
233 newEntry.Level = level
234 newEntry.Message = msg
235
236 newEntry.Logger.mu.Lock()
237 reportCaller := newEntry.Logger.ReportCaller
238 bufPool := newEntry.getBufferPool()
239 newEntry.Logger.mu.Unlock()
240
241 if reportCaller {
242 newEntry.Caller = getCaller()
243 }
244
245 newEntry.fireHooks()
246 buffer = bufPool.Get()
247 defer func() {
248 newEntry.Buffer = nil
249 buffer.Reset()
250 bufPool.Put(buffer)
251 }()
252 buffer.Reset()
253 newEntry.Buffer = buffer
254
255 newEntry.write()
256
257 newEntry.Buffer = nil
258
259 // To avoid Entry#log() returning a value that only would make sense for
260 // panic() to use in Entry#Panic(), we avoid the allocation by checking
261 // directly here.
262 if level <= PanicLevel {
263 panic(newEntry)
264 }
265}
266
267func (entry *Entry) getBufferPool() (pool BufferPool) {
268 if entry.Logger.BufferPool != nil {

Callers 1

LogMethod · 0.95

Calls 10

DupMethod · 0.95
getCallerFunction · 0.85
LockMethod · 0.80
getBufferPoolMethod · 0.80
UnlockMethod · 0.80
fireHooksMethod · 0.80
ResetMethod · 0.80
writeMethod · 0.80
GetMethod · 0.65
PutMethod · 0.65

Tested by

no test coverage detected