log.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. // Copyright 2014 beego Author. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package beego
  15. import (
  16. "strings"
  17. "github.com/astaxie/beego/logs"
  18. )
  19. // Log levels to control the logging output.
  20. // Deprecated: use github.com/astaxie/beego/logs instead.
  21. const (
  22. LevelEmergency = iota
  23. LevelAlert
  24. LevelCritical
  25. LevelError
  26. LevelWarning
  27. LevelNotice
  28. LevelInformational
  29. LevelDebug
  30. )
  31. // BeeLogger references the used application logger.
  32. // Deprecated: use github.com/astaxie/beego/logs instead.
  33. var BeeLogger = logs.GetBeeLogger()
  34. // SetLevel sets the global log level used by the simple logger.
  35. // Deprecated: use github.com/astaxie/beego/logs instead.
  36. func SetLevel(l int) {
  37. logs.SetLevel(l)
  38. }
  39. // SetLogFuncCall set the CallDepth, default is 3
  40. // Deprecated: use github.com/astaxie/beego/logs instead.
  41. func SetLogFuncCall(b bool) {
  42. logs.SetLogFuncCall(b)
  43. }
  44. // SetLogger sets a new logger.
  45. // Deprecated: use github.com/astaxie/beego/logs instead.
  46. func SetLogger(adaptername string, config string) error {
  47. return logs.SetLogger(adaptername, config)
  48. }
  49. // Emergency logs a message at emergency level.
  50. // Deprecated: use github.com/astaxie/beego/logs instead.
  51. func Emergency(v ...interface{}) {
  52. logs.Emergency(generateFmtStr(len(v)), v...)
  53. }
  54. // Alert logs a message at alert level.
  55. // Deprecated: use github.com/astaxie/beego/logs instead.
  56. func Alert(v ...interface{}) {
  57. logs.Alert(generateFmtStr(len(v)), v...)
  58. }
  59. // Critical logs a message at critical level.
  60. // Deprecated: use github.com/astaxie/beego/logs instead.
  61. func Critical(v ...interface{}) {
  62. logs.Critical(generateFmtStr(len(v)), v...)
  63. }
  64. // Error logs a message at error level.
  65. // Deprecated: use github.com/astaxie/beego/logs instead.
  66. func Error(v ...interface{}) {
  67. logs.Error(generateFmtStr(len(v)), v...)
  68. }
  69. // Warning logs a message at warning level.
  70. // Deprecated: use github.com/astaxie/beego/logs instead.
  71. func Warning(v ...interface{}) {
  72. logs.Warning(generateFmtStr(len(v)), v...)
  73. }
  74. // Warn compatibility alias for Warning()
  75. // Deprecated: use github.com/astaxie/beego/logs instead.
  76. func Warn(v ...interface{}) {
  77. logs.Warn(generateFmtStr(len(v)), v...)
  78. }
  79. // Notice logs a message at notice level.
  80. // Deprecated: use github.com/astaxie/beego/logs instead.
  81. func Notice(v ...interface{}) {
  82. logs.Notice(generateFmtStr(len(v)), v...)
  83. }
  84. // Informational logs a message at info level.
  85. // Deprecated: use github.com/astaxie/beego/logs instead.
  86. func Informational(v ...interface{}) {
  87. logs.Informational(generateFmtStr(len(v)), v...)
  88. }
  89. // Info compatibility alias for Warning()
  90. // Deprecated: use github.com/astaxie/beego/logs instead.
  91. func Info(v ...interface{}) {
  92. logs.Info(generateFmtStr(len(v)), v...)
  93. }
  94. // Debug logs a message at debug level.
  95. // Deprecated: use github.com/astaxie/beego/logs instead.
  96. func Debug(v ...interface{}) {
  97. logs.Debug(generateFmtStr(len(v)), v...)
  98. }
  99. // Trace logs a message at trace level.
  100. // compatibility alias for Warning()
  101. // Deprecated: use github.com/astaxie/beego/logs instead.
  102. func Trace(v ...interface{}) {
  103. logs.Trace(generateFmtStr(len(v)), v...)
  104. }
  105. func generateFmtStr(n int) string {
  106. return strings.Repeat("%v ", n)
  107. }