MCPcopy
hub / github.com/andeya/pholcus / writerMsg

Method writerMsg

logs/logs/log.go:173–210  ·  view source on GitHub ↗
(loglevel int, msg string)

Source from the content-addressed store, hash-verified

171}
172
173func (bl *BeeLogger) writerMsg(loglevel int, msg string) error {
174 if i, s := bl.Status(); i != WORK {
175 return errors.New("The current status is " + s)
176 }
177
178 lm := new(logMsg)
179 lm.level = loglevel
180 if bl.enableFuncCallDepth {
181 _, file, line, ok := runtime.Caller(bl.loggerFuncCallDepth)
182 if !ok {
183 file = "???"
184 line = 0
185 }
186 _, filename := path.Split(file)
187 lm.msg = fmt.Sprintf("[%s:%d] %s", filename, line, msg)
188 } else {
189 lm.msg = msg
190 }
191
192 if lm.level <= bl.stealLevel {
193 bl.stealOne(lm)
194 }
195
196 if bl.asynchronous {
197 bl.msg <- lm
198 } else {
199 bl.lock.RLock()
200 defer bl.lock.RUnlock()
201 for name, l := range bl.outputs {
202 err := l.WriteMsg(lm.msg, lm.level)
203 if err != nil {
204 fmt.Println("unable to WriteMsg to adapter:", name, err)
205 return err
206 }
207 }
208 }
209 return nil
210}
211
212// Set log message level.
213//

Callers 9

AppMethod · 0.95
EmergencyMethod · 0.95
AlertMethod · 0.95
CriticalMethod · 0.95
ErrorMethod · 0.95
WarningMethod · 0.95
NoticeMethod · 0.95
InformationalMethod · 0.95
DebugMethod · 0.95

Calls 3

StatusMethod · 0.95
stealOneMethod · 0.95
WriteMsgMethod · 0.65

Tested by

no test coverage detected