MCPcopy
hub / github.com/aceld/zinx / OutPut

Method OutPut

zlog/logger_core.go:197–240  ·  view source on GitHub ↗

OutPut outputs log file, the original method

(level int, s string)

Source from the content-addressed store, hash-verified

195
196// OutPut outputs log file, the original method
197func (log *ZinxLoggerCore) OutPut(level int, s string) error {
198 now := time.Now() // get current time
199 var file string // file name of the current caller of the log interface
200 var line int // line number of the executed code
201 log.mu.Lock()
202 defer log.mu.Unlock()
203
204 if log.flag&(BitShortFile|BitLongFile) != 0 {
205 log.mu.Unlock()
206 var ok bool
207 // get the file name and line number of the current caller
208 _, file, line, ok = runtime.Caller(log.calldDepth)
209 if !ok {
210 file = "unknown-file"
211 line = 0
212 }
213 log.mu.Lock()
214 }
215
216 // reset buffer
217 log.buf.Reset()
218 // write log header
219 log.formatHeader(now, file, line, level)
220 // write log content
221 log.buf.WriteString(s)
222 // add line break
223 if len(s) > 0 && s[len(s)-1] != '\n' {
224 log.buf.WriteByte('\n')
225 }
226
227 var err error
228 if log.fw == nil {
229 // if log file is not set, output to console
230 _, _ = os.Stderr.Write(log.buf.Bytes())
231 } else {
232 // write the filled buffer to IO output
233 _, err = log.fw.Write(log.buf.Bytes())
234 }
235
236 if log.onLogHook != nil {
237 log.onLogHook(log.buf.Bytes())
238 }
239 return err
240}
241
242func (log *ZinxLoggerCore) verifyLogIsolation(logLevel int) bool {
243 return log.isolationLevel > logLevel

Callers 13

DebugfMethod · 0.95
DebugMethod · 0.95
InfofMethod · 0.95
InfoMethod · 0.95
WarnfMethod · 0.95
WarnMethod · 0.95
ErrorfMethod · 0.95
ErrorMethod · 0.95
FatalfMethod · 0.95
FatalMethod · 0.95
PanicfMethod · 0.95
PanicMethod · 0.95

Calls 3

formatHeaderMethod · 0.95
WriteMethod · 0.80
ResetMethod · 0.45

Tested by

no test coverage detected