-
Notifications
You must be signed in to change notification settings - Fork 2
/
log.go
747 lines (625 loc) · 22.7 KB
/
log.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
// Copyright 2020 The ZKits Project Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package logger
import (
"bytes"
"context"
"fmt"
"io"
"os"
"sync"
"sync/atomic"
"time"
"github.com/edoger/zkits-logger/internal"
)
// Log interface defines an extensible log.
type Log interface {
// Name returns the logger name.
Name() string
// WithMessagePrefix adds a fixed message prefix to the current log.
WithMessagePrefix(string) Log
// WithField adds the given extended data to the log.
WithField(string, interface{}) Log
// WithError adds the given error to the log.
// This method is relative to WithField("error", error).
WithError(error) Log
// WithFields adds the given multiple extended data to the log.
WithFields(map[string]interface{}) Log
// WithFieldPairs adds the given key-value pairs to the log.
WithFieldPairs(pairs ...interface{}) Log
// WithContext adds the given context to the log.
WithContext(context.Context) Log
// WithCaller forces the caller report of the current log to be enabled.
WithCaller(...int) Log
// WithStack adds call stack information to the current log.
WithStack() Log
// IsLevelEnabled checks whether the given log level is enabled.
// Always returns false if the given log level is invalid.
IsLevelEnabled(Level) bool
// IsPanicLevelEnabled checks whether the PanicLevel is enabled.
IsPanicLevelEnabled() bool
// IsFatalLevelEnabled checks whether the FatalLevel is enabled.
IsFatalLevelEnabled() bool
// IsErrorLevelEnabled checks whether the ErrorLevel is enabled.
IsErrorLevelEnabled() bool
// IsWarnLevelEnabled checks whether the WarnLevel is enabled.
IsWarnLevelEnabled() bool
// IsInfoLevelEnabled checks whether the InfoLevel is enabled.
IsInfoLevelEnabled() bool
// IsDebugLevelEnabled checks whether the DebugLevel is enabled.
IsDebugLevelEnabled() bool
// IsTraceLevelEnabled checks whether the TraceLevel is enabled.
IsTraceLevelEnabled() bool
// Log uses the given parameters to record a log of the specified level.
// If the given log level is PanicLevel, the given panic function will be
// called automatically after logging is completed.
// If the given log level is FatalLevel, the given exit function will be
// called automatically after logging is completed.
// If the given log level is invalid, the log will be discarded.
Log(Level, ...interface{})
// Logln uses the given parameters to record a log of the specified level.
// If the given log level is PanicLevel, the given panic function will be
// called automatically after logging is completed.
// If the given log level is FatalLevel, the given exit function will be
// called automatically after logging is completed.
// If the given log level is invalid, the log will be discarded.
Logln(Level, ...interface{})
// Logf uses the given parameters to record a log of the specified level.
// If the given log level is PanicLevel, the given panic function will be
// called automatically after logging is completed.
// If the given log level is FatalLevel, the given exit function will be
// called automatically after logging is completed.
// If the given log level is invalid, the log will be discarded.
Logf(Level, string, ...interface{})
// Trace uses the given parameters to record a TraceLevel log.
Trace(...interface{})
// Traceln uses the given parameters to record a TraceLevel log.
Traceln(...interface{})
// Tracef uses the given parameters to record a TraceLevel log.
Tracef(string, ...interface{})
// Print uses the given parameters to record a TraceLevel log.
Print(...interface{})
// Println uses the given parameters to record a TraceLevel log.
Println(...interface{})
// Printf uses the given parameters to record a TraceLevel log.
Printf(string, ...interface{})
// Debug uses the given parameters to record a DebugLevel log.
Debug(...interface{})
// Debugln uses the given parameters to record a DebugLevel log.
Debugln(...interface{})
// Debugf uses the given parameters to record a DebugLevel log.
Debugf(string, ...interface{})
// Info uses the given parameters to record a InfoLevel log.
Info(...interface{})
// Infoln uses the given parameters to record a InfoLevel log.
Infoln(...interface{})
// Infof uses the given parameters to record a InfoLevel log.
Infof(string, ...interface{})
// Echo uses the given parameters to record a InfoLevel log.
Echo(...interface{})
// Echoln uses the given parameters to record a InfoLevel log.
Echoln(...interface{})
// Echof uses the given parameters to record a InfoLevel log.
Echof(string, ...interface{})
// Warn uses the given parameters to record a WarnLevel log.
Warn(...interface{})
// Warnln uses the given parameters to record a WarnLevel log.
Warnln(...interface{})
// Warnf uses the given parameters to record a WarnLevel log.
Warnf(string, ...interface{})
// Warning uses the given parameters to record a WarnLevel log.
Warning(...interface{})
// Warningln uses the given parameters to record a WarnLevel log.
Warningln(...interface{})
// Warningf uses the given parameters to record a WarnLevel log.
Warningf(string, ...interface{})
// Error uses the given parameters to record a ErrorLevel log.
Error(...interface{})
// Errorln uses the given parameters to record a ErrorLevel log.
Errorln(...interface{})
// Errorf uses the given parameters to record a ErrorLevel log.
Errorf(string, ...interface{})
// Fatal uses the given parameters to record a FatalLevel log.
// After the log record is completed, the system will automatically call
// the exit function given in advance.
Fatal(...interface{})
// Fatalln uses the given parameters to record a FatalLevel log.
// After the log record is completed, the system will automatically call
// the exit function given in advance.
Fatalln(...interface{})
// Fatalf uses the given parameters to record a FatalLevel log.
// After the log record is completed, the system will automatically call
// the exit function given in advance.
Fatalf(string, ...interface{})
// Panic uses the given parameters to record a PanicLevel log.
// After the log record is completed, the system will automatically call
// the panic function given in advance.
Panic(...interface{})
// Panicln uses the given parameters to record a PanicLevel log.
// After the log record is completed, the system will automatically call
// the panic function given in advance.
Panicln(...interface{})
// Panicf uses the given parameters to record a PanicLevel log.
// After the log record is completed, the system will automatically call
// the panic function given in advance.
Panicf(string, ...interface{})
}
// The core type defines the collection of shared attributes within the log,
// and each independent Logger shares the same core instance.
type core struct {
name string
level uint32
formatter Formatter
formatOutput FormatOutput
writer io.Writer
levelWriter map[Level]io.Writer
pool sync.Pool
hooks HookBag
enableHooks bool
timeFormat string
nowFunc func() time.Time
exitFunc func(int)
panicFunc func(string)
caller *internal.CallerReporter
callerSkip int
callerLong bool
levelCaller map[Level]*internal.CallerReporter
interceptor func(Summary, io.Writer) (int, error)
stackPrefixes []string
}
// Create a new core instance and bind the logger name.
func newCore(name string) *core {
return &core{
name: name,
level: uint32(TraceLevel),
formatter: DefaultJSONFormatter(),
writer: os.Stdout,
levelWriter: make(map[Level]io.Writer),
pool: sync.Pool{New: func() interface{} { return new(logEntity) }},
hooks: NewHookBag(),
enableHooks: true,
timeFormat: internal.DefaultTimeFormat,
nowFunc: internal.DefaultNowFunc,
exitFunc: internal.DefaultExitFunc,
panicFunc: internal.DefaultPanicFunc,
levelCaller: make(map[Level]*internal.CallerReporter),
stackPrefixes: internal.KnownStackPrefixes,
}
}
// Get a log entity from the pool and initialize it.
func (c *core) getEntity(l *log, level Level, message, caller string) *logEntity {
o := c.pool.Get().(*logEntity)
o.name = c.name
o.time = c.nowFunc()
o.timeFormat = c.timeFormat
o.level = level
o.message = message
o.ctx = l.ctx
o.caller = caller
o.fields = l.fields
return o
}
// Clean up and recycle the given log entity.
func (c *core) putEntity(o *logEntity) {
// If the log size exceeds 4KB, we need to discard this buffer to
// free memory faster.
if o.buffer.Cap() > 4096 {
o.buffer = bytes.Buffer{}
} else {
o.buffer.Reset()
}
o.name = ""
o.timeFormat = ""
o.message = ""
o.fields = nil
o.ctx = nil
o.caller = ""
o.stack = nil
c.pool.Put(o)
}
// Internal implementation of the Log interface.
type log struct {
core *core
ctx context.Context
fields internal.Fields
caller *internal.CallerReporter
prefix string
stack bool
}
// Name returns the logger name.
func (o *log) Name() string {
return o.core.name
}
// WithMessagePrefix adds a fixed message prefix to the current log.
func (o *log) WithMessagePrefix(prefix string) Log {
if o.prefix == prefix {
return o
}
return &log{core: o.core, fields: o.fields, ctx: o.ctx, caller: o.caller, stack: o.stack, prefix: prefix}
}
// WithField adds the given extended data to the log.
func (o *log) WithField(key string, value interface{}) Log {
r := &log{core: o.core, ctx: o.ctx, caller: o.caller, prefix: o.prefix, stack: o.stack}
if len(o.fields) == 0 {
r.fields = internal.Fields{key: value}
} else {
r.fields = o.fields.Clone(1)
r.fields[key] = value
}
return r
}
// WithError adds the given error to the log.
// This method is relative to WithField("error", error).
func (o *log) WithError(err error) Log {
return o.WithField("error", err)
}
// WithFields adds the given multiple extended data to the log.
func (o *log) WithFields(fields map[string]interface{}) Log {
if len(fields) == 0 {
return o
}
r := &log{core: o.core, ctx: o.ctx, caller: o.caller, prefix: o.prefix, stack: o.stack}
if len(o.fields) == 0 {
r.fields = internal.MakeFields(fields)
} else {
r.fields = o.fields.With(fields)
}
return r
}
// WithFieldPairs adds the given key-value pairs to the log.
func (o *log) WithFieldPairs(pairs ...interface{}) Log {
if len(pairs) == 0 {
return o
}
r := &log{core: o.core, ctx: o.ctx, caller: o.caller, prefix: o.prefix, stack: o.stack}
if len(o.fields) == 0 {
r.fields = internal.FormatPairsToFields(pairs)
} else {
r.fields = o.fields.With(internal.FormatPairsToFields(pairs))
}
return r
}
// WithContext adds the given context to the log.
func (o *log) WithContext(ctx context.Context) Log {
return &log{
core: o.core, fields: o.fields, caller: o.caller, prefix: o.prefix, stack: o.stack,
ctx: ctx,
}
}
// WithCaller forces the caller report of the current log to be enabled.
func (o *log) WithCaller(skip ...int) Log {
var n int
if len(skip) > 0 && skip[0] > 0 {
n = skip[0]
}
// If the caller is equaled, we don't need to create a new log instance.
if o.caller != nil && o.caller.Equal(n) {
return o
}
return &log{
core: o.core, fields: o.fields, ctx: o.ctx, prefix: o.prefix, stack: o.stack,
caller: internal.NewCallerReporter(n),
}
}
// WithStack adds call stack information to the current log.
func (o *log) WithStack() Log {
if o.stack {
return o
}
return &log{
core: o.core, fields: o.fields, ctx: o.ctx, caller: o.caller, prefix: o.prefix,
stack: true,
}
}
// Format and record the current log.
func (o *log) record(level Level, message string) {
entity := o.core.getEntity(o, level, o.prefix+message, o.getCaller(level))
defer o.core.putEntity(entity)
if o.stack {
entity.stack = internal.GetStack(o.core.stackPrefixes)
}
var (
err error
w io.Writer
)
if o.core.formatOutput == nil {
err = o.core.formatter.Format(entity, entity.Buffer())
} else {
w, err = o.core.formatOutput.Format(entity, entity.Buffer())
}
if err == nil {
if o.core.enableHooks {
err = o.core.hooks.Fire(entity)
if err != nil {
internal.EchoError("(%s) Failed to fire log hook: %s", o.core.name, err)
}
}
if err = o.write(entity, w); err != nil {
internal.EchoError("(%s) Failed to write log: %s", o.core.name, err)
}
} else {
// When the format log fails, we terminate the logging and report the error.
internal.EchoError("(%s) Failed to format log: %s", o.core.name, err)
}
if level < ErrorLevel {
switch level {
case FatalLevel:
o.core.exitFunc(1)
case PanicLevel:
o.core.panicFunc(message)
}
}
}
// Get the log writer.
func (o *log) getWriter(entity *logEntity) io.Writer {
if len(o.core.levelWriter) > 0 {
w, found := o.core.levelWriter[entity.level]
if found && w != nil {
return w
}
}
return o.core.writer
}
// Write the current log.
func (o *log) write(entity *logEntity, w io.Writer) (err error) {
if o.core.interceptor == nil {
// When there is no interceptor, make sure that the log written is not empty.
if entity.Size() > 0 {
if w == nil {
w = o.getWriter(entity)
}
_, err = w.Write(entity.Bytes())
}
} else {
if w == nil {
w = o.getWriter(entity)
}
_, err = o.core.interceptor(entity, w)
}
return
}
// Get the caller report. If caller reporting is not enabled in the current
// log, an empty string is always returned.
func (o *log) getCaller(level Level) string {
if o.caller == nil {
if caller, found := o.core.levelCaller[level]; found {
return internal.GetCaller(caller.Skip()+o.core.callerSkip, o.core.callerLong)
}
if o.core.caller != nil {
return internal.GetCaller(o.core.caller.Skip()+o.core.callerSkip, o.core.callerLong)
}
return ""
}
if caller, found := o.core.levelCaller[level]; found {
return internal.GetCaller(caller.Skip()+o.caller.Skip()+o.core.callerSkip, o.core.callerLong)
}
if o.core.caller != nil {
return internal.GetCaller(o.core.caller.Skip()+o.caller.Skip()+o.core.callerSkip, o.core.callerLong)
}
return internal.GetCaller(o.caller.Skip()+o.core.callerSkip, o.core.callerLong)
}
// IsLevelEnabled checks whether the given log level is enabled.
// Always returns false if the given log level is invalid.
func (o *log) IsLevelEnabled(level Level) bool {
return Level(atomic.LoadUint32(&o.core.level)).IsEnabled(level)
}
// IsPanicLevelEnabled checks whether the PanicLevel is enabled.
func (o *log) IsPanicLevelEnabled() bool {
return o.IsLevelEnabled(PanicLevel)
}
// IsFatalLevelEnabled checks whether the FatalLevel is enabled.
func (o *log) IsFatalLevelEnabled() bool {
return o.IsLevelEnabled(FatalLevel)
}
// IsErrorLevelEnabled checks whether the ErrorLevel is enabled.
func (o *log) IsErrorLevelEnabled() bool {
return o.IsLevelEnabled(ErrorLevel)
}
// IsWarnLevelEnabled checks whether the WarnLevel is enabled.
func (o *log) IsWarnLevelEnabled() bool {
return o.IsLevelEnabled(WarnLevel)
}
// IsInfoLevelEnabled checks whether the InfoLevel is enabled.
func (o *log) IsInfoLevelEnabled() bool {
return o.IsLevelEnabled(InfoLevel)
}
// IsDebugLevelEnabled checks whether the DebugLevel is enabled.
func (o *log) IsDebugLevelEnabled() bool {
return o.IsLevelEnabled(DebugLevel)
}
// IsTraceLevelEnabled checks whether the TraceLevel is enabled.
func (o *log) IsTraceLevelEnabled() bool {
return o.IsLevelEnabled(TraceLevel)
}
// Log uses the given parameters to record a log of the specified level.
// If the given log level is PanicLevel, the given panic function will be
// called automatically after logging is completed.
// If the given log level is FatalLevel, the given exit function will be
// called automatically after logging is completed.
// If the given log level is invalid, the log will be discarded.
func (o *log) Log(level Level, args ...interface{}) {
o.log(level, args...)
}
// Uses the given parameters to record a log of the specified level.
func (o *log) log(level Level, args ...interface{}) {
if !Level(atomic.LoadUint32(&o.core.level)).IsEnabled(level) {
return
}
o.record(level, fmt.Sprint(args...))
}
// Logln uses the given parameters to record a log of the specified level.
// If the given log level is PanicLevel, the given panic function will be
// called automatically after logging is completed.
// If the given log level is FatalLevel, the given exit function will be
// called automatically after logging is completed.
// If the given log level is invalid, the log will be discarded.
func (o *log) Logln(level Level, args ...interface{}) {
o.logln(level, args...)
}
// Uses the given parameters to record a log of the specified level.
func (o *log) logln(level Level, args ...interface{}) {
if !Level(atomic.LoadUint32(&o.core.level)).IsEnabled(level) {
return
}
s := fmt.Sprintln(args...)
o.record(level, s[:len(s)-1])
}
// Logf uses the given parameters to record a log of the specified level.
// If the given log level is PanicLevel, the given panic function will be
// called automatically after logging is completed.
// If the given log level is FatalLevel, the given exit function will be
// called automatically after logging is completed.
// If the given log level is invalid, the log will be discarded.
func (o *log) Logf(level Level, format string, args ...interface{}) {
o.logf(level, format, args...)
}
// Uses the given parameters to record a log of the specified level.
func (o *log) logf(level Level, format string, args ...interface{}) {
if !Level(atomic.LoadUint32(&o.core.level)).IsEnabled(level) {
return
}
o.record(level, fmt.Sprintf(format, args...))
}
// Trace uses the given parameters to record a TraceLevel log.
func (o *log) Trace(args ...interface{}) {
o.log(TraceLevel, args...)
}
// Traceln uses the given parameters to record a TraceLevel log.
func (o *log) Traceln(args ...interface{}) {
o.logln(TraceLevel, args...)
}
// Tracef uses the given parameters to record a TraceLevel log.
func (o *log) Tracef(format string, args ...interface{}) {
o.logf(TraceLevel, format, args...)
}
// Print uses the given parameters to record a TraceLevel log.
func (o *log) Print(args ...interface{}) {
o.log(TraceLevel, args...)
}
// Println uses the given parameters to record a TraceLevel log.
func (o *log) Println(args ...interface{}) {
o.logln(TraceLevel, args...)
}
// Printf uses the given parameters to record a TraceLevel log.
func (o *log) Printf(format string, args ...interface{}) {
o.logf(TraceLevel, format, args...)
}
// Debug uses the given parameters to record a DebugLevel log.
func (o *log) Debug(args ...interface{}) {
o.log(DebugLevel, args...)
}
// Debugln uses the given parameters to record a DebugLevel log.
func (o *log) Debugln(args ...interface{}) {
o.logln(DebugLevel, args...)
}
// Debugf uses the given parameters to record a DebugLevel log.
func (o *log) Debugf(format string, args ...interface{}) {
o.logf(DebugLevel, format, args...)
}
// Info uses the given parameters to record a InfoLevel log.
func (o *log) Info(args ...interface{}) {
o.log(InfoLevel, args...)
}
// Infoln uses the given parameters to record a InfoLevel log.
func (o *log) Infoln(args ...interface{}) {
o.logln(InfoLevel, args...)
}
// Infof uses the given parameters to record a InfoLevel log.
func (o *log) Infof(format string, args ...interface{}) {
o.logf(InfoLevel, format, args...)
}
// Echo uses the given parameters to record a InfoLevel log.
func (o *log) Echo(args ...interface{}) {
o.log(InfoLevel, args...)
}
// Echoln uses the given parameters to record a InfoLevel log.
func (o *log) Echoln(args ...interface{}) {
o.logln(InfoLevel, args...)
}
// Echof uses the given parameters to record a InfoLevel log.
func (o *log) Echof(format string, args ...interface{}) {
o.logf(InfoLevel, format, args...)
}
// Warn uses the given parameters to record a WarnLevel log.
func (o *log) Warn(args ...interface{}) {
o.log(WarnLevel, args...)
}
// Warnln uses the given parameters to record a WarnLevel log.
func (o *log) Warnln(args ...interface{}) {
o.logln(WarnLevel, args...)
}
// Warnf uses the given parameters to record a WarnLevel log.
func (o *log) Warnf(format string, args ...interface{}) {
o.logf(WarnLevel, format, args...)
}
// Warning uses the given parameters to record a WarnLevel log.
func (o *log) Warning(args ...interface{}) {
o.log(WarnLevel, args...)
}
// Warningln uses the given parameters to record a WarnLevel log.
func (o *log) Warningln(args ...interface{}) {
o.logln(WarnLevel, args...)
}
// Warningf uses the given parameters to record a WarnLevel log.
func (o *log) Warningf(format string, args ...interface{}) {
o.logf(WarnLevel, format, args...)
}
// Error uses the given parameters to record a ErrorLevel log.
func (o *log) Error(args ...interface{}) {
o.log(ErrorLevel, args...)
}
// Errorln uses the given parameters to record a ErrorLevel log.
func (o *log) Errorln(args ...interface{}) {
o.logln(ErrorLevel, args...)
}
// Errorf uses the given parameters to record a ErrorLevel log.
func (o *log) Errorf(format string, args ...interface{}) {
o.logf(ErrorLevel, format, args...)
}
// Fatal uses the given parameters to record a FatalLevel log.
// After the log record is completed, the system will automatically call
// the exit function given in advance.
func (o *log) Fatal(args ...interface{}) {
o.log(FatalLevel, args...)
}
// Fatalln uses the given parameters to record a FatalLevel log.
// After the log record is completed, the system will automatically call
// the exit function given in advance.
func (o *log) Fatalln(args ...interface{}) {
o.logln(FatalLevel, args...)
}
// Fatalf uses the given parameters to record a FatalLevel log.
// After the log record is completed, the system will automatically call
// the exit function given in advance.
func (o *log) Fatalf(format string, args ...interface{}) {
o.logf(FatalLevel, format, args...)
}
// Panic uses the given parameters to record a PanicLevel log.
// After the log record is completed, the system will automatically call
// the panic function given in advance.
func (o *log) Panic(args ...interface{}) {
o.log(PanicLevel, args...)
}
// Panicln uses the given parameters to record a PanicLevel log.
// After the log record is completed, the system will automatically call
// the panic function given in advance.
func (o *log) Panicln(args ...interface{}) {
o.logln(PanicLevel, args...)
}
// Panicf uses the given parameters to record a PanicLevel log.
// After the log record is completed, the system will automatically call
// the panic function given in advance.
func (o *log) Panicf(format string, args ...interface{}) {
o.logf(PanicLevel, format, args...)
}