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.

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