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.
 
 
 

87 lines
2.1 KiB

  1. /*
  2. *
  3. * Copyright 2015 gRPC authors.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. // Package glogger defines glog-based logging for grpc.
  19. // Importing this package will install glog as the logger used by grpclog.
  20. package glogger
  21. import (
  22. "fmt"
  23. "github.com/golang/glog"
  24. "google.golang.org/grpc/grpclog"
  25. )
  26. func init() {
  27. grpclog.SetLoggerV2(&glogger{})
  28. }
  29. type glogger struct{}
  30. func (g *glogger) Info(args ...interface{}) {
  31. glog.InfoDepth(2, args...)
  32. }
  33. func (g *glogger) Infoln(args ...interface{}) {
  34. glog.InfoDepth(2, fmt.Sprintln(args...))
  35. }
  36. func (g *glogger) Infof(format string, args ...interface{}) {
  37. glog.InfoDepth(2, fmt.Sprintf(format, args...))
  38. }
  39. func (g *glogger) Warning(args ...interface{}) {
  40. glog.WarningDepth(2, args...)
  41. }
  42. func (g *glogger) Warningln(args ...interface{}) {
  43. glog.WarningDepth(2, fmt.Sprintln(args...))
  44. }
  45. func (g *glogger) Warningf(format string, args ...interface{}) {
  46. glog.WarningDepth(2, fmt.Sprintf(format, args...))
  47. }
  48. func (g *glogger) Error(args ...interface{}) {
  49. glog.ErrorDepth(2, args...)
  50. }
  51. func (g *glogger) Errorln(args ...interface{}) {
  52. glog.ErrorDepth(2, fmt.Sprintln(args...))
  53. }
  54. func (g *glogger) Errorf(format string, args ...interface{}) {
  55. glog.ErrorDepth(2, fmt.Sprintf(format, args...))
  56. }
  57. func (g *glogger) Fatal(args ...interface{}) {
  58. glog.FatalDepth(2, args...)
  59. }
  60. func (g *glogger) Fatalln(args ...interface{}) {
  61. glog.FatalDepth(2, fmt.Sprintln(args...))
  62. }
  63. func (g *glogger) Fatalf(format string, args ...interface{}) {
  64. glog.FatalDepth(2, fmt.Sprintf(format, args...))
  65. }
  66. func (g *glogger) V(l int) bool {
  67. return bool(glog.V(glog.Level(l)))
  68. }