修改开发/测试环境写日志方式
This commit is contained in:
parent
30b584f0bd
commit
33161d92ac
8
log.go
8
log.go
@ -141,6 +141,12 @@ func init() {
|
||||
}
|
||||
|
||||
defaultModeMapping["es"] = []AdapterTupple{{level, AdapterConsole}, {level, AdapterElasticSearch}}
|
||||
defaultModeMapping["ali"] = []AdapterTupple{{level, AdapterConsole}, {level, AdapterAliLs}}
|
||||
defaultModeMapping[""] = []AdapterTupple{{level, AdapterConsole}, {level, AdapterFile}}
|
||||
defaultModeMapping["ali"] = []AdapterTupple{{level, AdapterConsole}}
|
||||
env := os.Getenv(envKey)
|
||||
if env == "production" || env == "gray" || os.Getenv("GRLOG_INTERNET") == "public" {
|
||||
defaultModeMapping["ali"] = append(defaultModeMapping["ali"], AdapterTupple{level, AdapterAliLs})
|
||||
} else {
|
||||
defaultModeMapping["ali"] = append(defaultModeMapping["ali"], AdapterTupple{level, AdapterFile})
|
||||
}
|
||||
}
|
||||
|
@ -63,12 +63,11 @@ func TestDropAdapter(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
os.Setenv("GRLOG_INTERNET", "public")
|
||||
os.Setenv("GAORE_ENVIRONMENT", "development")
|
||||
os.Setenv("CENTER_RUNMODE", "dev")
|
||||
os.Setenv("GRLOG_APP_NAME", "yoda")
|
||||
os.Setenv("GRLOG_ALILS_DEBUG", "on")
|
||||
t.Log(os.Getenv("GRLOG_INTERNET"))
|
||||
t.Log("GRLOG_INTERNET:" + os.Getenv("GRLOG_INTERNET"))
|
||||
t.Log("GAORE_ENVIRONMENT:" + os.Getenv("GAORE_ENVIRONMENT"))
|
||||
wg := sync.WaitGroup{}
|
||||
for i := 0; i < 10; i++ {
|
||||
wg.Add(1)
|
||||
|
21
logs/file.go
21
logs/file.go
@ -81,7 +81,7 @@ func newFileWriter() Logger {
|
||||
Rotate: true,
|
||||
RotatePerm: "0440",
|
||||
Level: LevelTrace,
|
||||
Perm: "0660",
|
||||
Perm: "0755",
|
||||
MaxLines: 10000000,
|
||||
MaxFiles: 999,
|
||||
MaxSize: 1 << 28,
|
||||
@ -91,15 +91,16 @@ func newFileWriter() Logger {
|
||||
|
||||
// Init file logger with json config.
|
||||
// jsonConfig like:
|
||||
// {
|
||||
// "filename":"logs/beego.log",
|
||||
// "maxLines":10000,
|
||||
// "maxsize":1024,
|
||||
// "daily":true,
|
||||
// "maxDays":15,
|
||||
// "rotate":true,
|
||||
// "perm":"0600"
|
||||
// }
|
||||
//
|
||||
// {
|
||||
// "filename":"logs/beego.log",
|
||||
// "maxLines":10000,
|
||||
// "maxsize":1024,
|
||||
// "daily":true,
|
||||
// "maxDays":15,
|
||||
// "rotate":true,
|
||||
// "perm":"0600"
|
||||
// }
|
||||
func (w *fileLogWriter) Init(jsonConfig string) error {
|
||||
err := json.Unmarshal([]byte(jsonConfig), w)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user