• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang log.SetLevelByString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/ngaut/log.SetLevelByString函数的典型用法代码示例。如果您正苦于以下问题:Golang SetLevelByString函数的具体用法?Golang SetLevelByString怎么用?Golang SetLevelByString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了SetLevelByString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: InitLog

func InitLog(runmode, path string) {
	log.SetLevelByString("info")

	if runmode == "dev" {
		log.SetLevelByString("debug")
	}

	log.SetOutputByName(path)
}
开发者ID:yzl11,项目名称:vessel,代码行数:9,代码来源:logger.go


示例2: main

func main() {
	flag.Parse()

	log.SetLevelByString(*logLevel)

	cfg := &server.Config{
		Addr:         *addr,
		ZKAddr:       *zk,
		RootPath:     *rootPath,
		SaveInterval: *interval,
	}

	oracle, err := server.NewTimestampOracle(cfg)
	if err != nil {
		log.Fatal(err)
	}

	go http.ListenAndServe(":5555", nil)

	sc := make(chan os.Signal, 1)
	signal.Notify(sc,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)

	go func() {
		sig := <-sc
		log.Infof("Got signal [%d] to exit.", sig)
		oracle.Close()
		os.Exit(0)
	}()

	oracle.Run()
}
开发者ID:pingcap,项目名称:tso,代码行数:35,代码来源:main.go


示例3: SetUpSuite

func (s *testBinlogSuite) SetUpSuite(c *C) {
	logLevel := os.Getenv("log_level")
	log.SetLevelByString(logLevel)
	store, err := tikv.NewMockTikvStore()
	c.Assert(err, IsNil)
	s.store = store
	tidb.SetSchemaLease(0)
	s.unixFile = "/tmp/mock-binlog-pump"
	os.Remove(s.unixFile)
	l, err := net.Listen("unix", s.unixFile)
	c.Assert(err, IsNil)
	s.serv = grpc.NewServer()
	s.pump = new(mockBinlogPump)
	binlog.RegisterPumpServer(s.serv, s.pump)
	go s.serv.Serve(l)
	opt := grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
		return net.DialTimeout("unix", addr, timeout)
	})
	clientCon, err := grpc.Dial(s.unixFile, opt, grpc.WithInsecure())
	c.Assert(err, IsNil)
	c.Assert(clientCon, NotNil)
	binloginfo.PumpClient = binlog.NewPumpClient(clientCon)
	s.tk = testkit.NewTestKit(c, s.store)
	s.tk.MustExec("use test")
	domain := sessionctx.GetDomain(s.tk.Se.(context.Context))
	s.ddl = domain.DDL()
}
开发者ID:pingcap,项目名称:tidb,代码行数:27,代码来源:binloginfo_test.go


示例4: SetUpTest

func (s *testStmtSuite) SetUpTest(c *C) {
	log.SetLevelByString("error")
	s.dbName = "teststmts"
	var err error
	s.testDB, err = sql.Open(tidb.DriverName, tidb.EngineGoLevelDBMemory+"/"+s.dbName+"/"+s.dbName)
	c.Assert(err, IsNil)
	// create db
	s.createDBSql = fmt.Sprintf("create database if not exists %s;", s.dbName)
	s.dropDBSql = fmt.Sprintf("drop database if exists %s;", s.dbName)
	s.useDBSql = fmt.Sprintf("use %s;", s.dbName)
	s.createTableSql = `
    CREATE TABLE test(id INT NOT NULL DEFAULT 1, name varchar(255), PRIMARY KEY(id));
    CREATE TABLE test1(id INT NOT NULL DEFAULT 2, name varchar(255), PRIMARY KEY(id), INDEX name(name));
    CREATE TABLE test2(id INT NOT NULL DEFAULT 3, name varchar(255), PRIMARY KEY(id));`

	s.selectSql = `SELECT * from test limit 2;`
	mustExec(c, s.testDB, s.createDBSql)
	mustExec(c, s.testDB, s.useDBSql)

	s.createSystemDBSQL = fmt.Sprintf("create database if not exists %s;", mysql.SystemDB)
	s.createUserTableSQL = tidb.CreateUserTable

	mustExec(c, s.testDB, s.createSystemDBSQL)
	mustExec(c, s.testDB, s.createUserTableSQL)
}
开发者ID:nengwang,项目名称:tidb,代码行数:25,代码来源:create_test.go


示例5: SetUpTest

func (t *testPrivilegeSuite) SetUpTest(c *C) {
	log.SetLevelByString("error")
	t.dbName = "test"
	t.store = newStore(c, t.dbName)
	se := newSession(c, t.store, t.dbName)
	t.createDBSQL = fmt.Sprintf("create database if not exists %s;", t.dbName)
	t.createDB1SQL = fmt.Sprintf("create database if not exists %s1;", t.dbName)
	t.dropDBSQL = fmt.Sprintf("drop database if exists %s;", t.dbName)
	t.useDBSQL = fmt.Sprintf("use %s;", t.dbName)
	t.createTableSQL = `CREATE TABLE test(id INT NOT NULL DEFAULT 1, name varchar(255), PRIMARY KEY(id));`

	mustExec(c, se, t.createDBSQL)
	mustExec(c, se, t.createDB1SQL) // create database test1
	mustExec(c, se, t.useDBSQL)
	mustExec(c, se, t.createTableSQL)

	t.createSystemDBSQL = fmt.Sprintf("create database if not exists %s;", mysql.SystemDB)
	t.createUserTableSQL = tidb.CreateUserTable
	t.createDBPrivTableSQL = tidb.CreateDBPrivTable
	t.createTablePrivTableSQL = tidb.CreateTablePrivTable
	t.createColumnPrivTableSQL = tidb.CreateColumnPrivTable

	mustExec(c, se, t.createSystemDBSQL)
	mustExec(c, se, t.createUserTableSQL)
	mustExec(c, se, t.createDBPrivTableSQL)
	mustExec(c, se, t.createTablePrivTableSQL)
	mustExec(c, se, t.createColumnPrivTableSQL)
}
开发者ID:lovedboy,项目名称:tidb,代码行数:28,代码来源:privileges_test.go


示例6: main

func main() {
	flag.Parse()

	if *lease < 0 {
		log.Fatalf("invalid lease seconds %d", *lease)
	}

	tidb.SetSchemaLease(time.Duration(*lease) * time.Second)

	log.SetLevelByString(*logLevel)
	store, err := tidb.NewStore(fmt.Sprintf("%s://%s", *store, *storePath))
	if err != nil {
		log.Fatal(err)
	}

	var driver relay.IDriver
	driver = relay.NewTiDBDriver(store)
	replayer, err := relay.NewReplayer(driver, *relayPath, *check)
	if err != nil {
		log.Fatal(err)
	}

	replayer.OnRecordRead = func(rec *relay.Record) {
		fmt.Printf("%s\n", rec)
	}

	err = replayer.Run()
	if err != nil {
		log.Fatal(errors.ErrorStack(err))
	}
}
开发者ID:pingcap,项目名称:mysqlrelay,代码行数:31,代码来源:main.go


示例7: OpenDB

// OpenDB opens the database in the given directory; if required, the database
// will be initialized.
func OpenDB(dir string) (err error) {
	log.SetLevelByString("error")

	dir = filepath.Join(dir, "tidb")
	_, err = os.Stat(dir)
	init := os.IsNotExist(err)

	name := "tidb"
	db, err = sqlx.Open("tidb", "goleveldb://"+dir+"/"+name)
	if err != nil {
		return fmt.Errorf("db open failed: %s", err)
	}
	if err := db.Ping(); err != nil {
		return fmt.Errorf("db ping failed: %s", err)
	}

	if init {
		// b, err := ioutil.ReadFile(filepath.Join("data", "schema.sql"))
		// if err != nil {
		// return fmt.Errorf("read schema file failed: %s", err)
		// }
		// if _, err = db.Exec(string(b)); err != nil {
		if _, err = db.Exec(schemasql); err != nil {
			return fmt.Errorf("exec schema failed: %s", err)
		}
		if err = insertCards(); err != nil {
			return fmt.Errorf("insert cards failed: %s", err)
		}
	}

	return nil
}
开发者ID:stepheninabox,项目名称:fowtcg,代码行数:34,代码来源:tidb.go


示例8: main

func main() {
	tidb.RegisterLocalStore("boltdb", boltdb.Driver{})
	tidb.RegisterStore("tikv", tikv.Driver{})

	metric.RunMetric(3 * time.Second)
	printer.PrintTiDBInfo()
	runtime.GOMAXPROCS(runtime.NumCPU())

	flag.Parse()

	if *lease < 0 {
		log.Fatalf("invalid lease seconds %d", *lease)
	}

	tidb.SetSchemaLease(time.Duration(*lease) * time.Second)

	cfg := &server.Config{
		Addr:       fmt.Sprintf(":%s", *port),
		LogLevel:   *logLevel,
		StatusAddr: fmt.Sprintf(":%s", *statusPort),
		Socket:     *socket,
	}

	log.SetLevelByString(cfg.LogLevel)
	store, err := tidb.NewStore(fmt.Sprintf("%s://%s", *store, *storePath))
	if err != nil {
		log.Fatal(errors.ErrorStack(err))
	}
	// Create a session to load information schema.
	se, err := tidb.CreateSession(store)
	if err != nil {
		log.Fatal(errors.ErrorStack(err))
	}
	se.Close()

	var driver server.IDriver
	driver = server.NewTiDBDriver(store)
	var svr *server.Server
	svr, err = server.NewServer(cfg, driver)
	if err != nil {
		log.Fatal(errors.ErrorStack(err))
	}

	sc := make(chan os.Signal, 1)
	signal.Notify(sc,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)

	go func() {
		sig := <-sc
		log.Infof("Got signal [%d] to exit.", sig)
		svr.Close()
		os.Exit(0)
	}()

	log.Error(svr.Run())
}
开发者ID:anywhy,项目名称:tidb,代码行数:59,代码来源:main.go


示例9: SetUpSuite

func (s *testTableRsetSuite) SetUpSuite(c *C) {
	log.SetLevelByString("error")
	s.dbName = "rset_test"
	s.tableName = "rset_table"

	s.createTableSql = fmt.Sprintf("create table if not exists %s(id int);", s.tableName)
	s.querySql = fmt.Sprintf("select * from %s;", s.tableName)
}
开发者ID:ninefive,项目名称:tidb,代码行数:8,代码来源:from_test.go


示例10: main

func main() {
	log.SetLevelByString(*logLevel)
	createTable(forceDrop)
	{
		timing("insert test data", func() {
			insertTestData(*concurrent)
		})
	}
}
开发者ID:c4pt0r,项目名称:pd-dashboard,代码行数:9,代码来源:main.go


示例11: SetUpSuite

func (s *testKVSuite) SetUpSuite(c *C) {
	store, err := tidb.NewStore(fmt.Sprintf("%s://%s", *testStore, *testStorePath))
	c.Assert(err, IsNil)
	s.s = store

	cacheS, _ := tidb.NewStore(fmt.Sprintf("%s://%s", *testStore, *testStorePath))
	c.Assert(cacheS, Equals, store)
	log.SetLevelByString("warn")
}
开发者ID:anywhy,项目名称:tidb,代码行数:9,代码来源:store_test.go


示例12: main

func main() {
	log.SetLevelByString(*logLevel)
	timing("create table", func() {
		createTable()
	})
	timing("insert test data", func() {
		insertTestData(*rows, *concurrent)
	})
}
开发者ID:shitfSign,项目名称:tidb-bench,代码行数:9,代码来源:main.go


示例13: main

func main() {
	flag.Parse()
	log.SetLevelByString("warn")
	go http.ListenAndServe(":9191", nil)

	value := make([]byte, *valueSize)
	t := time.Now()
	batchRawPut(value)

	fmt.Printf("\nelapse:%v, total %v\n", time.Since(t), *dataCnt)
}
开发者ID:pingcap,项目名称:tidb,代码行数:11,代码来源:main.go


示例14: SetUpSuite

func (s *testMainSuite) SetUpSuite(c *C) {
	s.dbName = "test_main_db"
	s.createDBSQL = fmt.Sprintf("create database if not exists %s;", s.dbName)
	s.dropDBSQL = fmt.Sprintf("drop database %s;", s.dbName)
	s.useDBSQL = fmt.Sprintf("use %s;", s.dbName)
	s.createTableSQL = `
    CREATE TABLE tbl_test(id INT NOT NULL DEFAULT 1, name varchar(255), PRIMARY KEY(id));
    CREATE TABLE tbl_test1(id INT NOT NULL DEFAULT 2, name varchar(255), PRIMARY KEY(id), INDEX name(name));
    CREATE TABLE tbl_test2(id INT NOT NULL DEFAULT 3, name varchar(255), PRIMARY KEY(id));`
	s.selectSQL = `SELECT * from tbl_test;`
	runtime.GOMAXPROCS(runtime.NumCPU())

	log.SetLevelByString("error")
}
开发者ID:awesomeleo,项目名称:tidb,代码行数:14,代码来源:tidb_test.go


示例15: main

func main() {
	metric.RunMetric(3 * time.Second)
	printer.PrintTiDBInfo()
	runtime.GOMAXPROCS(runtime.NumCPU())

	flag.Parse()

	if *lease <= 0 {
		log.Fatalf("invalid lease seconds %d", *lease)
	}

	tidb.SetSchemaLease(time.Duration(*lease) * time.Second)

	cfg := &server.Config{
		Addr:     fmt.Sprintf(":%s", *port),
		LogLevel: *logLevel,
	}

	log.SetLevelByString(cfg.LogLevel)
	store, err := tidb.NewStore(fmt.Sprintf("%s://%s", *store, *storePath))
	if err != nil {
		log.Fatal(err)
	}

	var driver server.IDriver
	driver = server.NewTiDBDriver(store)
	var svr *server.Server
	svr, err = server.NewServer(cfg, driver)
	if err != nil {
		log.Fatal(err)
	}

	sc := make(chan os.Signal, 1)
	signal.Notify(sc,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)

	go func() {
		sig := <-sc
		log.Infof("Got signal [%d] to exit.", sig)
		svr.Close()
		os.Exit(0)
	}()

	log.Error(svr.Run())
}
开发者ID:yzl11,项目名称:vessel,代码行数:48,代码来源:main.go


示例16: SetUpSuite

func (ts *TidbTestSuite) SetUpSuite(c *C) {
	log.SetLevelByString("error")
	store, err := tidb.NewStore("memory:///tmp/tidb")
	c.Assert(err, IsNil)
	ts.tidbdrv = NewTiDBDriver(store)
	cfg := &Config{
		Addr:       ":4001",
		LogLevel:   "debug",
		StatusAddr: ":10090",
	}
	server, err := NewServer(cfg, ts.tidbdrv)
	c.Assert(err, IsNil)
	ts.server = server
	go ts.server.Run()
	time.Sleep(time.Millisecond * 100)
}
开发者ID:yubobo,项目名称:tidb,代码行数:16,代码来源:tidb_test.go


示例17: main

func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	log.SetLevelByString("debug")
	log.Errorf("begin create table")
	dropTable(tblName1)
	createTable(tblName1)
	dropTable(tblName2)
	createTable(tblName2)
	log.Errorf("create table finish")

	go func() {
		log.Error(http.ListenAndServe("localhost:8889", nil))
	}()

	batchInsert(5, 50000)
}
开发者ID:yzl11,项目名称:vessel,代码行数:16,代码来源:main.go


示例18: main

func main() {
	log.SetLevelByString(*logLevel)
	createTable(forceDrop)
	{
		timing("insert test data", func() {
			insertTestData(*rows, *concurrent)
		})
		if !*insertOnly {
			timing("select point data", func() {
				selectPointTestData(*rows, *N, *concurrent)
			})
			timing("select range data", func() {
				selectRangeTestData(*rows, *N, *concurrent)
			})
		}
	}
}
开发者ID:pingcap,项目名称:tidb-bench,代码行数:17,代码来源:main.go


示例19: SetUpSuite

func (s *testSuite) SetUpSuite(c *C) {
	s.Parser = parser.New()
	flag.Lookup("mockTikv")
	useMockTikv := *mockTikv
	if useMockTikv {
		store, err := tikv.NewMockTikvStore()
		c.Assert(err, IsNil)
		s.store = store
		tidb.SetSchemaLease(0)
	} else {
		store, err := tidb.NewStore("memory://test/test")
		c.Assert(err, IsNil)
		s.store = store
	}
	logLevel := os.Getenv("log_level")
	log.SetLevelByString(logLevel)
	executor.BaseLookupTableTaskSize = 2
}
开发者ID:jmptrader,项目名称:tidb,代码行数:18,代码来源:executor_test.go


示例20: init

func init() {
	// set log settings
	log15.Root().SetHandler(log15.LvlFilterHandler(log15.LvlDebug, ext.FatalHandler(log15.StderrHandler)))

	// close tidb debug
	log.SetLevelByString("error")
	tidb.Debug = false

	// init global vars
	var (
		config   *Config = NewConfig()
		database *Db     = NewDB(config.Db.Driver, config.Db.DSN)
		server   *Web    = NewWeb(config.Http.Host, config.Http.Port, config.Http.Protocol)
	)
	Injector = pucore.NewInjector(config, database, server)
	Behavior = pucore.NewBehaviors()
	Modular = pucore.NewModular(Injector, Behavior)
}
开发者ID:go-xiaohei,项目名称:pucore,代码行数:18,代码来源:app.go



注:本文中的github.com/ngaut/log.SetLevelByString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang log.Warn函数代码示例发布时间:2022-05-29
下一篇:
Golang log.Infof函数代码示例发布时间:2022-05-29
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap