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

Golang gosteno.NewLogger函数代码示例

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

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



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

示例1: NewRouter

func NewRouter(cfg *config.Config, p proxy.Proxy, mbusClient yagnats.NATSConn, r *registry.RouteRegistry,
	v varz.Varz, logCounter *vcap.LogCounter, errChan chan error) (*Router, error) {

	var host string
	if cfg.Status.Port != 0 {
		host = fmt.Sprintf("%s:%d", cfg.Ip, cfg.Status.Port)
	}

	varz := &vcap.Varz{
		UniqueVarz: v,
		GenericVarz: vcap.GenericVarz{
			Type:        "Router",
			Index:       cfg.Index,
			Host:        host,
			Credentials: []string{cfg.Status.User, cfg.Status.Pass},
			LogCounts:   logCounter,
		},
	}

	healthz := &vcap.Healthz{}

	component := &vcap.VcapComponent{
		Config:  cfg,
		Varz:    varz,
		Healthz: healthz,
		InfoRoutes: map[string]json.Marshaler{
			"/routes": r,
		},
		Logger: steno.NewLogger("common.logger"),
	}

	routerErrChan := errChan
	if routerErrChan == nil {
		routerErrChan = make(chan error, 2)
	}

	router := &Router{
		config:       cfg,
		proxy:        p,
		mbusClient:   mbusClient,
		registry:     r,
		varz:         v,
		component:    component,
		serveDone:    make(chan struct{}),
		tlsServeDone: make(chan struct{}),
		idleConns:    make(map[net.Conn]struct{}),
		activeConns:  make(map[net.Conn]struct{}),
		logger:       steno.NewLogger("router"),
		errChan:      routerErrChan,
		stopping:     false,
	}

	if err := router.component.Start(); err != nil {
		return nil, err
	}

	return router, nil
}
开发者ID:idouba,项目名称:gorouter,代码行数:58,代码来源:router.go


示例2: TestDontSendEmptyData

func TestDontSendEmptyData(t *testing.T) {
	bufferSize := 4096
	loggregatorClient := l.NewLoggregatorClient("localhost:9876", gosteno.NewLogger("TestLogger"), bufferSize)

	udpAddr, err := net.ResolveUDPAddr("udp", "localhost:9876")
	if err != nil {
		t.Errorf("Expected no error, but got %v", err)
	}

	udpListener, err := net.ListenUDP("udp", udpAddr)
	defer udpListener.Close()
	if err != nil {
		t.Errorf("Expected no error, but got %v", err)
	}

	firstMessage := []byte("")
	secondMessage := []byte("hi")
	loggregatorClient.Send(firstMessage)
	loggregatorClient.Send(secondMessage)

	buffer := make([]byte, bufferSize)
	readCount, _, err := udpListener.ReadFromUDP(buffer)

	if err != nil {
		t.Errorf("Expected no error, but got %v", err)
	}

	received := string(buffer[:readCount])
	if string(secondMessage) != received {
		t.Errorf("Expected %s to equal %s", string(secondMessage), received)
	}
}
开发者ID:muhqu,项目名称:gotestit,代码行数:32,代码来源:testing_test.go


示例3: NewAtkListService

func NewAtkListService(cloudController CloudController, SpaceSummaryHelper SpaceSummaryHelper) *AtkListService {
	return &AtkListService{
		cloudController:    cloudController,
		SpaceSummaryHelper: SpaceSummaryHelper,
		logger:             gosteno.NewLogger("atk_list_service"),
	}
}
开发者ID:blkrs,项目名称:app-launcher-helper,代码行数:7,代码来源:atk_list_service.go


示例4: main

func main() {
	flag.Parse()

	if *version {
		fmt.Printf("\n\nversion: %s\ngitSha: %s\n\n", versionNumber, gitSha)
		return
	}

	level := gosteno.LOG_INFO

	if *logLevel {
		level = gosteno.LOG_DEBUG
	}

	loggingConfig := &gosteno.Config{
		Sinks:     make([]gosteno.Sink, 1),
		Level:     level,
		Codec:     gosteno.NewJsonCodec(),
		EnableLOC: true}
	if strings.TrimSpace(*logFilePath) == "" {
		loggingConfig.Sinks[0] = gosteno.NewIOSink(os.Stdout)
	} else {
		loggingConfig.Sinks[0] = gosteno.NewFileSink(*logFilePath)
	}
	gosteno.Init(loggingConfig)
	logger := gosteno.NewLogger("deaagent")

	loggregatorClient := loggregatorclient.NewLoggregatorClient(*loggregatorAddress, logger, 4096)

	agent := deaagent.NewAgent(*instancesJsonFilePath, logger)
	agent.Start(loggregatorClient)
}
开发者ID:shageman,项目名称:loggregator,代码行数:32,代码来源:main.go


示例5: NewProxy

func NewProxy(args ProxyArgs) Proxy {
	return &proxy{
		accessLogger: args.AccessLogger,
		traceKey:     args.TraceKey,
		ip:           args.Ip,
		logger:       steno.NewLogger("router.proxy"),
		registry:     args.Registry,
		reporter:     args.Reporter,
		transport: &http.Transport{
			Dial: func(network, addr string) (net.Conn, error) {
				conn, err := net.DialTimeout(network, addr, 5*time.Second)
				if err != nil {
					return conn, err
				}
				if args.EndpointTimeout > 0 {
					err = conn.SetDeadline(time.Now().Add(args.EndpointTimeout))
				}
				return conn, err
			},
			DisableKeepAlives:     true,
			ResponseHeaderTimeout: args.EndpointTimeout,
		},
		waitgroup: &sync.WaitGroup{},
	}
}
开发者ID:ninglipeng,项目名称:gorouter,代码行数:25,代码来源:proxy.go


示例6: NewProxy

func NewProxy(args ProxyArgs) Proxy {
	p := &proxy{
		accessLogger: args.AccessLogger,
		traceKey:     args.TraceKey,
		ip:           args.Ip,
		logger:       steno.NewLogger("router.proxy"),
		registry:     args.Registry,
		reporter:     args.Reporter,
		transport: &http.Transport{
			Dial: func(network, addr string) (net.Conn, error) {
				conn, err := net.DialTimeout(network, addr, 5*time.Second)
				if err != nil {
					return conn, err
				}
				if args.EndpointTimeout > 0 {
					err = conn.SetDeadline(time.Now().Add(args.EndpointTimeout))
				}
				return conn, err
			},
			DisableKeepAlives:  true,
			DisableCompression: true,
		},
		secureCookies: args.SecureCookies,
	}
	return p
}
开发者ID:trainchou,项目名称:gorouter,代码行数:26,代码来源:proxy.go


示例7: CreateRunningAccessLogger

func CreateRunningAccessLogger(config *config.Config) (AccessLogger, error) {
	loggregatorUrl := config.LoggregatorConfig.Url

	if config.AccessLog == "" && loggregatorUrl == "" {
		return &NullAccessLogger{}, nil
	}

	logger := steno.NewLogger("access_log")

	var err error
	var file *os.File
	if config.AccessLog != "" {
		file, err = os.OpenFile(config.AccessLog, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
		if err != nil {
			logger.Errorf("Error creating accesslog file, %s: (%s)", config.AccessLog, err.Error())
			return nil, err
		}
	}

	var e emitter.Emitter
	if loggregatorUrl != "" {
		loggregatorSharedSecret := config.LoggregatorConfig.SharedSecret
		e, err = NewEmitter(loggregatorUrl, loggregatorSharedSecret, config.Index)
		if err != nil {
			logger.Errorf("Error creating loggregator emitter: (%s)", err.Error())
			return nil, err
		}
	}

	accessLogger := NewFileAndLoggregatorAccessLogger(file, e)
	go accessLogger.Run()
	return accessLogger, nil
}
开发者ID:tomzhang,项目名称:golang-devops-stuff,代码行数:33,代码来源:create_running_access_logger.go


示例8: CreateRunningAccessLogger

func CreateRunningAccessLogger(config *config.Config) (AccessLogger, error) {

	if config.AccessLog == "" && !config.Logging.LoggregatorEnabled {
		return &NullAccessLogger{}, nil
	}

	logger := steno.NewLogger("access_log")

	var err error
	var file *os.File
	if config.AccessLog != "" {
		file, err = os.OpenFile(config.AccessLog, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
		if err != nil {
			logger.Errorf("Error creating accesslog file, %s: (%s)", config.AccessLog, err.Error())
			return nil, err
		}
	}

	var dropsondeSourceInstance string
	if config.Logging.LoggregatorEnabled {
		dropsondeSourceInstance = strconv.FormatUint(uint64(config.Index), 10)
	}

	accessLogger := NewFileAndLoggregatorAccessLogger(file, dropsondeSourceInstance)
	go accessLogger.Run()
	return accessLogger, nil
}
开发者ID:ninglipeng,项目名称:gorouter,代码行数:27,代码来源:create_running_access_logger.go


示例9: NewEmitter

func NewEmitter(loggregatorUrl, loggregatorSharedSecret string, index uint) (emitter.Emitter, error) {
	if !isValidUrl(loggregatorUrl) {
		return nil, fmt.Errorf("Invalid loggregator url %s", loggregatorUrl)
	}
	return emitter.NewEmitter(loggregatorUrl, "RTR", strconv.FormatUint(uint64(index), 10), loggregatorSharedSecret,
		steno.NewLogger("router.loggregator"))
}
开发者ID:tomzhang,项目名称:golang-devops-stuff,代码行数:7,代码来源:file_and_loggregator_access_logger.go


示例10: main

func main() {
	flag.Parse()

	level, err := gosteno.GetLogLevel(*logLevel)
	if err != nil {
		level = gosteno.LOG_INFO
	}
	loggingConfig := &gosteno.Config{
		Sinks: []gosteno.Sink{
			gosteno.NewIOSink(os.Stdout),
		},
		Level:     level,
		Codec:     gosteno.NewJsonCodec(),
		EnableLOC: true,
	}

	gosteno.Init(loggingConfig)
	logger := gosteno.NewLogger("statsdinjector")

	statsdMessageListener := statsdlistener.New(*statsdPort, logger)
	statsdEmitter := statsdemitter.New(*metronPort, logger)

	inputChan := make(chan *events.Envelope)

	go statsdMessageListener.Run(inputChan)
	statsdEmitter.Run(inputChan)
}
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:27,代码来源:main.go


示例11: Process

func (c *Config) Process() {
	var err error

	c.PruneStaleDropletsInterval = time.Duration(c.PruneStaleDropletsIntervalInSeconds) * time.Second
	c.DropletStaleThreshold = time.Duration(c.DropletStaleThresholdInSeconds) * time.Second
	c.PublishActiveAppsInterval = time.Duration(c.PublishActiveAppsIntervalInSeconds) * time.Second
	c.StartResponseDelayInterval = time.Duration(c.StartResponseDelayIntervalInSeconds) * time.Second
	c.EndpointTimeout = time.Duration(c.EndpointTimeoutInSeconds) * time.Second

	if c.StartResponseDelayInterval > c.DropletStaleThreshold {
		c.DropletStaleThreshold = c.StartResponseDelayInterval
		log := steno.NewLogger("config.logger")
		log.Warnf("DropletStaleThreshold (%s) cannot be less than StartResponseDelayInterval (%s); setting both equal to StartResponseDelayInterval and continuing", c.DropletStaleThreshold, c.StartResponseDelayInterval)
	}

	drain := c.DrainTimeoutInSeconds
	if drain == 0 {
		drain = c.EndpointTimeoutInSeconds
	}
	c.DrainTimeout = time.Duration(drain) * time.Second

	c.Ip, err = vcap.LocalIP()
	if err != nil {
		panic(err)
	}
}
开发者ID:johannespetzold,项目名称:gorouter,代码行数:26,代码来源:config.go


示例12: main

func main() {
	flag.Parse()

	if *version {
		fmt.Printf("\n\nversion: %s\ngitSha: %s\n\n", versionNumber, gitSha)
		return
	}

	level := gosteno.LOG_INFO

	if *logLevel {
		level = gosteno.LOG_DEBUG
	}

	loggingConfig := &gosteno.Config{
		Sinks:     make([]gosteno.Sink, 1),
		Level:     level,
		Codec:     gosteno.NewJsonCodec(),
		EnableLOC: true}

	if strings.TrimSpace(*logFilePath) == "" {
		loggingConfig.Sinks[0] = gosteno.NewIOSink(os.Stdout)
	} else {
		loggingConfig.Sinks[0] = gosteno.NewFileSink(*logFilePath)
	}
	gosteno.Init(loggingConfig)
	logger := gosteno.NewLogger("loggregator")

	listener := loggregator.NewAgentListener(*host, logger)
	incomingData := listener.Start()

	cfSink := loggregator.NewCfSink(incomingData, logger)
	cfSink.Start()
}
开发者ID:shageman,项目名称:loggregator,代码行数:34,代码来源:main.go


示例13: NewLogger

func NewLogger(verbose bool, logFilePath, name string, syslogNamespace string) *gosteno.Logger {
	level := gosteno.LOG_INFO

	if verbose {
		level = gosteno.LOG_DEBUG
	}

	loggingConfig := &gosteno.Config{
		Sinks:     make([]gosteno.Sink, 1),
		Level:     level,
		Codec:     gosteno.NewJsonCodec(),
		EnableLOC: true}

	if strings.TrimSpace(logFilePath) == "" {
		loggingConfig.Sinks[0] = gosteno.NewIOSink(os.Stdout)
	} else {
		loggingConfig.Sinks[0] = gosteno.NewFileSink(logFilePath)
	}

	if syslogNamespace != "" {
		loggingConfig.Sinks = append(loggingConfig.Sinks, GetNewSyslogSink(syslogNamespace))
	}

	gosteno.Init(loggingConfig)
	logger := gosteno.NewLogger(name)
	logger.Debugf("Component %s in debug mode!", name)

	return logger
}
开发者ID:lyuyun,项目名称:loggregator,代码行数:29,代码来源:logger.go


示例14: TestSend

func TestSend(t *testing.T) {
	bufferSize := 4096
	loggregatorClient := l.NewLoggregatorClient("localhost:9876", gosteno.NewLogger("TestLogger"), bufferSize)

	udpAddr, err := net.ResolveUDPAddr("udp", "localhost:9876")
	if err != nil {
		t.Errorf("Expected no error, but got %v", err)
	}

	udpListener, err := net.ListenUDP("udp", udpAddr)
	defer udpListener.Close()
	if err != nil {
		t.Errorf("Expected no error, but got %v", err)
	}

	expectedOutput := []byte("Important Testmessage")
	loggregatorClient.Send(expectedOutput)

	buffer := make([]byte, bufferSize)
	readCount, _, err := udpListener.ReadFromUDP(buffer)
	if err != nil {
		t.Errorf("Expected no error, but got %v", err)
	}

	received := string(buffer[:readCount])
	if string(expectedOutput) != received {
		t.Errorf("Expected %s to equal %s", string(expectedOutput), received)
	}
}
开发者ID:muhqu,项目名称:gotestit,代码行数:29,代码来源:testing_test.go


示例15: SetupLoggerFromConfig

func SetupLoggerFromConfig(c *config.Config) {
	l, err := steno.GetLogLevel(c.Logging.Level)
	if err != nil {
		panic(err)
	}

	s := make([]steno.Sink, 0)
	if c.Logging.File != "" {
		s = append(s, steno.NewFileSink(c.Logging.File))
	} else {
		s = append(s, steno.NewIOSink(os.Stdout))
	}

	if c.Logging.Syslog != "" {
		s = append(s, steno.NewSyslogSink(c.Logging.Syslog))
	}

	stenoConfig := &steno.Config{
		Sinks: s,
		Codec: steno.NewJsonCodec(),
		Level: l,
	}

	steno.Init(stenoConfig)
	log = steno.NewLogger("router")
}
开发者ID:hfeeki,项目名称:gorouter,代码行数:26,代码来源:logger.go


示例16: NewReporter

func NewReporter() *Reporter {
	rep := &Reporter{}

	rep.logger = steno.NewLogger("ila.reporter")

	config := configuration.NewRepositoryFromFilepath(configuration.DefaultFilePath(), func(err error) {
		if err != nil {
			rep.logger.Info("error reading api configuration")
		}
	})

	gateways := map[string]net.Gateway{
		"auth":             net.NewUAAGateway(config),
		"cloud-controller": net.NewCloudControllerGateway(config, time.Now),
		"uaa":              net.NewUAAGateway(config),
	}

	rep.apiAuth = api.NewUAAAuthenticationRepository(gateways["auth"], config)
	rep.credentials = make(map[string]string)
	rep.credentials["username"] = "admin"
	rep.credentials["password"] = "c1oudc0w"

	apiErr := rep.apiAuth.Authenticate(rep.credentials)

	rep.AppRepo = api.NewCloudControllerApplicationRepository(config, gateways["cloud-controller"])
	if apiErr != nil {
		//cmd.ui.Failed(apiErr.Error())
		rep.logger.Info("error authenticating")
	} else {
		rep.logger.Info("successfully authenticated")
	}

	return rep
}
开发者ID:mgazz,项目名称:ila,代码行数:34,代码来源:reporter.go


示例17: NewProxy

func NewProxy(args ProxyArgs) Proxy {
	routeServiceConfig := route_service.NewRouteServiceConfig(args.RouteServiceEnabled, args.RouteServiceTimeout, args.Crypto, args.CryptoPrev)

	p := &proxy{
		accessLogger: args.AccessLogger,
		traceKey:     args.TraceKey,
		ip:           args.Ip,
		logger:       steno.NewLogger("router.proxy"),
		registry:     args.Registry,
		reporter:     args.Reporter,
		transport: &http.Transport{
			Dial: func(network, addr string) (net.Conn, error) {
				conn, err := net.DialTimeout(network, addr, 5*time.Second)
				if err != nil {
					return conn, err
				}
				if args.EndpointTimeout > 0 {
					err = conn.SetDeadline(time.Now().Add(args.EndpointTimeout))
				}
				return conn, err
			},
			DisableKeepAlives:  true,
			DisableCompression: true,
			TLSClientConfig:    args.TLSConfig,
		},
		fakedomain:         args.FakeDomain,
		secureCookies:      args.SecureCookies,
		routeServiceConfig: routeServiceConfig,
		ExtraHeadersToLog:  args.ExtraHeadersToLog,
	}

	return p
}
开发者ID:qinguoan,项目名称:vulcan,代码行数:33,代码来源:proxy.go


示例18: loadLoggerAndConfig

func loadLoggerAndConfig(c *cli.Context, component string) (logger.Logger, *gosteno.Logger, *config.Config) {
	configPath := c.String("config")
	if configPath == "" {
		fmt.Printf("Config path required")
		os.Exit(1)
	}

	conf, err := config.FromFile(configPath)
	if err != nil {
		fmt.Printf("Failed to load config: %s", err.Error())
		os.Exit(1)
	}

	stenoConf := &gosteno.Config{
		Sinks: []gosteno.Sink{
			gosteno.NewIOSink(os.Stdout),
			gosteno.NewSyslogSink("vcap.hm9000." + component),
		},
		Level: conf.LogLevel(),
		Codec: gosteno.NewJsonCodec(),
	}
	gosteno.Init(stenoConf)
	steno := gosteno.NewLogger("vcap.hm9000." + component)
	hmLogger := logger.NewRealLogger(steno)

	return hmLogger, steno, conf
}
开发者ID:johntdyer,项目名称:golang-devops-stuff,代码行数:27,代码来源:hm9000.go


示例19: main

func main() {
	var configPath string
	flag.StringVar(&configPath,
		"conf",
		"", "Path of the YAML configuration of the co-located DEA.")
	flag.Parse()

	config, err := common.ConfigFromFile(configPath)
	if err != nil {
		panic(err.Error())
	}

	common.SetupSteno(&config.Server.Logging)
	log := steno.NewLogger("runner")

	var localIp *string
	localIp, err = getLocalIp()

	if err != nil {
		log.Fatal(err.Error())
	}

	if err := directoryserver.Start(*localIp, config); err != nil {
		log.Fatal(err.Error())
	}
}
开发者ID:yahuijiang,项目名称:cloudfoundry,代码行数:26,代码来源:runner.go


示例20: NewLogger

func NewLogger(name string) *gosteno.Logger {
	if !initialized {
		initLogging()
		initialized = true
	}

	return gosteno.NewLogger(name)
}
开发者ID:nkuacac,项目名称:pat,代码行数:8,代码来源:config.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang gosteno.Logger类代码示例发布时间:2022-05-23
下一篇:
Golang gosteno.NewJsonCodec函数代码示例发布时间: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