gf/os/glog/glog_chaining.go

107 lines
3.1 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 (
2020-05-08 17:12:37 +08:00
"context"
2019-05-21 23:57:03 +08:00
"io"
)
// Expose returns the default logger of package glog.
func Expose() *Logger {
return logger
}
2020-05-08 17:12:37 +08:00
// Ctx is a chaining function,
// which sets the context for current logging.
// The parameter <keys> specifies the context keys for retrieving values.
func Ctx(ctx context.Context, keys ...interface{}) *Logger {
return logger.Ctx(ctx, keys...)
}
2019-06-19 09:06:52 +08:00
// To is a chaining function,
2019-05-21 23:57:03 +08:00
// which redirects current logging content output to the sepecified <writer>.
func To(writer io.Writer) *Logger {
2019-06-19 09:06:52 +08:00
return logger.To(writer)
2019-05-21 23:57:03 +08:00
}
// Path is a chaining function,
// which sets the directory path to <path> for current logging content output.
func Path(path string) *Logger {
2019-06-19 09:06:52 +08:00
return logger.Path(path)
2019-05-21 23:57:03 +08:00
}
2019-06-19 09:06:52 +08:00
// Cat is a chaining function,
2019-05-21 23:57:03 +08:00
// which sets the category to <category> for current logging content output.
func Cat(category string) *Logger {
2019-06-19 09:06:52 +08:00
return logger.Cat(category)
2019-05-21 23:57:03 +08:00
}
2019-06-19 09:06:52 +08:00
// File is a chaining function,
2019-05-21 23:57:03 +08:00
// which sets file name <pattern> for the current logging content output.
func File(pattern string) *Logger {
2019-06-19 09:06:52 +08:00
return logger.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 {
2019-06-19 09:06:52 +08:00
return logger.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 logger.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 logger.Skip(skip)
}
// Stack is a chaining function,
// which sets stack options for the current logging content output .
func Stack(enabled bool, skip ...int) *Logger {
return logger.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 logger.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 logger.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 logger.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.
2019-06-11 20:57:43 +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 {
2019-05-21 23:57:03 +08:00
return logger.Line(long...)
}
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 {
2019-06-01 19:34:03 +08:00
return logger.Async(enabled...)
}