Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 8831015

Browse files
authored
Merge pull request #501 from erizocosmico/feature/replace-glog
_scripts: replace glog with logrus
2 parents 85cd592 + 6580302 commit 8831015

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed

_scripts/go-vitess/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ filter-branch: clone
1919
cd ${VITESS_SRC} && \
2020
git filter-branch --subdirectory-filter go && \
2121
rm -fr README.md cacheservice cmd exit ioutil2 memcache race ratelimiter stats/influxdbbackend stats/opentsdb stats/prometheusbackend testfiles vtbench zk vt/mysqlctl/cephbackupstorage && \
22-
cp -f "${CWD}/doc.go" "${CWD}/README.md" "${CWD}/LICENSE" ${VITESS_SRC}
22+
cp -f "${CWD}/doc.go" "${CWD}/README.md" "${CWD}/LICENSE" ${VITESS_SRC} && \
23+
cp -f "${CWD}/vt/log/log.go" "${VITESS_SRC}/vt/log/log.go"
2324

2425
rename-packages:
2526
cd ${VITESS_SRC} && \

_scripts/go-vitess/vt/log/log.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// You can modify this file to hook up a different logging library instead of logrus.
2+
// If you adapt to a different logging framework, you may need to use that
3+
// framework's equivalent of *Depth() functions so the file and line number printed
4+
// point to the real caller instead of your adapter function.
5+
6+
package log
7+
8+
import "github.com/sirupsen/logrus"
9+
10+
// Level is used with V() to test log verbosity.
11+
type Level = logrus.Level
12+
13+
var (
14+
// V quickly checks if the logging verbosity meets a threshold.
15+
V = func(level int) bool {
16+
lvl := logrus.GetLevel()
17+
switch level {
18+
case 0:
19+
return lvl == logrus.InfoLevel
20+
case 1:
21+
return lvl == logrus.WarnLevel
22+
case 2:
23+
return lvl == logrus.ErrorLevel
24+
case 3:
25+
return lvl == logrus.FatalLevel
26+
default:
27+
return false
28+
}
29+
}
30+
31+
// Flush ensures any pending I/O is written.
32+
Flush = func() {}
33+
34+
// Info formats arguments like fmt.Print.
35+
Info = logrus.Info
36+
// Infof formats arguments like fmt.Printf.
37+
Infof = logrus.Infof
38+
// InfoDepth formats arguments like fmt.Print and uses depth to choose which call frame to log.
39+
InfoDepth = func(_ int, args ...interface{}) {
40+
logrus.Info(args...)
41+
}
42+
43+
// Warning formats arguments like fmt.Print.
44+
Warning = logrus.Warning
45+
// Warningf formats arguments like fmt.Printf.
46+
Warningf = logrus.Warningf
47+
// WarningDepth formats arguments like fmt.Print and uses depth to choose which call frame to log.
48+
WarningDepth = func(depth int, args ...interface{}) {
49+
logrus.Warning(args...)
50+
}
51+
52+
// Error formats arguments like fmt.Print.
53+
Error = logrus.Error
54+
// Errorf formats arguments like fmt.Printf.
55+
Errorf = logrus.Errorf
56+
// ErrorDepth formats arguments like fmt.Print and uses depth to choose which call frame to log.
57+
ErrorDepth = func(_ int, args ...interface{}) {
58+
logrus.Error(args...)
59+
}
60+
61+
// Exit formats arguments like fmt.Print.
62+
Exit = logrus.Panic
63+
// Exitf formats arguments like fmt.Printf.
64+
Exitf = logrus.Panicf
65+
// ExitDepth formats arguments like fmt.Print and uses depth to choose which call frame to log.
66+
ExitDepth = func(_ int, args ...interface{}) {
67+
logrus.Panic(args...)
68+
}
69+
70+
// Fatal formats arguments like fmt.Print.
71+
Fatal = logrus.Fatal
72+
// Fatalf formats arguments like fmt.Printf
73+
Fatalf = logrus.Fatalf
74+
// FatalDepth formats arguments like fmt.Print and uses depth to choose which call frame to log.
75+
FatalDepth = func(_ int, args ...interface{}) {
76+
logrus.Fatal(args...)
77+
}
78+
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy