gf/os/glog/glog_chaining.go

99 lines
3.0 KiB
Go
Raw Normal View History

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"
)
// Expose returns the default logger of package glog.
func Expose() *Logger {
return defaultLogger
}
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 {
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 {
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 {
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 {
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 {
return defaultLogger.Level(level)
2019-05-21 23:57:03 +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 {
return defaultLogger.LevelStr(levelStr)
}
2019-05-23 19:14:16 +08:00
// Skip is a chaining function,
// 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 {
return defaultLogger.Skip(skip)
2019-05-23 19:14:16 +08:00
}
// Stack is a chaining function,
// which sets stack options for the current logging content output .
func Stack(enabled bool, skip ...int) *Logger {
return defaultLogger.Stack(enabled, skip...)
2019-05-21 23:57:03 +08:00
}
// StackWithFilter is a chaining function,
// which sets stack filter for the current logging content output .
func StackWithFilter(filter string) *Logger {
return defaultLogger.StackWithFilter(filter)
}
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.
// It's enabled in default.
2019-06-19 09:06:52 +08:00
func Stdout(enabled ...bool) *Logger {
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.
// It's enabled in default.
2019-06-19 09:06:52 +08:00
func Header(enabled ...bool) *Logger {
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 {
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 {
return defaultLogger.Async(enabled...)
2019-06-01 19:34:03 +08:00
}