grpclog.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. *
  3. * Copyright 2017, Google Inc.
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are
  8. * met:
  9. *
  10. * * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * * Redistributions in binary form must reproduce the above
  13. * copyright notice, this list of conditions and the following disclaimer
  14. * in the documentation and/or other materials provided with the
  15. * distribution.
  16. * * Neither the name of Google Inc. nor the names of its
  17. * contributors may be used to endorse or promote products derived from
  18. * this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. */
  33. // Package grpclog defines logging for grpc.
  34. //
  35. // All logs in transport package only go to verbose level 2.
  36. // All logs in other packages in grpc are logged in spite of the verbosity level.
  37. //
  38. // In the default logger,
  39. // severity level can be set by environment variable GRPC_GO_LOG_SEVERITY_LEVEL,
  40. // verbosity level can be set by GRPC_GO_LOG_VERBOSITY_LEVEL.
  41. package grpclog // import "google.golang.org/grpc/grpclog"
  42. import "os"
  43. var logger = newLoggerV2()
  44. // V reports whether verbosity level l is at least the requested verbose level.
  45. func V(l int) bool {
  46. return logger.V(l)
  47. }
  48. // Info logs to the INFO log.
  49. func Info(args ...interface{}) {
  50. logger.Info(args...)
  51. }
  52. // Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf.
  53. func Infof(format string, args ...interface{}) {
  54. logger.Infof(format, args...)
  55. }
  56. // Infoln logs to the INFO log. Arguments are handled in the manner of fmt.Println.
  57. func Infoln(args ...interface{}) {
  58. logger.Infoln(args...)
  59. }
  60. // Warning logs to the WARNING log.
  61. func Warning(args ...interface{}) {
  62. logger.Warning(args...)
  63. }
  64. // Warningf logs to the WARNING log. Arguments are handled in the manner of fmt.Printf.
  65. func Warningf(format string, args ...interface{}) {
  66. logger.Warningf(format, args...)
  67. }
  68. // Warningln logs to the WARNING log. Arguments are handled in the manner of fmt.Println.
  69. func Warningln(args ...interface{}) {
  70. logger.Warningln(args...)
  71. }
  72. // Error logs to the ERROR log.
  73. func Error(args ...interface{}) {
  74. logger.Error(args...)
  75. }
  76. // Errorf logs to the ERROR log. Arguments are handled in the manner of fmt.Printf.
  77. func Errorf(format string, args ...interface{}) {
  78. logger.Errorf(format, args...)
  79. }
  80. // Errorln logs to the ERROR log. Arguments are handled in the manner of fmt.Println.
  81. func Errorln(args ...interface{}) {
  82. logger.Errorln(args...)
  83. }
  84. // Fatal logs to the FATAL log. Arguments are handled in the manner of fmt.Print.
  85. // It calls os.Exit() with exit code 1.
  86. func Fatal(args ...interface{}) {
  87. logger.Fatal(args...)
  88. os.Exit(1)
  89. }
  90. // Fatalf logs to the FATAL log. Arguments are handled in the manner of fmt.Printf.
  91. // It calles os.Exit() with exit code 1.
  92. func Fatalf(format string, args ...interface{}) {
  93. logger.Fatalf(format, args...)
  94. os.Exit(1)
  95. }
  96. // Fatalln logs to the FATAL log. Arguments are handled in the manner of fmt.Println.
  97. // It calle os.Exit()) with exit code 1.
  98. func Fatalln(args ...interface{}) {
  99. logger.Fatalln(args...)
  100. os.Exit(1)
  101. }
  102. // Print prints to the logger. Arguments are handled in the manner of fmt.Print.
  103. // Deprecated: use Info.
  104. func Print(args ...interface{}) {
  105. logger.Info(args...)
  106. }
  107. // Printf prints to the logger. Arguments are handled in the manner of fmt.Printf.
  108. // Deprecated: use Infof.
  109. func Printf(format string, args ...interface{}) {
  110. logger.Infof(format, args...)
  111. }
  112. // Println prints to the logger. Arguments are handled in the manner of fmt.Println.
  113. // Deprecated: use Infoln.
  114. func Println(args ...interface{}) {
  115. logger.Infoln(args...)
  116. }