github.com/astaxie/beego@v1.12.3/log.go (about) 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 15 package beego 16 17 import ( 18 "strings" 19 20 "github.com/astaxie/beego/logs" 21 ) 22 23 // Log levels to control the logging output. 24 // Deprecated: use github.com/astaxie/beego/logs instead. 25 const ( 26 LevelEmergency = iota 27 LevelAlert 28 LevelCritical 29 LevelError 30 LevelWarning 31 LevelNotice 32 LevelInformational 33 LevelDebug 34 ) 35 36 // BeeLogger references the used application logger. 37 // Deprecated: use github.com/astaxie/beego/logs instead. 38 var BeeLogger = logs.GetBeeLogger() 39 40 // SetLevel sets the global log level used by the simple logger. 41 // Deprecated: use github.com/astaxie/beego/logs instead. 42 func SetLevel(l int) { 43 logs.SetLevel(l) 44 } 45 46 // SetLogFuncCall set the CallDepth, default is 3 47 // Deprecated: use github.com/astaxie/beego/logs instead. 48 func SetLogFuncCall(b bool) { 49 logs.SetLogFuncCall(b) 50 } 51 52 // SetLogger sets a new logger. 53 // Deprecated: use github.com/astaxie/beego/logs instead. 54 func SetLogger(adaptername string, config string) error { 55 return logs.SetLogger(adaptername, config) 56 } 57 58 // Emergency logs a message at emergency level. 59 // Deprecated: use github.com/astaxie/beego/logs instead. 60 func Emergency(v ...interface{}) { 61 logs.Emergency(generateFmtStr(len(v)), v...) 62 } 63 64 // Alert logs a message at alert level. 65 // Deprecated: use github.com/astaxie/beego/logs instead. 66 func Alert(v ...interface{}) { 67 logs.Alert(generateFmtStr(len(v)), v...) 68 } 69 70 // Critical logs a message at critical level. 71 // Deprecated: use github.com/astaxie/beego/logs instead. 72 func Critical(v ...interface{}) { 73 logs.Critical(generateFmtStr(len(v)), v...) 74 } 75 76 // Error logs a message at error level. 77 // Deprecated: use github.com/astaxie/beego/logs instead. 78 func Error(v ...interface{}) { 79 logs.Error(generateFmtStr(len(v)), v...) 80 } 81 82 // Warning logs a message at warning level. 83 // Deprecated: use github.com/astaxie/beego/logs instead. 84 func Warning(v ...interface{}) { 85 logs.Warning(generateFmtStr(len(v)), v...) 86 } 87 88 // Warn compatibility alias for Warning() 89 // Deprecated: use github.com/astaxie/beego/logs instead. 90 func Warn(v ...interface{}) { 91 logs.Warn(generateFmtStr(len(v)), v...) 92 } 93 94 // Notice logs a message at notice level. 95 // Deprecated: use github.com/astaxie/beego/logs instead. 96 func Notice(v ...interface{}) { 97 logs.Notice(generateFmtStr(len(v)), v...) 98 } 99 100 // Informational logs a message at info level. 101 // Deprecated: use github.com/astaxie/beego/logs instead. 102 func Informational(v ...interface{}) { 103 logs.Informational(generateFmtStr(len(v)), v...) 104 } 105 106 // Info compatibility alias for Warning() 107 // Deprecated: use github.com/astaxie/beego/logs instead. 108 func Info(v ...interface{}) { 109 logs.Info(generateFmtStr(len(v)), v...) 110 } 111 112 // Debug logs a message at debug level. 113 // Deprecated: use github.com/astaxie/beego/logs instead. 114 func Debug(v ...interface{}) { 115 logs.Debug(generateFmtStr(len(v)), v...) 116 } 117 118 // Trace logs a message at trace level. 119 // compatibility alias for Warning() 120 // Deprecated: use github.com/astaxie/beego/logs instead. 121 func Trace(v ...interface{}) { 122 logs.Trace(generateFmtStr(len(v)), v...) 123 } 124 125 func generateFmtStr(n int) string { 126 return strings.Repeat("%v ", n) 127 }