You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
2.5 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. // Package zlog 主要提供zinx相关日志记录接口
  2. // 包括:
  3. // stdzlog模块, 提供全局日志方法
  4. // zlogger模块, 日志内部定义协议,均为对象类方法
  5. //
  6. // 当前文件描述:
  7. // @Title stdzlog.go
  8. // @Description 包裹zlogger日志方法,提供全局方法
  9. // @Author Aceld - Thu Mar 11 10:32:29 CST 2019
  10. package zlog
  11. /*
  12. 全局默认提供一个Log对外句柄可以直接使用API系列调用
  13. 全局日志对象 StdZinxLog
  14. */
  15. import "os"
  16. //StdZinxLog 创建全局log
  17. var StdZinxLog = NewZinxLog(os.Stderr, "", BitDefault)
  18. //Flags 获取StdZinxLog 标记位
  19. func Flags() int {
  20. return StdZinxLog.Flags()
  21. }
  22. //ResetFlags 设置StdZinxLog标记位
  23. func ResetFlags(flag int) {
  24. StdZinxLog.ResetFlags(flag)
  25. }
  26. //AddFlag 添加flag标记
  27. func AddFlag(flag int) {
  28. StdZinxLog.AddFlag(flag)
  29. }
  30. //SetPrefix 设置StdZinxLog 日志头前缀
  31. func SetPrefix(prefix string) {
  32. StdZinxLog.SetPrefix(prefix)
  33. }
  34. //SetLogFile 设置StdZinxLog绑定的日志文件
  35. func SetLogFile(fileDir string, fileName string) {
  36. StdZinxLog.SetLogFile(fileDir, fileName)
  37. }
  38. //CloseDebug 设置关闭debug
  39. func CloseDebug() {
  40. StdZinxLog.CloseDebug()
  41. }
  42. //OpenDebug 设置打开debug
  43. func OpenDebug() {
  44. StdZinxLog.OpenDebug()
  45. }
  46. //Debugf ====> Debug <====
  47. func Debugf(format string, v ...interface{}) {
  48. StdZinxLog.Debugf(format, v...)
  49. }
  50. //Debug Debug
  51. func Debug(v ...interface{}) {
  52. StdZinxLog.Debug(v...)
  53. }
  54. //Infof ====> Info <====
  55. func Infof(format string, v ...interface{}) {
  56. StdZinxLog.Infof(format, v...)
  57. }
  58. //Info -
  59. func Info(v ...interface{}) {
  60. StdZinxLog.Info(v...)
  61. }
  62. // ====> Warn <====
  63. func Warnf(format string, v ...interface{}) {
  64. StdZinxLog.Warnf(format, v...)
  65. }
  66. func Warn(v ...interface{}) {
  67. StdZinxLog.Warn(v...)
  68. }
  69. // ====> Error <====
  70. func Errorf(format string, v ...interface{}) {
  71. StdZinxLog.Errorf(format, v...)
  72. }
  73. func Error(v ...interface{}) {
  74. StdZinxLog.Error(v...)
  75. }
  76. // ====> Fatal 需要终止程序 <====
  77. func Fatalf(format string, v ...interface{}) {
  78. StdZinxLog.Fatalf(format, v...)
  79. }
  80. func Fatal(v ...interface{}) {
  81. StdZinxLog.Fatal(v...)
  82. }
  83. // ====> Panic <====
  84. func Panicf(format string, v ...interface{}) {
  85. StdZinxLog.Panicf(format, v...)
  86. }
  87. func Panic(v ...interface{}) {
  88. StdZinxLog.Panic(v...)
  89. }
  90. // ====> Stack <====
  91. func Stack(v ...interface{}) {
  92. StdZinxLog.Stack(v...)
  93. }
  94. func init() {
  95. //因为StdZinxLog对象 对所有输出方法做了一层包裹,所以在打印调用函数的时候,比正常的logger对象多一层调用
  96. //一般的zinxLogger对象 calldDepth=2, StdZinxLog的calldDepth=3
  97. StdZinxLog.calldDepth = 3
  98. }