2021-01-17 21:46:25 +08:00
|
|
|
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
2019-05-21 23:57:03 +08:00
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
|
|
// If a copy of the MIT was not distributed with this file,
|
|
|
|
// You can obtain one at https://github.com/gogf/gf.
|
|
|
|
|
|
|
|
package glog
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
)
|
|
|
|
|
2021-08-08 13:10:21 +08:00
|
|
|
// Expose returns the default logger of package glog.
|
2019-06-13 19:29:09 +08:00
|
|
|
func Expose() *Logger {
|
2021-12-23 00:09:00 +08:00
|
|
|
return defaultLogger
|
2019-06-13 19:29:09 +08:00
|
|
|
}
|
|
|
|
|
2019-06-19 09:06:52 +08:00
|
|
|
// To is a chaining function,
|
2021-08-08 13:56:26 +08:00
|
|
|
// which redirects current logging content output to the sepecified `writer`.
|
2019-05-21 23:57:03 +08:00
|
|
|
func To(writer io.Writer) *Logger {
|
2021-12-23 00:09:00 +08:00
|
|
|
return defaultLogger.To(writer)
|
2019-05-21 23:57:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Path is a chaining function,
|
2021-08-08 13:56:26 +08:00
|
|
|
// which sets the directory path to `path` for current logging content output.
|
2019-05-21 23:57:03 +08:00
|
|
|
func Path(path string) *Logger {
|
2021-12-23 00:09:00 +08:00
|
|
|
return defaultLogger.Path(path)
|
2019-05-21 23:57:03 +08:00
|
|
|
}
|
|
|
|
|
2019-06-19 09:06:52 +08:00
|
|
|
// Cat is a chaining function,
|
2021-08-08 13:56:26 +08:00
|
|
|
// which sets the category to `category` for current logging content output.
|
2019-05-21 23:57:03 +08:00
|
|
|
func Cat(category string) *Logger {
|
2021-12-23 00:09:00 +08:00
|
|
|
return defaultLogger.Cat(category)
|
2019-05-21 23:57:03 +08:00
|
|
|
}
|
|
|
|
|
2019-06-19 09:06:52 +08:00
|
|
|
// File is a chaining function,
|
2021-08-08 13:56:26 +08:00
|
|
|
// which sets file name `pattern` for the current logging content output.
|
2019-05-21 23:57:03 +08:00
|
|
|
func File(pattern string) *Logger {
|
2021-12-23 00:09:00 +08:00
|
|
|
return defaultLogger.File(pattern)
|
2019-05-21 23:57:03 +08:00
|
|
|
}
|
|
|
|
|
2019-06-19 09:06:52 +08:00
|
|
|
// Level is a chaining function,
|
2019-05-21 23:57:03 +08:00
|
|
|
// which sets logging level for the current logging content output.
|
|
|
|
func Level(level int) *Logger {
|
2021-12-23 00:09:00 +08:00
|
|
|
return defaultLogger.Level(level)
|
2019-05-21 23:57:03 +08:00
|
|
|
}
|
|
|
|
|
2020-03-24 00:05:11 +08:00
|
|
|
// LevelStr is a chaining function,
|
|
|
|
// which sets logging level for the current logging content output using level string.
|
|
|
|
func LevelStr(levelStr string) *Logger {
|
2021-12-23 00:09:00 +08:00
|
|
|
return defaultLogger.LevelStr(levelStr)
|
2020-03-24 00:05:11 +08:00
|
|
|
}
|
|
|
|
|
2019-05-23 19:14:16 +08:00
|
|
|
// Skip is a chaining function,
|
2019-06-29 10:45:50 +08:00
|
|
|
// which sets stack skip for the current logging content output.
|
2019-05-23 19:14:16 +08:00
|
|
|
// It also affects the caller file path checks when line number printing enabled.
|
|
|
|
func Skip(skip int) *Logger {
|
2021-12-23 00:09:00 +08:00
|
|
|
return defaultLogger.Skip(skip)
|
2019-05-23 19:14:16 +08:00
|
|
|
}
|
|
|
|
|
2019-06-29 10:45:50 +08:00
|
|
|
// Stack is a chaining function,
|
|
|
|
// which sets stack options for the current logging content output .
|
|
|
|
func Stack(enabled bool, skip ...int) *Logger {
|
2021-12-23 00:09:00 +08:00
|
|
|
return defaultLogger.Stack(enabled, skip...)
|
2019-05-21 23:57:03 +08:00
|
|
|
}
|
|
|
|
|
2019-08-26 20:09:24 +08:00
|
|
|
// StackWithFilter is a chaining function,
|
|
|
|
// which sets stack filter for the current logging content output .
|
|
|
|
func StackWithFilter(filter string) *Logger {
|
2021-12-23 00:09:00 +08:00
|
|
|
return defaultLogger.StackWithFilter(filter)
|
2019-08-26 20:09:24 +08:00
|
|
|
}
|
|
|
|
|
2021-07-15 13:31:32 +08:00
|
|
|
// Stdout is a chaining function,
|
2019-05-21 23:57:03 +08:00
|
|
|
// which enables/disables stdout for the current logging content output.
|
2019-05-22 21:43:56 +08:00
|
|
|
// It's enabled in default.
|
2019-06-19 09:06:52 +08:00
|
|
|
func Stdout(enabled ...bool) *Logger {
|
2021-12-23 00:09:00 +08:00
|
|
|
return defaultLogger.Stdout(enabled...)
|
2019-05-21 23:57:03 +08:00
|
|
|
}
|
|
|
|
|
2019-06-19 09:06:52 +08:00
|
|
|
// Header is a chaining function,
|
2019-05-21 23:57:03 +08:00
|
|
|
// which enables/disables log header for the current logging content output.
|
2019-05-22 21:43:56 +08:00
|
|
|
// It's enabled in default.
|
2019-06-19 09:06:52 +08:00
|
|
|
func Header(enabled ...bool) *Logger {
|
2021-12-23 00:09:00 +08:00
|
|
|
return defaultLogger.Header(enabled...)
|
2019-05-21 23:57:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Line is a chaining function,
|
|
|
|
// which enables/disables printing its caller file along with its line number.
|
2021-08-08 13:56:26 +08:00
|
|
|
// The parameter `long` specified whether print the long absolute file path, eg: /a/b/c/d.go:23.
|
2019-06-19 09:06:52 +08:00
|
|
|
func Line(long ...bool) *Logger {
|
2021-12-23 00:09:00 +08:00
|
|
|
return defaultLogger.Line(long...)
|
2019-05-21 23:57:03 +08:00
|
|
|
}
|
2019-06-01 19:34:03 +08:00
|
|
|
|
|
|
|
// Async is a chaining function,
|
|
|
|
// which enables/disables async logging output feature.
|
2019-06-19 09:06:52 +08:00
|
|
|
func Async(enabled ...bool) *Logger {
|
2021-12-23 00:09:00 +08:00
|
|
|
return defaultLogger.Async(enabled...)
|
2019-06-01 19:34:03 +08:00
|
|
|
}
|