/usr/share/gocode/src/go.pedge.io/lion/thrift/thriftlion_nongen.go is in golang-go.pedge-lion-dev 0.0~git20171203.2a81062-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | /*
Package thriftlion defines the Thrift functionality for lion.
*/
package thriftlion // import "go.pedge.io/lion/thrift"
import (
"io"
"sync"
"git.apache.org/thrift.git/lib/go/thrift"
"go.pedge.io/lion"
)
var (
// Encoding is the name of the encoding.
Encoding = "thrift-binary"
globalLogger Logger
globalLevel = lion.DefaultLevel
globalLock = &sync.Mutex{}
)
func init() {
if err := lion.RegisterEncoderDecoder(
Encoding,
newEncoderDecoder(
Encoding,
thrift.NewTBinaryProtocolFactory(
true,
true,
),
),
); err != nil {
panic(err.Error())
}
lion.AddGlobalHook(setGlobalLogger)
}
func setGlobalLogger(logger lion.Logger) {
globalLock.Lock()
defer globalLock.Unlock()
globalLogger = NewLogger(logger)
globalLevel = logger.Level()
}
// MustRegister calls Register and panics on error.
func MustRegister(constructor interface{}) {
if err := Register(constructor); err != nil {
panic(err.Error())
}
}
// Register registers the given thrift.TStruct using the generated constructor.
//
// The given constructor must be of the correct type.
func Register(constructor interface{}) error {
return register(constructor)
}
// LevelLogger is a lion.LevelLogger that also has proto logging methods.
type LevelLogger interface {
lion.BaseLevelLogger
WithField(key string, value interface{}) LevelLogger
WithFields(fields map[string]interface{}) LevelLogger
WithKeyValues(keyvalues ...interface{}) LevelLogger
WithContext(context thrift.TStruct) LevelLogger
Print(event thrift.TStruct)
}
// Logger is a lion.Logger that also has proto logging methods.
type Logger interface {
lion.BaseLogger
AtLevel(level lion.Level) Logger
WithField(key string, value interface{}) Logger
WithFields(fields map[string]interface{}) Logger
WithKeyValues(keyValues ...interface{}) Logger
WithContext(context thrift.TStruct) Logger
Debug(event thrift.TStruct)
Info(event thrift.TStruct)
Warn(event thrift.TStruct)
Error(event thrift.TStruct)
Fatal(event thrift.TStruct)
Panic(event thrift.TStruct)
Print(event thrift.TStruct)
// NOTE: this function name may change, this is experimental
LogDebug() LevelLogger
// NOTE: this function name may change, this is experimental
LogInfo() LevelLogger
LionLogger() lion.Logger
}
// GlobalLogger returns the global Logger instance.
func GlobalLogger() Logger {
return globalLogger
}
// NewLogger returns a new Logger.
func NewLogger(delegate lion.Logger) Logger {
return newLogger(delegate)
}
// Flush calls Flush on the global Logger.
func Flush() error {
return globalLogger.Flush()
}
// DebugWriter calls DebugWriter on the global Logger.
func DebugWriter() io.Writer {
return globalLogger.DebugWriter()
}
// InfoWriter calls InfoWriter on the global Logger.
func InfoWriter() io.Writer {
return globalLogger.InfoWriter()
}
// WarnWriter calls WarnWriter on the global Logger.
func WarnWriter() io.Writer {
return globalLogger.WarnWriter()
}
// ErrorWriter calls ErrorWriter on the global Logger.
func ErrorWriter() io.Writer {
return globalLogger.ErrorWriter()
}
// Writer calls Writer on the global Logger.
func Writer() io.Writer {
return globalLogger.Writer()
}
// Debugf calls Debugf on the global Logger.
func Debugf(format string, args ...interface{}) {
if lion.LevelDebug < globalLevel {
return
}
globalLogger.Debugf(format, args...)
}
// Debugln calls Debugln on the global Logger.
func Debugln(args ...interface{}) {
if lion.LevelDebug < globalLevel {
return
}
globalLogger.Debugln(args...)
}
// Infof calls Infof on the global Logger.
func Infof(format string, args ...interface{}) {
if lion.LevelInfo < globalLevel {
return
}
globalLogger.Infof(format, args...)
}
// Infoln calls Infoln on the global Logger.
func Infoln(args ...interface{}) {
if lion.LevelInfo < globalLevel {
return
}
globalLogger.Infoln(args...)
}
// Warnf calls Warnf on the global Logger.
func Warnf(format string, args ...interface{}) {
if lion.LevelWarn < globalLevel {
return
}
globalLogger.Warnf(format, args...)
}
// Warnln calls Warnln on the global Logger.
func Warnln(args ...interface{}) {
if lion.LevelWarn < globalLevel {
return
}
globalLogger.Warnln(args...)
}
// Errorf calls Errorf on the global Logger.
func Errorf(format string, args ...interface{}) {
if lion.LevelError < globalLevel {
return
}
globalLogger.Errorf(format, args...)
}
// Errorln calls Errorln on the global Logger.
func Errorln(args ...interface{}) {
if lion.LevelError < globalLevel {
return
}
globalLogger.Errorln(args...)
}
// Fatalf calls Fatalf on the global Logger.
func Fatalf(format string, args ...interface{}) {
if lion.LevelFatal < globalLevel {
return
}
globalLogger.Fatalf(format, args...)
}
// Fatalln calls Fatalln on the global Logger.
func Fatalln(args ...interface{}) {
if lion.LevelFatal < globalLevel {
return
}
globalLogger.Fatalln(args...)
}
// Panicf calls Panicf on the global Logger.
func Panicf(format string, args ...interface{}) {
if lion.LevelPanic < globalLevel {
return
}
globalLogger.Panicf(format, args...)
}
// Panicln calls Panicln on the global Logger.
func Panicln(args ...interface{}) {
if lion.LevelPanic < globalLevel {
return
}
globalLogger.Panicln(args...)
}
// Printf calls Printf on the global Logger.
func Printf(format string, args ...interface{}) {
globalLogger.Printf(format, args...)
}
// Println calls Println on the global Logger.
func Println(args ...interface{}) {
globalLogger.Println(args...)
}
// AtLevel calls AtLevel on the global Logger.
func AtLevel(level lion.Level) Logger {
return globalLogger.AtLevel(level)
}
// WithField calls WithField on the global Logger.
func WithField(key string, value interface{}) Logger {
return globalLogger.WithField(key, value)
}
// WithFields calls WithFields on the global Logger.
func WithFields(fields map[string]interface{}) Logger {
return globalLogger.WithFields(fields)
}
// WithKeyValues calls WithKeyValues on the global Logger.
func WithKeyValues(keyValues ...interface{}) Logger {
return globalLogger.WithKeyValues(keyValues...)
}
// WithContext calls WithContext on the global Logger.
func WithContext(context thrift.TStruct) Logger {
return globalLogger.WithContext(context)
}
// Debug calls Debug on the global Logger.
func Debug(event thrift.TStruct) {
if lion.LevelDebug < globalLevel {
return
}
globalLogger.Debug(event)
}
// Info calls Info on the global Logger.
func Info(event thrift.TStruct) {
if lion.LevelInfo < globalLevel {
return
}
globalLogger.Info(event)
}
// Warn calls Warn on the global Logger.
func Warn(event thrift.TStruct) {
if lion.LevelWarn < globalLevel {
return
}
globalLogger.Warn(event)
}
// Error calls Error on the global Logger.
func Error(event thrift.TStruct) {
if lion.LevelError < globalLevel {
return
}
globalLogger.Error(event)
}
// Fatal calls Fatal on the global Logger.
func Fatal(event thrift.TStruct) {
if lion.LevelFatal < globalLevel {
return
}
globalLogger.Fatal(event)
}
// Panic calls Panic on the global Logger.
func Panic(event thrift.TStruct) {
if lion.LevelPanic < globalLevel {
return
}
globalLogger.Panic(event)
}
// Print calls Print on the global Logger.
func Print(event thrift.TStruct) {
globalLogger.Print(event)
}
// LogDebug calls LogDebug on the global Logger.
func LogDebug() LevelLogger {
return globalLogger.LogDebug()
}
// LogInfo calls LogInfo on the global Logger.
func LogInfo() LevelLogger {
return globalLogger.LogInfo()
}
// LionLogger calls LionLogger on the global Logger.
func LionLogger() lion.Logger {
return globalLogger.LionLogger()
}
|