Skip to content

Commit

Permalink
fix: test logdir default value, issue TencentBlueKing#236
Browse files Browse the repository at this point in the history
  • Loading branch information
DeveloperJim committed Oct 25, 2019
1 parent 4024413 commit 654e405
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
3 changes: 0 additions & 3 deletions bcs-services/bcs-dns/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ dnssec:dnssec
autopath:autopath
template:template
hosts:hosts
federation:federation
k8s_external:k8s_external
kubernetes:kubernetes
bcsscheduler:bk-bcs/bcs-services/bcs-dns/plugin/bcsscheduler
bcscustom:bk-bcs/bcs-services/bcs-dns/plugin/bcscustom
file:file
Expand Down
39 changes: 25 additions & 14 deletions bcs-services/bcs-dns/plugin/log/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ import (
)

func init() {
blog.InitLogs(conf.LogConfig{
ToStdErr: false,
AlsoToStdErr: false,
Verbosity: 3,
StdErrThreshold: "2",
VModule: "",
TraceLocation: "",
LogDir: "/data/bcs/bcs-dns/testdir",
LogMaxSize: 500,
LogMaxNum: 10,
})
caddy.RegisterPlugin("log", caddy.Plugin{
ServerType: "dns",
Action: setup,
Expand All @@ -46,29 +57,29 @@ func setup(c *caddy.Controller) error {
c.OnStartup(func() error {
for i := 0; i < len(rules); i++ {
var writer io.Writer
fmt.Printf("######output file: %s#########\n", rules[i].OutputFile)
fmt.Printf("##output file: %s#########\n", rules[i].OutputFile)
if rules[i].OutputFile == "stdout" {
writer = os.Stdout
} else if rules[i].OutputFile == "stderr" {
writer = os.Stderr
} else {
blog.InitLogs(conf.LogConfig{
ToStdErr: false,
AlsoToStdErr: false,
Verbosity: 3,
StdErrThreshold: "2",
VModule: "",
TraceLocation: "",
LogDir: rules[i].OutputFile,
LogMaxSize: 500,
LogMaxNum: 10,
})
writer = &blog.GlogWriter{}
}

rules[i].Log = log.New(writer, "", 0)
}

/*
blog.InitLogs(conf.LogConfig{
ToStdErr: false,
AlsoToStdErr: false,
Verbosity: 3,
StdErrThreshold: "2",
VModule: "",
TraceLocation: "",
LogDir: "/data/bcs/bcs-dns/testdir",
LogMaxSize: 500,
LogMaxNum: 10,
})
*/
return nil

})
Expand Down

0 comments on commit 654e405

Please sign in to comment.