Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logger: 允许打印日志到控制台 #285

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions common/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,26 @@ func init() {

// LoggerInit Log配置初始化
func LoggerInit() {
var err error

Log.SetLevel(Config.LogLevel)
func() { _ = Log.DelLogger(logs.AdapterFile) }()
logConfig := map[string]interface{}{
"filename": Config.LogOutput,
"level": 7,
"maxlines": 0,
"maxsize": 0,
"daily": false,
"maxdays": 0,

if Config.LogOutput == "" {
err = Log.SetLogger(logs.AdapterConsole)
} else {
logConfig := map[string]interface{}{
"filename": Config.LogOutput,
"level": 7,
"maxlines": 0,
"maxsize": 0,
"daily": false,
"maxdays": 0,
}
logConfigJSON, _ := json.Marshal(logConfig)
err = Log.SetLogger(logs.AdapterFile, string(logConfigJSON))
}
logConfigJSON, _ := json.Marshal(logConfig)
err := Log.SetLogger(logs.AdapterFile, string(logConfigJSON))

if err != nil {
fmt.Println(err.Error())
}
Expand Down
38 changes: 0 additions & 38 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,28 @@ module github.com/XiaoMi/soar
go 1.15

require (
github.com/Azure/azure-storage-blob-go v0.10.0 // indirect
github.com/Azure/go-autorest/autorest v0.10.0 // indirect
github.com/CorgiMan/json2 v0.0.0-20150213135156-e72957aba209
github.com/aquarapid/vaultlib v0.5.1 // indirect
github.com/astaxie/beego v1.12.3
github.com/buger/jsonparser v1.1.1 // indirect
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 // indirect
github.com/cyberdelia/go-metrics-graphite v0.0.0-20161219230853-39f87cc3b432 // indirect
github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5
github.com/gedex/inflector v0.0.0-20170307190818-16278e9db813
github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab // indirect
github.com/go-sql-driver/mysql v1.6.0
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/hashicorp/consul/api v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.1.0 // indirect
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
github.com/hashicorp/go-uuid v1.0.2 // indirect
github.com/hashicorp/serf v0.9.2 // indirect
github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c // indirect
github.com/jeremywohl/flatten v0.0.0-20190921043622-d936035e55cf // indirect
github.com/klauspost/pgzip v1.2.4 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/kr/pretty v0.2.1
github.com/looplab/fsm v0.2.0 // indirect
github.com/martini-contrib/auth v0.0.0-20150219114609-fa62c19b7ae8 // indirect
github.com/martini-contrib/gzip v0.0.0-20151124214156-6c035326b43f // indirect
github.com/martini-contrib/render v0.0.0-20150707142108-ec18f8345a11 // indirect
github.com/mitchellh/go-ps v1.0.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.0 // indirect
github.com/mitchellh/mapstructure v1.2.3 // indirect
github.com/montanaflynn/stats v0.6.3 // indirect
github.com/olekukonko/tablewriter v0.0.5-0.20200416053754-163badb3bac6 // indirect
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/percona/go-mysql v0.0.0-20210427141028-73d29c6da78c
github.com/pingcap/log v0.0.0-20210317133921-96f4fcab92a4 // indirect
github.com/pingcap/parser v0.0.0-20210525032559-c37778aff307
github.com/pingcap/pd/v4 v4.0.0-beta.1.0.20200305072537-61d9f9cc35d3 // indirect
github.com/pingcap/tidb v1.1.0-beta.0.20210601085537-5d7c852770eb
github.com/pingcap/tipb v0.0.0-20210601083426-79a378b6d1c4 // indirect
github.com/planetscale/pargzip v0.0.0-20201116224723-90c7fc03ea8a // indirect
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
github.com/russross/blackfriday v1.6.0
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca
github.com/samuel/go-zookeeper v0.0.0-20200724154423-2164a8ac840e // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/sjmudd/stopwatch v0.0.0-20170613150411-f380bf8a9be1 // indirect
github.com/spf13/cobra v1.1.1 // indirect
github.com/spyzhov/ajson v0.4.2 // indirect
github.com/tidwall/gjson v1.12.1
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.17.0 // indirect
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/sys v0.0.0-20210601080250-7ecdf8ef093b // indirect
golang.org/x/text v0.3.6 // indirect
gopkg.in/gcfg.v1 v1.2.3 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0
vitess.io/vitess v0.0.0-20200325000816-eda961851d63
)
Loading