github.com/gogf/gf@v1.16.9/os/glog/glog_chaining.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/gogf/gf. 6 7 package glog 8 9 import ( 10 "context" 11 "io" 12 ) 13 14 // Expose returns the default logger of package glog. 15 func Expose() *Logger { 16 return logger 17 } 18 19 // Ctx is a chaining function, 20 // which sets the context for current logging. 21 // The parameter `keys` specifies the context keys for retrieving values. 22 func Ctx(ctx context.Context, keys ...interface{}) *Logger { 23 return logger.Ctx(ctx, keys...) 24 } 25 26 // To is a chaining function, 27 // which redirects current logging content output to the sepecified `writer`. 28 func To(writer io.Writer) *Logger { 29 return logger.To(writer) 30 } 31 32 // Path is a chaining function, 33 // which sets the directory path to `path` for current logging content output. 34 func Path(path string) *Logger { 35 return logger.Path(path) 36 } 37 38 // Cat is a chaining function, 39 // which sets the category to `category` for current logging content output. 40 func Cat(category string) *Logger { 41 return logger.Cat(category) 42 } 43 44 // File is a chaining function, 45 // which sets file name `pattern` for the current logging content output. 46 func File(pattern string) *Logger { 47 return logger.File(pattern) 48 } 49 50 // Level is a chaining function, 51 // which sets logging level for the current logging content output. 52 func Level(level int) *Logger { 53 return logger.Level(level) 54 } 55 56 // LevelStr is a chaining function, 57 // which sets logging level for the current logging content output using level string. 58 func LevelStr(levelStr string) *Logger { 59 return logger.LevelStr(levelStr) 60 } 61 62 // Skip is a chaining function, 63 // which sets stack skip for the current logging content output. 64 // It also affects the caller file path checks when line number printing enabled. 65 func Skip(skip int) *Logger { 66 return logger.Skip(skip) 67 } 68 69 // Stack is a chaining function, 70 // which sets stack options for the current logging content output . 71 func Stack(enabled bool, skip ...int) *Logger { 72 return logger.Stack(enabled, skip...) 73 } 74 75 // StackWithFilter is a chaining function, 76 // which sets stack filter for the current logging content output . 77 func StackWithFilter(filter string) *Logger { 78 return logger.StackWithFilter(filter) 79 } 80 81 // Stdout is a chaining function, 82 // which enables/disables stdout for the current logging content output. 83 // It's enabled in default. 84 func Stdout(enabled ...bool) *Logger { 85 return logger.Stdout(enabled...) 86 } 87 88 // Header is a chaining function, 89 // which enables/disables log header for the current logging content output. 90 // It's enabled in default. 91 func Header(enabled ...bool) *Logger { 92 return logger.Header(enabled...) 93 } 94 95 // Line is a chaining function, 96 // which enables/disables printing its caller file along with its line number. 97 // The parameter `long` specified whether print the long absolute file path, eg: /a/b/c/d.go:23. 98 func Line(long ...bool) *Logger { 99 return logger.Line(long...) 100 } 101 102 // Async is a chaining function, 103 // which enables/disables async logging output feature. 104 func Async(enabled ...bool) *Logger { 105 return logger.Async(enabled...) 106 }