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

Golang lumber.LvlInt函数代码示例

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

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



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

示例1: startLogvac

func startLogvac(ccmd *cobra.Command, args []string) error {
	// initialize logger
	lumber.Level(lumber.LvlInt(config.LogLevel)) // for clients using lumber too
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt(config.LogLevel))

	// initialize logvac
	logvac.Init()

	// setup authenticator
	err := authenticator.Init()
	if err != nil {
		return fmt.Errorf("Authenticator failed to initialize - %v", err)
	}

	// initialize drains
	err = drain.Init()
	if err != nil {
		return fmt.Errorf("Drain failed to initialize - %v", err)
	}

	// initializes collectors
	err = collector.Init()
	if err != nil {
		return fmt.Errorf("Collector failed to initialize - %v", err)
	}

	err = api.Start(collector.CollectHandler)
	if err != nil {
		return fmt.Errorf("Api failed to initialize - %v", err)
	}

	return nil
}
开发者ID:nanopack,项目名称:logvac,代码行数:33,代码来源:main.go


示例2: startHoarder

func startHoarder(ccmd *cobra.Command, args []string) error {
	// convert the log level
	logLvl := lumber.LvlInt(viper.GetString("log-level"))

	// configure the logger
	lumber.Prefix("[hoader]")
	lumber.Level(logLvl)

	// enable/start garbage collection if age config was changed
	if ccmd.Flag("clean-after").Changed {
		lumber.Debug("Starting garbage collector (data older than %vs)...\n", ccmd.Flag("clean-after").Value)

		// start garbage collector
		go collector.Start()
	}

	// set, and initialize, the backend driver
	if err := backends.Initialize(); err != nil {
		lumber.Error("Failed to initialize backend - %v", err)
		return err
	}

	// start the API
	if err := api.Start(); err != nil {
		lumber.Fatal("Failed to start API: ", err.Error())
		return err
	}

	return nil
}
开发者ID:nanopack,项目名称:hoarder,代码行数:30,代码来源:commands.go


示例3: AddFlags

// AddFlags adds cli flags to logvac
func AddFlags(cmd *cobra.Command) {
	// collectors
	cmd.Flags().StringVarP(&ListenHttp, "listen-http", "a", ListenHttp, "API listen address (same endpoint for http log collection)")
	cmd.Flags().StringVarP(&ListenUdp, "listen-udp", "u", ListenUdp, "UDP log collection endpoint")
	cmd.Flags().StringVarP(&ListenTcp, "listen-tcp", "t", ListenTcp, "TCP log collection endpoint")

	// drains
	cmd.Flags().StringVarP(&PubAddress, "pub-address", "p", PubAddress, "Log publisher (mist) address (\"mist://127.0.0.1:1445\")")
	cmd.Flags().StringVarP(&PubAuth, "pub-auth", "P", PubAuth, "Log publisher (mist) auth token")
	cmd.Flags().StringVarP(&DbAddress, "db-address", "d", DbAddress, "Log storage address")

	// authenticator
	cmd.PersistentFlags().StringVarP(&AuthAddress, "auth-address", "A", AuthAddress, "Address or file location of authentication db. ('boltdb:///var/db/logvac.bolt' or 'postgresql://127.0.0.1')")

	// other
	cmd.Flags().StringVarP(&CorsAllow, "cors-allow", "C", CorsAllow, "Sets the 'Access-Control-Allow-Origin' header")
	cmd.Flags().StringVarP(&LogKeep, "log-keep", "k", LogKeep, "Age or number of logs to keep per type '{\"app\":\"2w\", \"deploy\": 10}' (int or X(m)in, (h)our,  (d)ay, (w)eek, (y)ear)")
	cmd.Flags().StringVarP(&LogLevel, "log-level", "l", LogLevel, "Level at which to log")
	cmd.Flags().StringVarP(&LogType, "log-type", "L", LogType, "Default type to apply to incoming logs (commonly used: app|deploy)")
	cmd.Flags().StringVarP(&Token, "token", "T", Token, "Administrative token to add/remove 'X-USER-TOKEN's used to pub/sub via http")
	cmd.Flags().BoolVarP(&Server, "server", "s", Server, "Run as server")
	cmd.Flags().BoolVarP(&Insecure, "insecure", "i", Insecure, "Don't use TLS (used for testing)")
	cmd.Flags().BoolVarP(&Version, "version", "v", Version, "Print version info and exit")

	Log = lumber.NewConsoleLogger(lumber.LvlInt("ERROR"))
}
开发者ID:nanopack,项目名称:logvac,代码行数:27,代码来源:config.go


示例4: initialize

// manually configure and start internals
func initialize() {
	config.ListenHttp = "127.0.0.1:4234"
	config.ListenTcp = "127.0.0.1:4235"
	config.ListenUdp = "127.0.0.1:4234"
	config.DbAddress = "boltdb:///tmp/syslogTest/logvac.bolt"
	config.AuthAddress = ""
	config.Insecure = true
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt("ERROR"))

	// initialize logvac
	logvac.Init()

	// setup authenticator
	err := authenticator.Init()
	if err != nil {
		config.Log.Fatal("Authenticator failed to initialize - %v", err)
		os.Exit(1)
	}

	// initialize drains
	err = drain.Init()
	if err != nil {
		config.Log.Fatal("Drain failed to initialize - %v", err)
		os.Exit(1)
	}

	// initializes collectors
	err = collector.Init()
	if err != nil {
		config.Log.Fatal("Collector failed to initialize - %v", err)
		os.Exit(1)
	}
}
开发者ID:nanopack,项目名称:logvac,代码行数:34,代码来源:collector_test.go


示例5: startShaman

func startShaman(ccmd *cobra.Command, args []string) error {
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt(config.LogLevel))

	// initialize cache
	err := cache.Initialize()
	if err != nil {
		config.Log.Fatal(err.Error())
		return err
	}

	// make channel for errors
	errors := make(chan error)

	go func() {
		errors <- api.Start()
	}()
	go func() {
		errors <- server.Start()
	}()

	// break if any of them return an error (blocks exit)
	if err := <-errors; err != nil {
		config.Log.Fatal(err.Error())
	}
	return err
}
开发者ID:nanopack,项目名称:shaman,代码行数:26,代码来源:main.go


示例6: initialize

func initialize() {
	ifIptables, err := exec.Command("iptables", "-S").CombinedOutput()
	if err != nil {
		fmt.Printf("Failed to run iptables - %s%v\n", ifIptables, err.Error())
		skip = true
	}
	ifIpvsadm, err := exec.Command("ipvsadm", "--version").CombinedOutput()
	if err != nil {
		fmt.Printf("Failed to run ipvsadm - %s%v\n", ifIpvsadm, err.Error())
		skip = true
	}

	config.Log = lumber.NewConsoleLogger(lumber.LvlInt("FATAL"))

	if !skip {
		// todo: find more friendly way to clear crufty rules only
		err = exec.Command("iptables", "-F", "portal").Run()
		if err != nil {
			fmt.Printf("Failed to clear iptables - %v\n", err.Error())
			os.Exit(1)
		}
		err = exec.Command("ipvsadm", "-C").Run()
		if err != nil {
			fmt.Printf("Failed to clear ipvsadm - %v\n", err.Error())
			os.Exit(1)
		}

		balance.Init()
	}
}
开发者ID:nanopack,项目名称:portal,代码行数:30,代码来源:lvs_test.go


示例7: initialize

// manually configure and start internals
func initialize() error {
	var err error
	drain.CleanFreq = 1
	config.LogKeep = `{"app": "1s", "deploy":0}`
	config.LogKeep = `{"app": "1s", "deploy":0, "a":"1m", "aa":"1h", "b":"1d", "c":"1w", "d":"1y", "e":"1"}`
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt("ERROR"))

	// initialize logvac
	logvac.Init()

	// initialize archiver
	// Doing broke db
	config.DbAddress = "[email protected]#$%^&*()"
	drain.Init()

	// Doing file db
	config.DbAddress = "file:///tmp/boltdbTest/logvac.bolt"
	drain.Init()
	drain.Archiver.(*drain.BoltArchive).Close()

	// Doing no db
	config.DbAddress = "/tmp/boltdbTest/logvac.bolt"
	drain.Init()
	drain.Archiver.(*drain.BoltArchive).Close()

	// Doing bolt db
	config.DbAddress = "boltdb:///tmp/boltdbTest/logvac.bolt"
	drain.Init()

	return err
}
开发者ID:nanopack,项目名称:logvac,代码行数:32,代码来源:boltdb_test.go


示例8: mistInitialize

// manually configure and start internals
func mistInitialize() error {
	var err error
	drain.CleanFreq = 1
	config.LogKeep = `{"app": "1s", "deploy":0}`
	config.LogKeep = `{"app": "1s", "deploy":0, "a":"1m", "aa":"1h", "b":"1d", "c":"1w", "d":"1y", "e":"1"}`
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt("ERROR"))
	config.DbAddress = "boltdb:///tmp/boltdbTest/logvac.bolt"

	server.StartTCP(PubAddress, nil)

	// initialize logvac
	logvac.Init()

	// initialize publisher
	// Doing broke publisher
	config.PubAddress = "[email protected]#$%^&*()"
	drain.Init()
	drain.Archiver.(*drain.BoltArchive).Close()

	// Doing schemeless publisher
	config.PubAddress = "127.0.0.1:2445"
	drain.Init()
	drain.Archiver.(*drain.BoltArchive).Close()
	drain.Publisher.(*drain.Mist).Close()

	// Doing real publisher
	config.PubAddress = "mist://127.0.0.1:2445"
	err = drain.Init()

	return err
}
开发者ID:nanopack,项目名称:logvac,代码行数:32,代码来源:mist_test.go


示例9: TestPublish

// Test writing and getting data
func TestPublish(t *testing.T) {
	lumber.Level(lumber.LvlInt("fatal"))
	err := mistInitialize()
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	// create test messages
	messages := []logvac.Message{
		logvac.Message{
			Time:     time.Now(),
			UTime:    time.Now().UnixNano(),
			Id:       "myhost",
			Tag:      "test[bolt]",
			Type:     "",
			Priority: 4,
			Content:  "This is a test message",
		},
		logvac.Message{
			Time:     time.Now(),
			UTime:    time.Now().UnixNano(),
			Id:       "myhost",
			Tag:      "test[expire]",
			Type:     "deploy",
			Priority: 4,
			Content:  "This is another test message",
		},
	}

	// write test messages
	drain.Publisher.Publish(messages[0])
	drain.Publisher.Publish(messages[1])
}
开发者ID:nanopack,项目名称:logvac,代码行数:35,代码来源:mist_test.go


示例10: initialize

// manually configure and start internals
func initialize() {
	config.Insecure = true
	config.L2Connect = "none://"
	config.ApiListen = "127.0.0.1:1634"
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt("FATAL"))
	config.LogLevel = "FATAL"
}
开发者ID:nanopack,项目名称:shaman,代码行数:8,代码来源:commands_test.go


示例11: TestSetService

func TestSetService(t *testing.T) {
	config.DatabaseConnection = "scribble:///tmp/scribbleTest"
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt("FATAL"))

	// Backend = &database.ScribbleDatabase{}
	database.Init()

	if err := database.SetService(&testService1); err != nil {
		t.Errorf("Failed to SET service - %v", err)
	}

	service, err := ioutil.ReadFile("/tmp/scribbleTest/services/tcp-192_168_0_15-80.json")
	if err != nil {
		t.Error(err)
	}

	jService, err := toJson(testService1)
	if err != nil {
		t.Error(err)
	}

	if string(service) != string(jService) {
		t.Errorf("Read service differs from written service")
	}
}
开发者ID:nanopack,项目名称:portal,代码行数:25,代码来源:scribble_test.go


示例12: TestMain

// TestMain
func TestMain(m *testing.M) {
	lumber.Level(lumber.LvlInt("fatal"))

	server.StartTCP(testAddr, nil)

	//
	os.Exit(m.Run())
}
开发者ID:nanopack,项目名称:mist,代码行数:9,代码来源:clients_test.go


示例13: Parse

func Parse(configFile string) {
	c := map[string]string{}

	bytes, err := ioutil.ReadFile(configFile)
	if err != nil {
		Log.Error("unable to read config file: %v\n", err)
	}
	err = yaml.Unmarshal(bytes, &c)
	if err != nil {
		Log.Error("err parsing config file: %v\n", err)
		Log.Error("falling back to default values")
	}

	Log = lumber.NewConsoleLogger(lumber.LvlInt(c["log_level"]))
	if c["ssh_listen_address"] != "" {
		SshListenAddress = c["ssh_listen_address"]
	}
	if c["http_listen_address"] != "" {
		HttpListenAddress = c["http_listen_address"]
	}
	if c["key_path"] != "" {
		KeyPath = c["key_path"]
	}
	if c["repo_type"] != "" {
		RepoType = c["repo_type"]
	}
	if c["repo_location"] != "" {
		RepoLocation = c["repo_location"]
	}
	if c["key_auth_type"] != "" {
		KeyAuthType = c["key_auth_type"]
	}
	if c["key_auth_location"] != "" {
		KeyAuthLocation = c["key_auth_location"]
	}
	if c["repo_type"] != "" {
		RepoType = c["repo_type"]
	}
	if c["repo_location"] != "" {
		RepoLocation = c["repo_location"]
	}
	if c["repo_type"] != "" {
		RepoType = c["repo_type"]
	}
	if c["repo_location"] != "" {
		RepoLocation = c["repo_location"]
	}
	if c["repo_type"] != "" {
		RepoType = c["repo_type"]
	}
	if c["repo_location"] != "" {
		RepoLocation = c["repo_location"]
	}
	if c["token"] != "" {
		Token = c["token"]
	}
}
开发者ID:Lanzafame,项目名称:butter,代码行数:57,代码来源:config.go


示例14: startPulse

func startPulse(ccmd *cobra.Command, args []string) error {
	// re-initialize logger
	lumber.Level(lumber.LvlInt(viper.GetString("log-level")))

	plex := plexer.NewPlexer()

	if viper.GetString("mist-address") != "" {
		mist, err := mist.New(viper.GetString("mist-address"), viper.GetString("mist-token"))
		if err != nil {
			return fmt.Errorf("Mist failed to start - %s", err.Error())
		}
		plex.AddObserver("mist", mist.Publish)
		defer mist.Close()
	}

	plex.AddBatcher("influx", influx.Insert)

	err := pulse.Listen(viper.GetString("server-listen-address"), plex.Publish)
	if err != nil {
		return fmt.Errorf("Pulse failed to start - %s", err.Error())
	}
	// begin polling the connected servers
	pollSec := viper.GetInt("poll-interval")
	if pollSec == 0 {
		pollSec = 60
	}
	go pulse.StartPolling(nil, nil, time.Duration(pollSec)*time.Second, nil)

	queries := []string{
		"CREATE DATABASE statistics",
		"CREATE RETENTION POLICY one_day ON statistics DURATION 8h REPLICATION 1 DEFAULT",
		fmt.Sprintf("CREATE RETENTION POLICY one_week ON statistics DURATION %dw REPLICATION 1", viper.GetInt("retention")), // todo: ALTER as well?
	}

	for _, query := range queries {
		_, err := influx.Query(query)
		if err != nil {
			return fmt.Errorf("Failed to query influx - %s", err.Error())
		}
	}

	go influx.KeepContinuousQueriesUpToDate()

	if viper.GetString("kapacitor-address") != "" {
		err := kapacitor.Init()
		if err != nil {
			return fmt.Errorf("Kapacitor failed to start - %s", err.Error())
		}
	}

	err = api.Start()
	if err != nil {
		return fmt.Errorf("Api failed to start - %s", err.Error())
	}

	return nil
}
开发者ID:nanopack,项目名称:pulse,代码行数:57,代码来源:main.go


示例15: TestMain

func TestMain(m *testing.M) {
	// manually configure
	// config.Log = lumber.NewConsoleLogger(lumber.LvlInt("trace"))
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt("FATAL"))

	// run tests
	rtn := m.Run()

	os.Exit(rtn)
}
开发者ID:nanopack,项目名称:shaman,代码行数:10,代码来源:cache_test.go


示例16: TestMain

func TestMain(m *testing.M) {
	shamanClear()
	// manually configure
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt("FATAL"))

	// run tests
	rtn := m.Run()

	os.Exit(rtn)
}
开发者ID:nanopack,项目名称:shaman,代码行数:10,代码来源:shaman_test.go


示例17: TestMain

func TestMain(m *testing.M) {
	// manually configure
	config.DnsListen = "127.0.0.1:8053"
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt("FATAL"))

	// start dns server
	go server.Start()
	<-time.After(time.Second)

	// run tests
	rtn := m.Run()

	os.Exit(rtn)
}
开发者ID:nanopack,项目名称:shaman,代码行数:14,代码来源:dns_test.go


示例18: initialize

func initialize() {
	rExec, err := exec.Command("redis-server", "-v").CombinedOutput()
	if err != nil {
		fmt.Printf("Failed to run redis-server - %s%v\n", rExec, err.Error())
		skip = true
	}

	config.RouteHttp = "0.0.0.0:9082"
	config.RouteTls = "0.0.0.0:9445"
	config.LogLevel = "FATAL"
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt(config.LogLevel))

	if !skip {
		config.ClusterConnection = "redis://127.0.0.1:6379"
		config.DatabaseConnection = "scribble:///tmp/clusterTest"

		err = database.Init()
		if err != nil {
			fmt.Printf("database init failed - %v\n", err)
			os.Exit(1)
		}

		balance.Balancer = &database.ScribbleDatabase{}
		err = balance.Balancer.Init()
		if err != nil {
			fmt.Printf("balance init failed - %v\n", err)
			os.Exit(1)
		}

		// initialize proxymgr
		err = proxymgr.Init()
		if err != nil {
			fmt.Printf("Proxymgr init failed - %v\n", err)
			os.Exit(1)
		}

		// initialize vipmgr
		err = vipmgr.Init()
		if err != nil {
			fmt.Printf("Vipmgr init failed - %v\n", err)
			os.Exit(1)
		}

		err = cluster.Init()
		if err != nil {
			fmt.Printf("Cluster init failed - %v\n", err)
			os.Exit(1)
		}
	}
}
开发者ID:nanopack,项目名称:portal,代码行数:50,代码来源:redis_test.go


示例19: initialize

// manually configure and start internals
func initialize() error {
	http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
	config.ListenHttp = "127.0.0.1:3234"
	config.ListenTcp = "127.0.0.1:3235"
	config.ListenUdp = "127.0.0.1:3234"
	config.DbAddress = "boltdb:///tmp/authTest/logvac.bolt"
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt("ERROR"))

	// initialize logvac
	logvac.Init()

	// setup authenticator
	config.AuthAddress = ""
	err := authenticator.Init()
	if err != nil {
		return fmt.Errorf("Authenticator failed to initialize - %v", err)
	}
	config.AuthAddress = "file:///tmp/authTest/logvac-auth.bolt"
	err = authenticator.Init()
	if err != nil {
		return fmt.Errorf("Authenticator failed to initialize - %v", err)
	}
	config.AuthAddress = "[email protected]#$%^&*()_"
	err = authenticator.Init()
	if err == nil {
		return fmt.Errorf("Authenticator failed to initialize - %v", err)
	}
	config.AuthAddress = "boltdb:///tmp/authTest/logvac-auth.bolt"
	err = authenticator.Init()
	if err != nil {
		return fmt.Errorf("Authenticator failed to initialize - %v", err)
	}

	// initialize drains
	err = drain.Init()
	if err != nil {
		return fmt.Errorf("Drain failed to initialize - %v", err)
	}

	// initializes collectors
	err = collector.Init()
	if err != nil {
		return fmt.Errorf("Collector failed to initialize - %v", err)
	}

	return nil
}
开发者ID:nanopack,项目名称:logvac,代码行数:48,代码来源:authenticator_test.go


示例20: startRedundis

// startRedundis reads a specified config file, initializes the logger, and starts
// redundis
func startRedundis(ccmd *cobra.Command, args []string) {
	if err := config.ReadConfigFile(configFile); err != nil {
		config.Log.Fatal("Failed to read config - %v", err)
		os.Exit(1)
	}

	// initialize logger
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt(config.LogLevel))
	config.Log.Prefix("[redundis]")

	// initialize redundis
	err := redundis.Start()
	if err != nil {
		config.Log.Fatal("Failed to listen - %v", err)
		os.Exit(1)
	}
}
开发者ID:nanopack,项目名称:redundis,代码行数:19,代码来源:main.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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