logger.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright 2020-2021 InfluxData, Inc. All rights reserved.
  2. // Use of this source code is governed by MIT
  3. // license that can be found in the LICENSE file.
  4. // Package log provides internal logging infrastructure
  5. package log
  6. import (
  7. ilog "github.com/influxdata/influxdb-client-go/v2/log"
  8. )
  9. // Debugf writes formatted debug message to the Logger instance
  10. func Debugf(format string, v ...interface{}) {
  11. if ilog.Log != nil {
  12. ilog.Log.Debugf(format, v...)
  13. }
  14. }
  15. // Debug writes debug message message to the Logger instance
  16. func Debug(msg string) {
  17. if ilog.Log != nil {
  18. ilog.Log.Debug(msg)
  19. }
  20. }
  21. // Infof writes formatted info message to the Logger instance
  22. func Infof(format string, v ...interface{}) {
  23. if ilog.Log != nil {
  24. ilog.Log.Infof(format, v...)
  25. }
  26. }
  27. // Info writes info message message to the Logger instance
  28. func Info(msg string) {
  29. if ilog.Log != nil {
  30. ilog.Log.Info(msg)
  31. }
  32. }
  33. // Warnf writes formatted warning message to the Logger instance
  34. func Warnf(format string, v ...interface{}) {
  35. if ilog.Log != nil {
  36. ilog.Log.Warnf(format, v...)
  37. }
  38. }
  39. // Warn writes warning message message to the Logger instance
  40. func Warn(msg string) {
  41. if ilog.Log != nil {
  42. ilog.Log.Warn(msg)
  43. }
  44. }
  45. // Errorf writes formatted error message to the Logger instance
  46. func Errorf(format string, v ...interface{}) {
  47. if ilog.Log != nil {
  48. ilog.Log.Errorf(format, v...)
  49. }
  50. }
  51. // Error writes error message message to the Logger instance
  52. func Error(msg string) {
  53. if ilog.Log != nil {
  54. ilog.Log.Error(msg)
  55. }
  56. }
  57. // Level retrieves current logging level form the Logger instance
  58. func Level() uint {
  59. if ilog.Log != nil {
  60. return ilog.Log.LogLevel()
  61. }
  62. return ilog.ErrorLevel
  63. }