|
|
@ -18,13 +18,12 @@ const callerDepth = 4
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
var (
|
|
|
|
timeFormat = "2006-01-02T15:04:05.000Z07:00"
|
|
|
|
timeFormat = "2006-01-02T15:04:05.000Z07:00"
|
|
|
|
logLevel uint32
|
|
|
|
|
|
|
|
encoding uint32 = jsonEncodingType
|
|
|
|
encoding uint32 = jsonEncodingType
|
|
|
|
// maxContentLength is used to truncate the log content, 0 for not truncating.
|
|
|
|
// maxContentLength is used to truncate the log content, 0 for not truncating.
|
|
|
|
maxContentLength uint32
|
|
|
|
maxContentLength uint32
|
|
|
|
// use uint32 for atomic operations
|
|
|
|
// use uint32 for atomic operations
|
|
|
|
disableLog uint32
|
|
|
|
|
|
|
|
disableStat uint32
|
|
|
|
disableStat uint32
|
|
|
|
|
|
|
|
logLevel uint32
|
|
|
|
options logOptions
|
|
|
|
options logOptions
|
|
|
|
writer = new(atomicWriter)
|
|
|
|
writer = new(atomicWriter)
|
|
|
|
setupOnce sync.Once
|
|
|
|
setupOnce sync.Once
|
|
|
@ -96,7 +95,7 @@ func Debugw(msg string, fields ...LogField) {
|
|
|
|
|
|
|
|
|
|
|
|
// Disable disables the logging.
|
|
|
|
// Disable disables the logging.
|
|
|
|
func Disable() {
|
|
|
|
func Disable() {
|
|
|
|
atomic.StoreUint32(&disableLog, 1)
|
|
|
|
atomic.StoreUint32(&logLevel, disableLevel)
|
|
|
|
writer.Store(nopWriter{})
|
|
|
|
writer.Store(nopWriter{})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -250,7 +249,7 @@ func SetLevel(level uint32) {
|
|
|
|
|
|
|
|
|
|
|
|
// SetWriter sets the logging writer. It can be used to customize the logging.
|
|
|
|
// SetWriter sets the logging writer. It can be used to customize the logging.
|
|
|
|
func SetWriter(w Writer) {
|
|
|
|
func SetWriter(w Writer) {
|
|
|
|
if atomic.LoadUint32(&disableLog) == 0 {
|
|
|
|
if atomic.LoadUint32(&logLevel) != disableLevel {
|
|
|
|
writer.Store(w)
|
|
|
|
writer.Store(w)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|