glog_chaining.go 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. package glog
  7. import (
  8. "io"
  9. )
  10. // Expose returns the default logger of package glog.
  11. func Expose() *Logger {
  12. return defaultLogger
  13. }
  14. // To is a chaining function,
  15. // which redirects current logging content output to the sepecified `writer`.
  16. func To(writer io.Writer) *Logger {
  17. return defaultLogger.To(writer)
  18. }
  19. // Path is a chaining function,
  20. // which sets the directory path to `path` for current logging content output.
  21. func Path(path string) *Logger {
  22. return defaultLogger.Path(path)
  23. }
  24. // Cat is a chaining function,
  25. // which sets the category to `category` for current logging content output.
  26. func Cat(category string) *Logger {
  27. return defaultLogger.Cat(category)
  28. }
  29. // File is a chaining function,
  30. // which sets file name `pattern` for the current logging content output.
  31. func File(pattern string) *Logger {
  32. return defaultLogger.File(pattern)
  33. }
  34. // Level is a chaining function,
  35. // which sets logging level for the current logging content output.
  36. func Level(level int) *Logger {
  37. return defaultLogger.Level(level)
  38. }
  39. // LevelStr is a chaining function,
  40. // which sets logging level for the current logging content output using level string.
  41. func LevelStr(levelStr string) *Logger {
  42. return defaultLogger.LevelStr(levelStr)
  43. }
  44. // Skip is a chaining function,
  45. // which sets stack skip for the current logging content output.
  46. // It also affects the caller file path checks when line number printing enabled.
  47. func Skip(skip int) *Logger {
  48. return defaultLogger.Skip(skip)
  49. }
  50. // Stack is a chaining function,
  51. // which sets stack options for the current logging content output .
  52. func Stack(enabled bool, skip ...int) *Logger {
  53. return defaultLogger.Stack(enabled, skip...)
  54. }
  55. // StackWithFilter is a chaining function,
  56. // which sets stack filter for the current logging content output .
  57. func StackWithFilter(filter string) *Logger {
  58. return defaultLogger.StackWithFilter(filter)
  59. }
  60. // Stdout is a chaining function,
  61. // which enables/disables stdout for the current logging content output.
  62. // It's enabled in default.
  63. func Stdout(enabled ...bool) *Logger {
  64. return defaultLogger.Stdout(enabled...)
  65. }
  66. // Header is a chaining function,
  67. // which enables/disables log header for the current logging content output.
  68. // It's enabled in default.
  69. func Header(enabled ...bool) *Logger {
  70. return defaultLogger.Header(enabled...)
  71. }
  72. // Line is a chaining function,
  73. // which enables/disables printing its caller file along with its line number.
  74. // The parameter `long` specified whether print the long absolute file path, eg: /a/b/c/d.go:23.
  75. func Line(long ...bool) *Logger {
  76. return defaultLogger.Line(long...)
  77. }
  78. // Async is a chaining function,
  79. // which enables/disables async logging output feature.
  80. func Async(enabled ...bool) *Logger {
  81. return defaultLogger.Async(enabled...)
  82. }